Class: Chook::HandledEventLogger
- Inherits:
-
Object
- Object
- Chook::HandledEventLogger
- Defined in:
- lib/chook/event/handled_event_logger.rb
Overview
a simple object embedded in a Handled Event that allows a standardize way to note event-related log entries with the event object_id.
Every Handled Event has one of these instances exposed in it’s #logger attribute, and usable from within ‘internal’ handlers
Here’s an example.
Say you have a ComputerSmartGroupMembershipChanged event
calling ‘event.logger.info “foobar”` will generate the log message:
Event 1234567: foobar
Instance Method Summary collapse
- #debug(msg) ⇒ Object
- #error(msg) ⇒ Object
- #event_message(msg) ⇒ Object
- #fatal(msg) ⇒ Object
- #info(msg) ⇒ Object
-
#initialize(event) ⇒ HandledEventLogger
constructor
A new instance of HandledEventLogger.
-
#log_exception(exception) ⇒ Object
log an exception - multiple log lines the first being the error message the rest being indented backtrace.
- #unknown(msg) ⇒ Object
- #warn(msg) ⇒ Object
Constructor Details
#initialize(event) ⇒ HandledEventLogger
Returns a new instance of HandledEventLogger.
45 46 47 |
# File 'lib/chook/event/handled_event_logger.rb', line 45 def initialize(event) @event = event end |
Instance Method Details
#debug(msg) ⇒ Object
53 54 55 |
# File 'lib/chook/event/handled_event_logger.rb', line 53 def debug(msg) Chook::Server::Log.logger.debug (msg) end |
#error(msg) ⇒ Object
65 66 67 |
# File 'lib/chook/event/handled_event_logger.rb', line 65 def error(msg) Chook::Server::Log.logger.error (msg) end |
#event_message(msg) ⇒ Object
49 50 51 |
# File 'lib/chook/event/handled_event_logger.rb', line 49 def (msg) "Event #{@event.id}: #{msg}" end |
#fatal(msg) ⇒ Object
69 70 71 |
# File 'lib/chook/event/handled_event_logger.rb', line 69 def fatal(msg) Chook::Server::Log.logger.fatal (msg) end |
#info(msg) ⇒ Object
57 58 59 |
# File 'lib/chook/event/handled_event_logger.rb', line 57 def info(msg) Chook::Server::Log.logger.info (msg) end |
#log_exception(exception) ⇒ Object
log an exception - multiple log lines the first being the error message the rest being indented backtrace
79 80 81 82 |
# File 'lib/chook/event/handled_event_logger.rb', line 79 def log_exception(exception) error "#{exception.class}: #{exception}" exception.backtrace.each { |l| error "..#{l}" } end |