class Chook::HandledEventLogger
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
Public Class Methods
new(event)
click to toggle source
# File lib/chook/event/handled_event_logger.rb, line 45 def initialize(event) @event = event end
Public Instance Methods
debug(msg)
click to toggle source
# File lib/chook/event/handled_event_logger.rb, line 53 def debug(msg) Chook::Server::Log.logger.debug event_message(msg) end
error(msg)
click to toggle source
# File lib/chook/event/handled_event_logger.rb, line 65 def error(msg) Chook::Server::Log.logger.error event_message(msg) end
event_message(msg)
click to toggle source
# File lib/chook/event/handled_event_logger.rb, line 49 def event_message(msg) "Event #{@event.id}: #{msg}" end
fatal(msg)
click to toggle source
# File lib/chook/event/handled_event_logger.rb, line 69 def fatal(msg) Chook::Server::Log.logger.fatal event_message(msg) end
info(msg)
click to toggle source
# File lib/chook/event/handled_event_logger.rb, line 57 def info(msg) Chook::Server::Log.logger.info event_message(msg) end
log_exception(exception)
click to toggle source
log an exception - multiple log lines the first being the error message the rest being indented backtrace
# 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
unknown(msg)
click to toggle source
# File lib/chook/event/handled_event_logger.rb, line 73 def unknown(msg) Chook::Server::Log.logger.unknown event_message(msg) end
warn(msg)
click to toggle source
# File lib/chook/event/handled_event_logger.rb, line 61 def warn(msg) Chook::Server::Log.logger.warn event_message(msg) end