bunyanizer
v0.1.2
Published
bunyan child logger
Downloads
1
Readme
bunyanizer
Bunyanizer is basically a bunyan constructor with the reqSerializer and an added method bunyanizer.jsonLog(message)
.
.jsonify(obj/string)
This function is a wrapper to bunyan.info() but it checks first if its JSON or a string and call the bunyan.info()
.
Its a simple function that wraps bunyan.info to make sure its JSON.
TjsonLog() just checks if the string can be parsed by JSON then log it as is. Else if it's not parseable, it turns it into an object by wrapping it up like this: {msg: '<your-log-here>' }
.
If its neither JSON, not a string, it will call bunyan's default log.info("").
"sensible" defaults and more..
see examples/simpleObjectLog.js
for more details on how to use fluentd for example. You just pass in a stream name
Basically, just need to call the .construct({name:<your-app-name>})
method and voila a new Bunyan object with a simple request 'reqSerializer' function is created.
re:Streams
Btw you can pass in a stream-name if you want,then modify bunyanizer's construct() mechanism to instantiate an appropriate stream when you call bunyanizer.
In index.js
you can check what to do there.
An example in my index.js is instantiating the fluentLogger. You need to npm install
fluent-logger-node btw for that to work.
License
ISC.