summaryrefslogtreecommitdiff
path: root/ext/win32-eventlog
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2014-07-31 22:37:08 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2014-10-22 13:03:18 -0700
commit7546df7b4bfed2071ca1cc46c4d3f14286b6cd37 (patch)
tree7d5940b0471f2dbe7679edef7de714d9132cfa82 /ext/win32-eventlog
parentbb7682124e6f3a97e558ceb0f817e61e80508933 (diff)
downloadchef-7546df7b4bfed2071ca1cc46c4d3f14286b6cd37.tar.gz
Build resource dll for event log and register it
Diffstat (limited to 'ext/win32-eventlog')
-rw-r--r--ext/win32-eventlog/Rakefile49
-rw-r--r--ext/win32-eventlog/chef-log.man26
2 files changed, 75 insertions, 0 deletions
diff --git a/ext/win32-eventlog/Rakefile b/ext/win32-eventlog/Rakefile
new file mode 100644
index 0000000000..0200783433
--- /dev/null
+++ b/ext/win32-eventlog/Rakefile
@@ -0,0 +1,49 @@
+require 'rubygems'
+require 'rake'
+require 'mkmf'
+require 'win32/eventlog'
+
+desc "Building event log dll"
+
+def ensure_present(commands)
+ commands.each do |c|
+ unless find_executable c
+ warn "Could not find #{c}. Windows Event Logging will not correctly function."
+ end
+ end
+end
+
+
+EVT_MC_FILE = 'chef-log.man'
+EVT_RC_FILE = 'chef-log.rc'
+EVT_RESOURCE_OBJECT = 'resource.o'
+EVT_SHARED_OBJECT = 'chef-log.dll'
+MC = 'windmc'
+RC = 'windres'
+CC = 'gcc'
+
+ensure_present [MC, RC, CC]
+
+task :default => [EVT_RESOURCE_OBJECT, EVT_SHARED_OBJECT, :register]
+
+file EVT_RC_FILE=> EVT_MC_FILE do
+ sh "#{MC} #{EVT_MC_FILE}"
+end
+
+file EVT_RESOURCE_OBJECT => EVT_RC_FILE do
+ sh "#{RC} -i #{EVT_RC_FILE} -o #{EVT_RESOURCE_OBJECT}"
+end
+
+file EVT_SHARED_OBJECT => EVT_RESOURCE_OBJECT do
+ sh "#{CC} -o #{EVT_SHARED_OBJECT} -shared #{EVT_RESOURCE_OBJECT}"
+end
+
+task :register => EVT_SHARED_OBJECT do
+ dll_file = File.expand_path(EVT_SHARED_OBJECT)
+ Win32::EventLog.add_event_source(
+ :source => "Application",
+ :key_name => "Chef",
+ :event_message_file => dll_file,
+ :category_message_file => dll_file
+ )
+end
diff --git a/ext/win32-eventlog/chef-log.man b/ext/win32-eventlog/chef-log.man
new file mode 100644
index 0000000000..35983db1de
--- /dev/null
+++ b/ext/win32-eventlog/chef-log.man
@@ -0,0 +1,26 @@
+MessageId=10000
+SymbolicName=RUN_START
+Language=English
+Starting chef-client run v%1
+.
+
+MessageId=10001
+SymbolicName=RUN_STARTED
+Language=English
+Started chef-client run %1
+.
+
+MessageId=10002
+SymbolicName=RUN_COMPLETED
+Language=English
+Completed chef-client run %1 in %2 seconds
+.
+
+MessageId=10003
+SymbolicName=RUN_FAILED
+Language=English
+Failed chef-client run %1 in %2 seconds.%n
+Exception type: %3%n
+Exception message: %4%n
+Exception backtrace: %5%n
+.