Class: Dialog::Log
- Inherits:
-
Object
- Object
- Dialog::Log
- Defined in:
- lib/tooling/log.rb
Instance Method Summary collapse
- #catch(message) ⇒ Object
- #debug(message) ⇒ Object
- #error(message) ⇒ Object
- #info(message) ⇒ Object
-
#initialize(debug_level) ⇒ Log
constructor
A new instance of Log.
- #warn(message) ⇒ Object
Constructor Details
#initialize(debug_level) ⇒ Log
Returns a new instance of Log.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/tooling/log.rb', line 21 def initialize(debug_level) @logger ||= Logger.new(STDERR) @logger.datetime_format = "sec: %S.%6N" @logger.formatter = proc do |severity, datetime, progname, msg| "#{msg}\n" end @logger.info 'Logger started' @debug_level = debug_level end |
Instance Method Details
#catch(message) ⇒ Object
32 33 34 |
# File 'lib/tooling/log.rb', line 32 def catch() @logger.debug "\033[33m#{}\033[0m" if [:debug].include? @debug_level.to_sym end |
#debug(message) ⇒ Object
36 37 38 |
# File 'lib/tooling/log.rb', line 36 def debug() @logger.debug "\033[32m#{}\033[0m" if [:debug].include? @debug_level.to_sym end |
#error(message) ⇒ Object
48 49 50 |
# File 'lib/tooling/log.rb', line 48 def error() @logger.error "\033[31m#{}\033[0m" if [:error, :warn, :info, :debug].include? @debug_level.to_sym end |
#info(message) ⇒ Object
40 41 42 |
# File 'lib/tooling/log.rb', line 40 def info() @logger.info "\033[36m#{}\033[0m" if [:info, :debug].include? @debug_level.to_sym end |
#warn(message) ⇒ Object
44 45 46 |
# File 'lib/tooling/log.rb', line 44 def warn() @logger.warn "\033[35m#{}\033[0m" if [:warn, :info, :debug].include? @debug_level.to_sym end |