node-logger-json-stderr
Log JSON to stderr.
Currently, it uses Bunyan to do the work.
What it does
- log data is only written to stderr
- log data is written in JSON format
- all newline characters (\n) in the log data are escaped, such that each log entry has only one unescaped newline at the end of the line -- this makes it easy to split your log files on newlines in order to get each JSON string.
- objects can be logged as well
- enables two 'styles' of logger: message first then objects (like Winston), or object first, then message (like Bunyan)
Installation
npm install -S logger-json-stderr // install and add as a dependency to your package.json
Usage
Basic (verbose) usage, using the default (Winston) style (message first, then object):
var options = name: 'name for the logger' loggingLevel: 'error' // name defaults to 'Logger', and loggingLevel defaults to 'info'var loggerFn = ;var logger = logger;
A shorter version is
var logger = name: "awesome app" logger
Objects can be logged as well
logger
Using the Bunyan style (object first, then message)
var logger = name: "awesome app" style: 'bunyan' logger
Suppressing logging
logger;loggerloggerloggerlogger
Testing
make test
Change History
1.0.0
- Replace Winston with Bunyan.
- Returns a function instead of an object.
- Must call the function with an object like { name: 'the name for the logger' }.
0.1.0
- Use Winston.
License
MIT