juttle / winston-logrotate

Log rotating transport for Winston
Apache License 2.0
10 stars 8 forks source link

Added support for winston's built-in formatter function #9

Closed jathanasiou closed 7 years ago

jathanasiou commented 7 years ago

Added reference for the formatter transport parameter found in winston so as to support its usage in this extension. In regular winston transports this works like so:

var logger = new (winston.Logger)({
  transports: [
    new (winston.transports.Console)({
      timestamp: function() {
        return Date.now();
      },
      formatter: function(options) {
        // Return string will be passed to logger. 
        return options.timestamp() +' '+ options.level.toUpperCase() +' '+ (options.message ? options.message : '') +
          (options.meta && Object.keys(options.meta).length ? '\n\t'+ JSON.stringify(options.meta) : '' );
      }
    })
  ]
});

And now it should work with winston.transports.Rotate as well.

demmer commented 7 years ago

I just merged this and pushed a new release to npm.