npm.io
2.0.0 • Published 9 years ago

global-console-prefix

Licence
ISC
Version
2.0.0
Deps
1
Vulns
0
Weekly
0

global-console-prefix

Build Status

Add a your own prefix to every single console message.

Usage

require("global-console-prefix")("[MONEY_APP]");

console.log("starting execution", {name: "crawler"});
console.info("starting execution", {name: "crawler"});
console.warn("starting execution", {name: "crawler"});
console.error("starting execution", {name: "crawler"});

//Output:
//[INFO][MONEY_APP] starting execution { name: 'crawler' }
//[INFO][MONEY_APP] starting execution { name: 'crawler' }
//[ERROR][MONEY_APP] starting execution { name: 'crawler' }
//[ERROR][MONEY_APP] starting execution { name: 'crawler' }

Remarks

Executes the default console methods when no prefix is specified.

Hides the log level when a second parameter is specified.

require("global-console-prefix")("[MONEY_APP]", true);

Keywords