1.4.1 • Published 9 years ago
nodlog v1.4.1
NODLOG
Node wrapper for logging to:
- console
- logmatic
It has several logging levels:
trace5: debug information to have a basic stack tracedebug4: information used for debuginfo3: notification of a normal actionwarn2: incorrect behavior but the application can continueerror1: exceptionsfatal0: problem that prevents the service from running correctly
It can be used just like console.log() with multiple parameters and objects.
Installation
npm install --save nodlogHow to use
var log = require('nodlog')({
console: {
level: 5,
timestamp: true
},
logmatic: {
key: 'API_KEY',
enabled: true,
context: {
app: 'myApp',
instance: 'dev-1',
env: 'development'
},
level: 3,
label: 'dev-1'
},
});
log.info('Informative note');
log.warn('The object', myObject, 'is invalid');Timers
Named timers can be used to check how long a function call takes:
log.startTimer('test');
setTimeout(function () {
log.stopTimer('test');
}, 300);Will log as trace if options.timers is true :
Timer "test" took 301 ms, { timer: "test", ms: 301 }