README
ez-log
A tiny simple logger.
Install
npm install ez-log
Usage
Normal print
It has 4 standard output methods: log
, info
, warn
, error
var ezLog = require('ez-log')(module);
ezLog.log(1);
ezLog.log(true);
ezLog.log(null);
ezLog.log('string');
ezLog.error(function(){});
ezLog.error(/\d+/g);
And collections will receive auto-indenting.
ezLog.warn([1,2,3]);
ezLog.warn({a:'b'});
Compile print
If the second parameter is given, logger can be a template compiler.
ezLog.info('THIS - IS - {name}', { name: 'SPARTA' });
Even can use a cool solution to resove multi-line template!
ezLog.info(function(){/*
this should be multi-lines
RegExp : {0.x}
Array : {0.inner}
Boolean : {1.1}
Function: {1.2}
Object : {1.3}
String : {1.4}
Number : {1.5.x[0]}
*/}, [{x: /x/i, inner: [2,3]}, [1,false, function(){}, { a:0, b: 1}, 'str', { x: [222] }]]);
Appoint worker
If you need, you can use the appointed work for log.
ezLog.file.info('I only write logs to file.');
ezLog.console.info('And i only echo logs to console.');
Config
If you wanna something different, try this:
var ezLog = require('ez-log')(module, config);
These are default config, you can override them in your config.
{
"multiLinePrefix" : " - ",
"indentNum" : 2,
"indent" : " ",
"lineBreak" : "\n",
"comma" : ",",
"colon" : ":",
"logDir" : ".",
"logFile" : "ez.log",
"logMax" : 128
}
Dependencies
see package.json