Have ideas to improve npm?Join in the discussion! »

logu

1.1.3 • Public • Published

logu

NPM version Build Status Dependency Status Coverage percentage

A javascript logging library based on wiston.

Installation

[sudo] npm install logu --save

Usage

logu supports host, id and label for log.

var logu = require('logu');
 
logu.cli('logu', {colorize: true, timestamp: 'short', showLevel: false, showLabel: true});
 
logu.log('info', 'Hello, this is a logging event with host', {'foo': 'bar'});
logu.log('info', 'action', 'Hello, this is a logging event with host', {'foo': 'bar'});
logu.log('info', 'build', 'Hello, this is a logging event with host', {'foo': 'bar', 'label': 'logu#*', arr: [1, 2]});
logu.info('say', 'hello', {'foo': 'bar'});

output:

[15:51:14.108] logu Hello, this is a logging event with host foo=bar
[15:51:14.112] logu            action Hello, this is a logging event with host foo=bar
[15:51:14.114] logu logu#*      build Hello, this is a logging event with host foo=bar, label=logu#*, arr=[1, 2]
[15:51:14.114] logu               say hello foo=bar

logu using one parameter for logging and logged events.

A sample log parameter of event logging:

{
  transport: {...},
  level: 'info',
  id: 'logu',
  message: 'Hello world!',
  meta: {foo: 'bar'}
}
 

A sample log parameter of event logged:

{
  transport: {...},
  level: 'info',
  id: 'logu',
  message: 'Hello world!',
  meta: {foo: 'bar'}
}

For example:

var logu = require('logu');
 
var logger = new (logu.Logger)({
  transports: [new (logu.transports.Console)()]
});
 
logger.once('logging', function (log) {
  console.log(log.transport);
  console.log(log.level);
  console.log(log.id);
  console.log(log.message);
  console.log(log.meta);
});
 
logger.once('logged', function (log) {
  console.log(log.level);
  console.log(log.id);
  console.log(log.message);
  console.log(log.meta);
});
 
 
logger.log('info', 'Hello world!');

License

MIT © taoyuan

Install

npm i logu

DownloadsWeekly Downloads

2

Version

1.1.3

License

MIT

Last publish

Collaborators

  • avatar
  • avatar