JetLog
Streamed logger with multiple simltaneous output options.
The intention of this module is to allow pushing the log data to an API, some file and still be able to see the data in stdout.
Streams are based on scramjet
so you can use any transforms you like on your streams.
Default output
No colors, no fancy line drawing, nothing yet really - just a simple and parsable log output...
2018-06-29T15:07:37.339Z jetlog [info] defaultOutput(simple.js:52) Message1
2018-06-29T15:07:37.339Z jetlog [log] defaultOutput(simple.js:53) Message2
2018-06-29T15:07:37.339Z jetlog [error] defaultOutput(simple.js:54) Message3!
Usage
Simple version:
const logger = require('jetlog');
jetlog.log("Some message", {some_extra: data});
More complex version:
const {JetLog, Entry} = require('jetlog');
const logger = new JetLog({})
.catch(e => new Entry("Invalid log entry", e));
logger
.use("my-decorator-module")
.toJSONStream()
.tee(fs.createWriteStream("/var/log/myapp.log"))
logger
.filter(({level}) => level >= 3)
.stringify(myParser)
.pipe(process.stdout);
logger
.level("warn")
.use("my-reporter")
.pipe(process.stderr);
Environment control
Jetlog's default logger (the one exposed as module.exports
) behavior can be changed using the following environment variables:
JETLOG_REPORTER
- choose reporter module "./lib/entry-reporter"
by default.JETLOG
- boolean - set to "0"
to disable stdout.JETLOG_FILTER
- only log if Entry matches any of the words (space separated).
API
module.exports : JetLog
- the default export is a JetLog instance piped to stdout
using the standard log reporter.module.exports.getLog(name, pipeToOutput, reporter, filterArray)
- a facilitation method for creating loggersmodule.exports.JetLog
- the main logger class is exported
JetLog class
JetLog class implements the following methods:
Logging methods are as follows in the following order:
JetLog Entries
Each log message is turned to a stream object.
Props:
See more about Entry here
License
JetLog is MIT licensed.