node-windows icon indicating copy to clipboard operation
node-windows copied to clipboard

EventLogger ignores source name defined in constructor

Open DominikPalo opened this issue 10 years ago • 3 comments

I'm using EventLogger for logging in my app, but all my logs have source set to "Node.js" instead of string which I defined in EventLogger constructor.

For example: var EventLogger = require('node-windows').EventLogger; var log = new EventLogger('TestLogger'); log.info('Test');

creates log in Windows Logs / Application with source "Node.js" instead of "TestLogger"

My Node.js version: 0.10.27, OS: Windows 8.1 x64

DominikPalo avatar Jun 16 '14 10:06 DominikPalo

@DominikPalo This should work as a work-around:

var log = new EventLogger({source:'TestLogger'});

dweremeichik avatar Jun 23 '14 15:06 dweremeichik

My messages source are set to "Unknown Application" even with the given workaround.

Code:

var log = new (require("node-windows").EventLogger)({source: "my app" });
log.info("test message");

nodejs: v12.7 os: Windows server 2008 R2 standard

blackshadev avatar Jul 28 '15 09:07 blackshadev

Ignore my last statement. The given example works, the problem within my program (which is actually allot bigger than the given example) is with the wrapping of the log functions.

eg.

console.log = log.info;

will not work as expected because the info(...) method needs information stored within the log instance. A working solution would be:

console.log = log.info.bind(log);

blackshadev avatar Jul 28 '15 09:07 blackshadev