Class: Chef::Log::WinEvt

Inherits:
Object
  • Object
show all
Includes:
Mixin::Unformatter
Defined in:
lib/chef/log/winevt.rb

Overview

Chef::Log::WinEvt class. usage in client.rb:

log_location Chef::Log::WinEvt.new

Constant Summary collapse

INFO_EVENT_ID =

These must match those that are defined in the manifest file

10100
WARN_EVENT_ID =
10101
DEBUG_EVENT_ID =
10102
ERROR_EVENT_ID =
10103
FATAL_EVENT_ID =
10104
SOURCE =

Since we must install the event logger, this is not really configurable

"Chef"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixin::Unformatter

#write

Constructor Details

#initialize(eventlog = nil) ⇒ WinEvt

Returns a new instance of WinEvt.



45
46
47
# File 'lib/chef/log/winevt.rb', line 45

def initialize(eventlog = nil)
  @eventlog = eventlog || ::Win32::EventLog.open("Application")
end

Instance Attribute Details

#formatterObject

Returns the value of attribute formatter.



43
44
45
# File 'lib/chef/log/winevt.rb', line 43

def formatter
  @formatter
end

#levelObject

Returns the value of attribute level.



43
44
45
# File 'lib/chef/log/winevt.rb', line 43

def level
  @level
end

#syncObject

Returns the value of attribute sync.



43
44
45
# File 'lib/chef/log/winevt.rb', line 43

def sync
  @sync
end

Instance Method Details

#closeObject



49
50
# File 'lib/chef/log/winevt.rb', line 49

def close
end

#debug(msg) ⇒ Object



70
71
72
73
74
75
76
77
# File 'lib/chef/log/winevt.rb', line 70

def debug(msg)
  @eventlog.report_event(
    :event_type => ::Win32::EventLog::INFO_TYPE,
    :source => SOURCE,
    :event_id => DEBUG_EVENT_ID,
    :data => [msg]
  )
end

#error(msg) ⇒ Object



79
80
81
82
83
84
85
86
# File 'lib/chef/log/winevt.rb', line 79

def error(msg)
  @eventlog.report_event(
    :event_type => ::Win32::EventLog::ERROR_TYPE,
    :source => SOURCE,
    :event_id => ERROR_EVENT_ID,
    :data => [msg]
  )
end

#fatal(msg) ⇒ Object



88
89
90
91
92
93
94
95
# File 'lib/chef/log/winevt.rb', line 88

def fatal(msg)
  @eventlog.report_event(
    :event_type => ::Win32::EventLog::ERROR_TYPE,
    :source => SOURCE,
    :event_id => FATAL_EVENT_ID,
    :data => [msg]
  )
end

#info(msg) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/chef/log/winevt.rb', line 52

def info(msg)
  @eventlog.report_event(
    :event_type => ::Win32::EventLog::INFO_TYPE,
    :source => SOURCE,
    :event_id => INFO_EVENT_ID,
    :data => [msg]
  )
end

#warn(msg) ⇒ Object



61
62
63
64
65
66
67
68
# File 'lib/chef/log/winevt.rb', line 61

def warn(msg)
  @eventlog.report_event(
    :event_type => ::Win32::EventLog::WARN_TYPE,
    :source => SOURCE,
    :event_id => WARN_EVENT_ID,
    :data => [msg]
  )
end