loge

Singleton logging with levels

loge

My very own Node.js logging library! Crazy that no one else thought of this first!

npm install loge --save

Or in your package.json:

{
  "dependencies": {
    "loge": "*",
    ...
  },
  ...
}
import {logger} from 'loge';
 
logger.level = 'error';
logger.warning('You should probably get a doctor to look at that.');
// (nothing) 
logger.critical('OMG your face I you what no really just does it hurt?');
// [critical] OMG your face I you what no really just does it hurt? 

Formatting:

Loge's calls Node's util.format (but only when the called method's level is greater than equal to the logger's level), so the following interpolation variables are available:

  • %s - String
  • %d - Number (integer / float)
  • %j - JSON (JSON.stringify() called without replacer or indentation

Use %% for an escaped percent sign

import {Level} from 'loge';
 
console.log(Level.notset);
// 0 
console.log(Level.debug);
// 10 
console.log(Level.info);
// 20 
console.log(Level.warning);
// 30 
console.log(Level.error);
// 40 
console.log(Level.critical);
// 50 

Copyright © 2014-2015 Christopher Brown. MIT Licensed.