ez-log

0.4.61 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i ez-log

Weekly Downloads

1

Version

0.4.61

License

MIT

Last publish

Collaborators

  • gordomium.zhang