winston-datadog icon indicating copy to clipboard operation
winston-datadog copied to clipboard

[feature request] add support for logger.add() function

Open jenskdsgn opened this issue 8 years ago • 2 comments

Right now this is the way to init the transports

var logger = new (winston.Logger)({
  transports: [
    /* ... */
  ]
});

It would be nice to use it with the add function of winston logger

logger.add(ddTransport, { /* options */ });

This could be useful if conditionally add logger or adding logger later as required ... Thanks

jenskdsgn avatar Jun 20 '16 15:06 jenskdsgn

You can do:

const ddTransport = new DatadogTransport({
  api_key: 'xx',
  app_key: 'yy'
});

winston.add(ddTransport, null, true);

Last parameter indicates that transport has already been instantiated.

meznaric avatar Sep 14 '16 13:09 meznaric

Yeah I had the same question. Suggestion above worked for me.

anselanza avatar Nov 16 '17 12:11 anselanza