Class: KXI::Application::Logger
- Inherits:
-
Object
- Object
- KXI::Application::Logger
- Defined in:
- lib/kxi/application/logger.rb
Overview
Allows simple unstructured (time-independent) logging
Defined Under Namespace
Classes: Message
Instance Method Summary collapse
-
#attach(min = Message::Severity::COMMAND) {|msg| ... } ⇒ Number
Attaches action to message event.
-
#command(cmd) ⇒ Object
Logs message with the Message::Severity::COMMAND severity.
-
#debug(msg) ⇒ Object
Logs message with the Message::Severity::DEBUG severity.
-
#error(msg) ⇒ Object
Logs message with the Message::Severity::ERROR severity.
-
#fatal(msg) ⇒ Object
Logs message with the Message::Severity::FATAL severity.
-
#info(msg) ⇒ Object
Logs message with the Message::Severity::INFO severity.
-
#initialize ⇒ Logger
constructor
Instantiates the Logger class.
-
#on_message ⇒ KXI::Application::Event
Gets the message event.
-
#trace(msg) ⇒ Object
Logs message with the Message::Severity::TRACE severity.
-
#warning(msg) ⇒ Object
Logs message with the Message::Severity::WARNING severity.
Constructor Details
#initialize ⇒ Logger
Instantiates the KXI::Application::Logger class
23 24 25 26 |
# File 'lib/kxi/application/logger.rb', line 23 def initialize @event = KXI::Application::Event.new @start = DateTime.now end |
Instance Method Details
#attach(min = Message::Severity::COMMAND) {|msg| ... } ⇒ Number
Attaches action to message event
18 19 20 |
# File 'lib/kxi/application/logger.rb', line 18 def attach(min = Message::Severity::COMMAND, &block) return @event.add { |s, msg| block.call(msg) if msg.severity.level >= min.level } end |
#command(cmd) ⇒ Object
Logs message with the KXI::Application::Logger::Message::Severity::COMMAND severity
30 31 32 |
# File 'lib/kxi/application/logger.rb', line 30 def command(cmd) log(Message::Severity::COMMAND, cmd) end |
#debug(msg) ⇒ Object
Logs message with the KXI::Application::Logger::Message::Severity::DEBUG severity
42 43 44 |
# File 'lib/kxi/application/logger.rb', line 42 def debug(msg) log(Message::Severity::DEBUG, msg) end |
#error(msg) ⇒ Object
Logs message with the KXI::Application::Logger::Message::Severity::ERROR severity
60 61 62 |
# File 'lib/kxi/application/logger.rb', line 60 def error(msg) log(Message::Severity::ERROR, msg) end |
#fatal(msg) ⇒ Object
Logs message with the KXI::Application::Logger::Message::Severity::FATAL severity
66 67 68 |
# File 'lib/kxi/application/logger.rb', line 66 def fatal(msg) log(Message::Severity::FATAL, msg) end |
#info(msg) ⇒ Object
Logs message with the KXI::Application::Logger::Message::Severity::INFO severity
48 49 50 |
# File 'lib/kxi/application/logger.rb', line 48 def info(msg) log(Message::Severity::INFO, msg) end |
#on_message ⇒ KXI::Application::Event
Gets the message event
9 10 11 |
# File 'lib/kxi/application/logger.rb', line 9 def @event end |
#trace(msg) ⇒ Object
Logs message with the KXI::Application::Logger::Message::Severity::TRACE severity
36 37 38 |
# File 'lib/kxi/application/logger.rb', line 36 def trace(msg) log(Message::Severity::TRACE, msg) end |
#warning(msg) ⇒ Object
Logs message with the KXI::Application::Logger::Message::Severity::WARNING severity
54 55 56 |
# File 'lib/kxi/application/logger.rb', line 54 def warning(msg) log(Message::Severity::WARNING, msg) end |