nemtsov / node-bunyan-logentries

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

also check if the level was passed as a string #2

Closed troyastorino closed 9 years ago

troyastorino commented 9 years ago

I don't know if this is generally a problem, or was just a problem with our use case (we override our web framework's logger to use bunyan). We ran into a situation where the log level was passed as a string instead of being passed as a number.

So, don't know if you'd want to merge this in, but putting it out there just in case.

nemtsov commented 9 years ago

Can you tell me a bit more your bunyan configuration that caused the levels to be strings? Internally bunyan uses numbers, so I'm curious about this.

troyastorino commented 9 years ago

We use Geddy as our webserver (which has its own builtin logging), but we use bunyan for our logging. So, we just monkey patch Geddy on initialization, setting geddy.log = bunyanLogger, and bunyanLogger.access = bunyanLogger.info (since Geddy's logger also uses an access log level).

What's weird is that this setup didn't have any problem when with node-bunyan-logentries when I was just running a development server, but failed when we ran our testsuite. I honestly didn't dig into the issue of what caused the level to be strings...just realized I could fix it for our case pretty easily.

nemtsov commented 9 years ago

I see. In that case I'm not sure this level mapping should be done by this library. It sounds like you need an adapter (your logging library levels to bunyan levels) that you can put between this lib and your logger.