0.4.61 • Published 9 years ago

ez-log v0.4.61

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

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);

normal output

And collections will receive auto-indenting.

ezLog.warn([1,2,3]);
ezLog.warn({a:'b'});

advance output

Compile print

If the second parameter is given, logger can be a template compiler.

ezLog.info('THIS - IS - {name}', { name: 'SPARTA' });

compile output

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] }]]);

magical output

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

0.4.61

9 years ago

0.4.6

9 years ago

0.4.5

9 years ago

0.4.44

9 years ago

0.4.4

9 years ago