1.4.1 • Published 9 years ago

nodlog v1.4.1

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

NODLOG

Node wrapper for logging to:

It has several logging levels:

  • trace 5: debug information to have a basic stack trace
  • debug 4: information used for debug
  • info 3: notification of a normal action
  • warn 2: incorrect behavior but the application can continue
  • error 1: exceptions
  • fatal 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 }

1.4.1

9 years ago

1.4.0

9 years ago

1.3.1

9 years ago

1.3.0

9 years ago

1.2.0

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago