0.0.3 • Published 10 years ago
@iondrive/logger v0.0.3
@iondrive/logger
A 12-factor logging module for Node.js/io.js.
Principles
- Log to
stdout. The environment should manage how logs are routed and stored. - Log as JSON, allowing machines to read the log output.
Install
npm install @iondrive/loggerUsage
Logging level
The logging level can be set with the environment variable NODE_LOG_LEVEL or LOG_LEVEL. The value can be one of trace, debug, info, warn, error or fatal. The default level is info.
Example
var log = require('@iondrive/logger');
log.info('hello');
// The following will log the error fields and stack trace
log.info(err);
log.info(err, 'Something broke');Formatting
All logger methods use util.format and thus can use placeholder formatting.
log.debug('hello from %s', 'iondrive'); // 'hello from iondrive'