nemtsov / node-bunyan-logentries

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

Using levels : info and error #7

Open pputhran opened 8 years ago

pputhran commented 8 years ago

Hello,

Trying to understanding how to use both "info" and "errors". If I set level => streams: [{level: 'info', I am not able to use logger.error function. Can you please how to log both info and errors

markstos commented 8 years ago

@pputhran Please provide example code.

bethnull commented 8 years ago

Hi,

I'm having issues trying to log with the error level. Here is the code (first example in the repo readme):

var bunyan = require('bunyan');
var bunyanLogentries = require('bunyan-logentries');

var logger = bunyan.createLogger({
  name: "test",
  streams: [{
    level: 'error',
    stream: bunyanLogentries.createStream({ token: "xxx" }),
    type: 'raw'
  }]
});

logger.info("info test");
logger.error("error test");

The first logger.info works flawlessly however the second, the logger.error throws the following exception:

events.js:154
      throw er; // Unhandled 'error' event
      ^

Error: The log method was called with the unknown level "undefined".

I've tried to spot where it fails and I can see in the debugger (in le_node/lib/node_modules/logger.js) that in line 193 (it seems to be a babelized file):

logger.js:193 [ lvl, lvlName ] = this[$toLevel](lvl)

for the logger.info it returns [1, "info"], but for the logger.error it returns [undefined, undefined]. I can't say anymore as for some reason I can't watch $toLevel as the debugger says that is undefined.

I hope to be helpful, if you need that I try something please don't hesitate to ask.

Thanks in advance.

nemtsov commented 8 years ago

@bethnull can you please check if https://github.com/nemtsov/node-bunyan-logentries/pull/9 fixes your issue?

bethnull commented 8 years ago

Hi!

Yes, it seems to work ;)

Thanks for your support.

cbrwizard commented 7 years ago

Having the same issue.