logzoo

0.0.2 • Public • Published

logzoo

Simple logger zoo.

It generates different loggers that all use console.log() to output messages, however each logger corresponds to some named part of your application (e.g. 'HTTP', 'Storage', 'Model') and have the same set of levels (e.g 'error', 'warn', 'info', 'debug').

Trivial usage example

const log = require('logzoo').get();
 
// by default log has .error(), .warn(), .info(), and .debug() methods
log.error('an error message (%d)', 123);
// same as console.log('[error] an error message (%d)', 123);

Example

// this is app.js
const logzoo = require('logzoo')(
  'CORE, HTTP, STORAGE, Model',
  // these are default levels, right now the list is ignored!
  'error, warn, info, debug'
);
 
logzoo.setLogLevel('warn'); // no info and debug
 
const log = logzoo.get('core');
 
log.info('logzoo looks fine: %j', logzoo); // skipped since log level
log.warn('Some useless warning'); // console.log('CORE [warn] Some useless warning');
// this is http.js
const log = require('logzoo').get('http');
 
log.error('connection is not established!');// console.log('HTTP [error] connection is not established');

Readme

Keywords

none

Package Sidebar

Install

npm i logzoo

Weekly Downloads

5

Version

0.0.2

License

MIT

Last publish

Collaborators

  • tutukin