ez-log
A tiny simple logger for the lazys
Last updated 5 years ago by gordomium.zhang .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ez-log 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.4.61                                ...           latest (5 years ago)

5 Versions

  • 0.4.61                                ...           5 years ago
  • 0.4.6                                ...           5 years ago
  • 0.4.5                                ...           5 years ago
  • 0.4.44                                ...           5 years ago
  • 0.4.4                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (5)
Dev Dependencies (0)
None
Dependents (2)

Copyright 2014 - 2016 © taobao.org |