node-modules/zlogger

Name: zlogger

Owner: node_modules

Description: The last console logger

Created: 2016-11-25 18:17:08.0

Updated: 2017-05-26 03:31:56.0

Pushed: 2016-12-13 10:02:25.0

Homepage:

Size: 8

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

zlogger

NPM version build status Test coverage David deps Known Vulnerabilities npm download

The last console logger

Installation
install --save zlogger
Feature
Usage

zlogger is same as global console which has .log, .info, .warn, .error.

Every line will start with prefix that you customize.

t logger = new ConsoleLogger({
efix: '> ',

Specify stdout/stderr, default is process.stdout/process.stderr, you can use fs if you want to print to file.

t logger = new ConsoleLogger({
dout: fs.createWriteStream('stdout.log'),
derr: fs.createWriteStream('stderr.log'),

er.info('info');
er.error('error');

at stdout.log
at stderr.log

You can create a child logger, the first argument can be a ChildProcess or writable stream. If you give a prefix, it will print after prefix defined by the parent logger.

t cp = require('child_process');
t logger = new ConsoleLogger({
efix: 'prefix > ',

er.info('see directory')

t ls = cp.spawn('ls', { cwd: __dirname });
er.child(ls, '> ');

15:03:46] prefix > see directory
15:03:46] prefix > > History.md
15:03:46] prefix > > README.md
15:03:46] prefix > > index.js
15:03:46] prefix > > node_modules
15:03:46] prefix > > package.json
15:03:46] prefix > > test

.child will return a new logger.

t logger = new ConsoleLogger({
efix: 'parent> ',

er.info('parent');

t child = logger.child('child> ');
d.info('child');

15:02:43] parent> parent
15:02:43] parent> child> child

It will print time before prefix, format is [HH:MM:SS], but you can disable it.

??
License

(The MIT License)


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.