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
Size: 8
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
The last console logger
install --save zlogger
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.
.log
and .info
will pipe to it?default is process.stdout.warn
and .error
will pipe to it?default is process.stderrprefix
, if it's a function, it will be called every line print.(The MIT License)