Class: Chef::EventLoggers::WindowsEventLogger
- Inherits:
-
Base
- Object
- Chef::EventDispatch::Base
- Base
- Chef::EventLoggers::WindowsEventLogger
- Defined in:
- lib/chef/event_loggers/windows_eventlog.rb
Constant Summary collapse
- RUN_START_EVENT_ID =
These must match those that are defined in the manifest file
10000
- RUN_STARTED_EVENT_ID =
10001
- RUN_COMPLETED_EVENT_ID =
10002
- RUN_FAILED_EVENT_ID =
10003
- EVENT_CATEGORY_ID =
11000
- LOG_CATEGORY_ID =
11001
- SOURCE =
Since we must install the event logger, this is not really configurable
"Chef"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ WindowsEventLogger
constructor
A new instance of WindowsEventLogger.
- #run_completed(node) ⇒ Object
-
#run_failed(e) ⇒ Object
Failed chef-client run %1 in %2 seconds.
- #run_start(version) ⇒ Object
- #run_started(run_status) ⇒ Object
Methods inherited from Base
Methods inherited from Chef::EventDispatch::Base
#attribute_file_load_failed, #attribute_file_loaded, #attribute_load_complete, #attribute_load_start, #audit_phase_complete, #audit_phase_failed, #audit_phase_start, #control_example_failure, #control_example_success, #control_group_started, #converge_complete, #converge_failed, #converge_start, #cookbook_clean_complete, #cookbook_clean_start, #cookbook_gem_failed, #cookbook_gem_finished, #cookbook_gem_installing, #cookbook_gem_start, #cookbook_gem_using, #cookbook_resolution_complete, #cookbook_resolution_failed, #cookbook_resolution_start, #cookbook_sync_complete, #cookbook_sync_failed, #cookbook_sync_start, #definition_file_load_failed, #definition_file_loaded, #definition_load_complete, #definition_load_start, #deprecation, #handler_executed, #handlers_completed, #handlers_start, #library_file_load_failed, #library_file_loaded, #library_load_complete, #library_load_start, #lwrp_file_load_failed, #lwrp_file_loaded, #lwrp_load_complete, #lwrp_load_start, #msg, #node_load_completed, #node_load_failed, #node_load_start, #ohai_completed, #policyfile_loaded, #provider_requirement_failed, #recipe_file_load_failed, #recipe_file_loaded, #recipe_load_complete, #recipe_load_start, #recipe_not_found, #registration_completed, #registration_failed, #registration_start, #removed_cookbook_file, #resource_action_start, #resource_bypassed, #resource_completed, #resource_current_state_load_bypassed, #resource_current_state_loaded, #resource_failed, #resource_failed_retriable, #resource_skipped, #resource_up_to_date, #resource_update_applied, #resource_update_progress, #resource_updated, #run_list_expand_failed, #run_list_expanded, #skipping_registration, #stream_closed, #stream_opened, #stream_output, #synchronized_cookbook, #updated_cookbook_file, #whyrun_assumption
Constructor Details
#initialize ⇒ WindowsEventLogger
Returns a new instance of WindowsEventLogger.
44 45 46 |
# File 'lib/chef/event_loggers/windows_eventlog.rb', line 44 def initialize @eventlog = ::Win32::EventLog.open("Application") end |
Class Method Details
Instance Method Details
#run_completed(node) ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/chef/event_loggers/windows_eventlog.rb', line 67 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) ⇒ Object
Failed chef-client run %1 in %2 seconds. Exception type: %3 Exception message: %4 Exception backtrace: %5
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/chef/event_loggers/windows_eventlog.rb', line 80 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., e.backtrace.join("\n")] ) end |
#run_start(version) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/chef/event_loggers/windows_eventlog.rb', line 48 def run_start(version) @eventlog.report_event( :event_type => ::Win32::EventLog::INFO_TYPE, :source => SOURCE, :event_id => RUN_START_EVENT_ID, :data => [version] ) end |
#run_started(run_status) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/chef/event_loggers/windows_eventlog.rb', line 57 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 |