mperdeck / jsnlog.js

Tiny JavaScript logging library, simple and well documented. Lots of options to filter logging data.
js.jsnlog.com
Other
130 stars 43 forks source link

Type 'ConsoleTransportInstance' is not assignable to type 'JSNLogAppender' #71

Closed vdepatla closed 5 years ago

vdepatla commented 6 years ago

Getting below error when I try to assign winston console transport as an appender. Any Idea ? Type 'ConsoleTransportInstance' is not assignable to type 'JSNLogAppender'. Property 'setOptions' is missing in type 'ConsoleTransportInstance'.

Code : const consoleAppender = new winston.transports.Console({ json: false, formatter: options => { const logEntry: ClientSideLoggingResult = { host: os.hostname(), pid: process.pid, level: options.level.toString(), ts: moment().format(), eventData: options.meta, component: globalStrings.componentName }; return JSON.stringify(logEntry); } });

    JL().setOptions({ appenders: [consoleAppender] });
bender316 commented 5 years ago

The type definitions don't allow a winston transport to be used as an appender. A (dirty) workaround is to set the appender in pure JS code. But this also works just up to winston:2.4.4.

Apparently winston support is utterly broken in jsnlog.

mperdeck commented 5 years ago

A fix for this has now been released as part of version 2.29.0.