outrider
v2.0.0
Published
Package aware bunyan logger
Downloads
9
Readme
outrider
npm install outrider
outrider
logger is wrapper over bunyan to allow for easy log management inside of projects that consist of several in house libraries. This library makes sure that logs both end up in the right place and are delivered with necessary meta information.
Behavior
The goal of outrider
is to make logging with a large number of libraries that are being used in many different situations easy. Lets consider a project with the following dependency structure:
[email protected]
└─┬ [email protected]
└── [email protected]
With outrider
this project will log out to a file called foo.log
and will name space foo
, bar
, and baz
as [email protected]
, [email protected]
, and [email protected]
. There will also be a foo-error.log
file for error level messages. The log file will have all levels of messages (eg trace and higher) and anything info and higher will be logged to stdout.
Lets dig a little deeper, lets say that we now require foo
in a project called main
.
[email protected]
└─┬ [email protected]
├ [email protected]
└── ...
Now outrider
will log to main.log
with the same name spacing structure as before. Additionally, the log file will differentiate between [email protected]
and bar1.2.0
making it easy to see errant behavior between different versions of libraries.
By using outrider
it is easy to manage log files as your libraries and services grow in complexity.
Caution
outrider
will only log to a file if there is a main module for the process. If there is no main module (eg a package is included from the node REPL) then outrider
will only log to stdout.
Usage
outrider
is easy to set up:
// preferred way:
var log = require('outrider')(require('./package.json'));
// or
log = require('outrider')(name, version);
The log
variable is just an instance of the bunyan logger, so feel free to use it as you would any bunyan instance.
log.error();
log.warn();
log.info();
log.debug();
log.trace();
and now your logs are ready to go!
Configuration
outrider
will look for process.env.NODE_LOG_LOCATION
as a directory to write log files to. If this is not found then outrider
will default to ./
.
License
MIT