Class: Tml::Logger
- Inherits:
-
Logger
- Object
- Logger
- Tml::Logger
- Defined in:
- lib/tml/logger.rb
Instance Attribute Summary collapse
-
#external_logger ⇒ Object
Returns the value of attribute external_logger.
Instance Method Summary collapse
- #add(severity, message = nil, progname = nil, &block) ⇒ Object
- #debug(message) ⇒ Object
- #error(message) ⇒ Object
- #fatal(message) ⇒ Object
- #format_message(severity, timestamp, progname, msg) ⇒ Object
- #info(message) ⇒ Object
- #log_to_console(msg) ⇒ Object
- #stack ⇒ Object
- #trace(message) ⇒ Object
- #warn(message) ⇒ Object
Instance Attribute Details
#external_logger ⇒ Object
Returns the value of attribute external_logger.
59 60 61 |
# File 'lib/tml/logger.rb', line 59 def external_logger @external_logger end |
Instance Method Details
#add(severity, message = nil, progname = nil, &block) ⇒ Object
101 102 103 104 |
# File 'lib/tml/logger.rb', line 101 def add(severity, = nil, progname = nil, &block) return unless Tml.config.logger[:enabled] super end |
#debug(message) ⇒ Object
72 73 74 75 76 |
# File 'lib/tml/logger.rb', line 72 def debug() log_to_console() return external_logger.debug((Logger::Severity::DEBUG, Time.new, nil, )) if external_logger super end |
#error(message) ⇒ Object
84 85 86 87 88 |
# File 'lib/tml/logger.rb', line 84 def error() log_to_console() return external_logger.error((Logger::Severity::ERROR, Time.new, nil, )) if external_logger super end |
#fatal(message) ⇒ Object
90 91 92 93 94 |
# File 'lib/tml/logger.rb', line 90 def fatal() log_to_console() return external_logger.fatal((Logger::Severity::FATAL, Time.new, nil, )) if external_logger super end |
#format_message(severity, timestamp, progname, msg) ⇒ Object
96 97 98 99 |
# File 'lib/tml/logger.rb', line 96 def (severity, , progname, msg) return '' unless Tml.config.logger[:enabled] "[#{.strftime('%D %T')}]: tml: #{' ' * stack.size}#{msg}\n" end |
#info(message) ⇒ Object
66 67 68 69 70 |
# File 'lib/tml/logger.rb', line 66 def info() log_to_console() return external_logger.info((Logger::Severity::INFO, Time.new, nil, )) if external_logger super end |
#log_to_console(msg) ⇒ Object
61 62 63 64 |
# File 'lib/tml/logger.rb', line 61 def log_to_console(msg) return unless Tml.config.logger[:console] puts msg end |
#stack ⇒ Object
106 107 108 |
# File 'lib/tml/logger.rb', line 106 def stack @stack ||= [] end |