bithavoc / express-winston

express.js middleware for winstonjs
https://www.npmjs.com/package/express-winston
MIT License
797 stars 187 forks source link

Dynamic Log Levels #148

Closed CryptArchy closed 7 years ago

CryptArchy commented 7 years ago

Allow options.level to be a function for dynamic level setting.

A project I am working on requires the ability to dynamically set the log level based on deeper inspection of the request and response. I added unit tests based on the existing ones, and everything is passing. I tried to set sane defaults and checks that should preserve the existing behavior of the middleware with options.level set to a string or object. Only setting it to a function should behave differently, and that wasn't a valid option before.

rosston commented 7 years ago

@CryptArchy Sorry, only just now looking at this. Thanks for contributing (with tests)!

This all looks good to me. If you could just update the docs to mention the function usage of level, I'd be happy to merge it.

CryptArchy commented 7 years ago

@rosston Thanks for the review! I totally forgot about updating the documentation, but I got you covered now! Let me know if anything else needs to be adjusted.

rosston commented 7 years ago

Perfect. Your clarifying comment on statusLevels is a welcome bonus!

Released in 2.4.0. Thank you @CryptArchy!