class Chef::EventLoggers::WindowsEventLogger
Constants
- EVENT_CATEGORY_ID
- LOG_CATEGORY_ID
- RUN_COMPLETED_EVENT_ID
- RUN_FAILED_EVENT_ID
- RUN_STARTED_EVENT_ID
- RUN_START_EVENT_ID
These must match those that are defined in the manifest file
- SOURCE
Since we must install the event logger, this is not really configurable
Public Class Methods
available?()
click to toggle source
# File lib/chef/event_loggers/windows_eventlog.rb, line 41 def self.available? ChefUtils.windows? end
new()
click to toggle source
# File lib/chef/event_loggers/windows_eventlog.rb, line 45 def initialize @eventlog = ::Win32::EventLog.open("Application") end
Public Instance Methods
run_completed(node)
click to toggle source
# File lib/chef/event_loggers/windows_eventlog.rb, line 68 def run_completed(node) @eventlog.report_event( event_type: ::Win32::EventLog::INFO_TYPE, source: SOURCE, event_id: RUN_COMPLETED_EVENT_ID, data: [@run_status.run_id, @run_status.elapsed_time.to_s] ) end
run_failed(e)
click to toggle source
Failed chef-client run %1 in %2 seconds. Exception type: %3 Exception message: %4 Exception backtrace: %5
# File lib/chef/event_loggers/windows_eventlog.rb, line 81 def run_failed(e) data = if @run_status [@run_status.run_id, @run_status.elapsed_time.to_s] else %w{UNKNOWN UNKNOWN} end @eventlog.report_event( event_type: ::Win32::EventLog::ERROR_TYPE, source: SOURCE, event_id: RUN_FAILED_EVENT_ID, data: data + [e.class.name, e.message, e.backtrace.join("\n")] ) end
run_start(version, run_status)
click to toggle source
# File lib/chef/event_loggers/windows_eventlog.rb, line 49 def run_start(version, run_status) @eventlog.report_event( event_type: ::Win32::EventLog::INFO_TYPE, source: SOURCE, event_id: RUN_START_EVENT_ID, data: [version] ) end
run_started(run_status)
click to toggle source
# File lib/chef/event_loggers/windows_eventlog.rb, line 58 def run_started(run_status) @run_status = run_status @eventlog.report_event( event_type: ::Win32::EventLog::INFO_TYPE, source: SOURCE, event_id: RUN_STARTED_EVENT_ID, data: [run_status.run_id] ) end