nodlog
v1.4.1
Published
Log wrapper for node
Downloads
13
Readme
NODLOG
Node wrapper for logging to:
- console
- logmatic
It has several logging levels:
trace
[5]: debug information to have a basic stack tracedebug
[4]: information used for debuginfo
[3]: notification of a normal actionwarn
[2]: incorrect behavior but the application can continueerror
[1]: exceptionsfatal
[0]: 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 nodlog
How 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 }