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

ChefUtils::Dist::Infra::SHORT.freeze

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.



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

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

Instance Attribute Details

#formatterObject

Returns the value of attribute formatter.



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

def formatter
  @formatter
end

#levelObject

Returns the value of attribute level.



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

def level
  @level
end

#syncObject

Returns the value of attribute sync.



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

def sync
  @sync
end

Instance Method Details

#closeObject



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

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