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 |
# 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 @debug_level = debug_level end |
Instance Method Details
#catch(message) ⇒ Object
31 32 33 |
# File 'lib/tooling/log.rb', line 31 def catch() @logger.debug "\033[33m#{}\033[0m" if [:debug].include? @debug_level.to_sym end |
#debug(message) ⇒ Object
35 36 37 |
# File 'lib/tooling/log.rb', line 35 def debug() @logger.debug "\033[32m#{}\033[0m" if [:debug].include? @debug_level.to_sym end |
#error(message) ⇒ Object
47 48 49 |
# File 'lib/tooling/log.rb', line 47 def error() @logger.error "\033[31m#{}\033[0m" if [:error, :warn, :info, :debug].include? @debug_level.to_sym end |
#info(message) ⇒ Object
39 40 41 |
# File 'lib/tooling/log.rb', line 39 def info() @logger.info "\033[36m#{}\033[0m" if [:info, :debug].include? @debug_level.to_sym end |
#warn(message) ⇒ Object
43 44 45 |
# File 'lib/tooling/log.rb', line 43 def warn() @logger.warn "\033[35m#{}\033[0m" if [:warn, :info, :debug].include? @debug_level.to_sym end |