Class: Inform
- Inherits:
-
Object
- Object
- Inform
- Defined in:
- lib/inform.rb,
lib/inform/version.rb
Constant Summary collapse
- CLEAR =
"\e[0m"
- BOLD =
"\e[1m"
- UNDERLINE =
"\e[4m"
- BLACK =
"\e[30m"
- RED =
"\e[31m"
- GREEN =
"\e[32m"
- YELLOW =
"\e[33m"
- BLUE =
"\e[34m"
- MAGENTA =
"\e[35m"
- CYAN =
"\e[36m"
- WHITE =
"\e[37m"
- DEFAULT_LOG_LEVEL =
:info
- LOG_LEVELS =
[:debug, :info, :warning, :error]
- VERSION =
"0.0.5"
Class Method Summary collapse
- .debug(message, args = nil) ⇒ Object
- .error(message, args = nil) ⇒ Object
- .info(message, args = nil) ⇒ Object
- .level ⇒ Object
- .level=(_level) ⇒ Object
- .warning(message, args = nil) ⇒ Object
Class Method Details
.debug(message, args = nil) ⇒ Object
33 34 35 |
# File 'lib/inform.rb', line 33 def debug(, args=nil) log(:debug, " " + color_args(, args, CYAN)) end |
.error(message, args = nil) ⇒ Object
52 53 54 |
# File 'lib/inform.rb', line 52 def error(, args=nil) log(:error, color('ERROR', RED, BOLD) + ': ' + color_args(, args, RED)) end |
.info(message, args = nil) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/inform.rb', line 37 def info(, args=nil) if block_given? log(:info, ">>> " + color_args(, args, GREEN) + " : ", :no_newline => true) ret = yield log(:info, color('Done.', GREEN), :continue_line => true, :prefix => '>>> ') ret else log(:info, "*** " + color_args(, args, GREEN)) end end |
.level ⇒ Object
24 25 26 |
# File 'lib/inform.rb', line 24 def level @level.nil? ? DEFAULT_LOG_LEVEL : @level end |
.level=(_level) ⇒ Object
28 29 30 31 |
# File 'lib/inform.rb', line 28 def level= _level raise "Unrecognized log level #{_level} (should be one of #{LOG_LEVELS.join(', ')})" unless LOG_LEVELS.include?(_level) @level = _level end |