Singleton logging with levels
My very own Node.js logging library! Crazy that no one else thought of this first!
npm install --save loge
Logger instance defaults to writing to
import logger Level from 'loge';loggerlevel = Level.error;loggerwarning'You should probably get a doctor to look at that.';// (nothing)loggercritical'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?
Alternatively, write to
import Logger Level from 'loge';const logger = processstdout Level.info;
Loge's calls Node's
util.format (but only when the called method's level is greater than or equal to the logger's
level), so the following interpolation variables are available:
%d- Number (integer / float)
%j- JSON (
JSON.stringify()called without replacer or indentation
%% for an escaped percent sign
import Level from 'loge';console.logLevelnotset;// 0console.logLeveldebug;// 10console.logLevel.info;// 20console.logLevelwarning;// 30console.logLevel.error;// 40console.logLevelcritical;// 50
Copyright © 2014-2015 Christopher Brown. MIT Licensed.