Windows Event Log Js
Native node.js module to log messages to the Windows Event Log.
$ npm install windows-eventlog
You need to have these two things installed in your system for now:
If you have a newer version of Visual Studio than 2010 installed, you need to configure your environment variables so that node_gyp knows what version you are using (2012, 2013, etc).
Initialize somewhere the logger like:
var EventLog = require('windows-eventlog').EventLog; var myeventlog = new EventLog("mySource"); myeventlog.log("a message");
And you will see this:
new EventLog(source[, logName])
This create an instance of the EventLog with the given source. You can optionally pass a logName, defaults to "Application".
If the source doesn't exist in the event log database it will be created with the givne log name.
This method will create an entry in the event log with the given message.
Optionally you can specify a logEntryType. The possible values for logEntryType are "Information", "Warning", "Error" and others two that you will never use :)
How it works
This module was built on c++/cli (.Net) and uses System.Diagnostics.EventLog.
In order to log events you need to run the application with an elevated account: ie administrator or system account. Windows services typically run under the system account, if you are looking on how to run node.js applications as a Windows Service have a look to WinSer.
- Use uv_queue_work to execute the writelog method in a different thread ( ? )
About win32 native modules
(The MIT License)
Copyright (c) 2012 Jose Romaniello <firstname.lastname@example.org>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.