nemtsov / node-bunyan-logentries

Bunyan logger stream for Logentries
MIT License
8 stars 9 forks source link

upgrading to v1.2.0 #6

Closed mariosvlad closed 8 years ago

mariosvlad commented 8 years ago

can you please provide a more complete example or the changes required for 1.1 -> 1.2? my current code that works for 1.1 is something like this:

  var log = bunyan.createLogger({
    name: "beta",
    streams: [{
      level: 'info',
      stream: bunyanLogentries.createStream({token: token}),
      type: 'raw'
    }],
    serializers: { // add serializers for req, res and err
      req: bunyan.stdSerializers.req,
      res: bunyan.stdSerializers.res,
      err: bunyan.stdSerializers.err
    }
  });

  var my_logger = log.child({type: 'myCustomLogger'});
  my_logger.error('error!!!');
  my_logger.info('some info log');

after upgrading to 1.2.0 i get the error The log method was called with the unknown level "undefined" , after reading the tests i assume i will have to send an object like this {msg: 'my log msg', level: 20} but what function should i call (previously it was error, info,... ) if the level is already specified in the object? thanks in advance

nemtsov commented 8 years ago

@rbaumier can you please share your way of configuring this package with the new version logentries? (I'm asking you since you submitted the #1. I stopped using logentries and am happy to give you owner permissions if you're interested in maintaining it.)

boitewitte commented 8 years ago

You can easily fix this by creating your own mapping upon instantiation:

{
  levels: ['trace', 'debug', 'info', 'warn', 'error', 'fatal']
}

But because this is a bunyan based package, I think this should be standardised within the code. I've done this in the above mentioned commit (of a fork of this package), but I also made some adjustments in style (standard is now applied), so you could also easily copy in the above array and fix it that way

mariosvlad commented 8 years ago

@boitewitte 's suggestion along with removing type: 'raw' fixed my issue, so my code now looks like this:

var log = bunyan.createLogger({
  name: "beta",
  streams: [{
    levels: ['trace', 'debug', 'info', 'warn', 'error', 'fatal'],
    stream: bunyanLogentries.createStream({token: token})
  }],
  serializers: { 
    req: bunyan.stdSerializers.req,
    res: bunyan.stdSerializers.res,
    err: bunyan.stdSerializers.err
  }
});

var my_logger = log.child({type: 'myCustomLogger'});
my_logger.error('error!!!');
my_logger.info('some info log');