0.0.1010 • Published 7 years ago

log-prepend v0.0.1010

Weekly downloads
5
License
ISC
Repository
github
Last release
7 years ago

log-prepend

Create a console.log or console.error like function, but prepend a string to each line.

API

const {lp} = require('log-prepend');
const log = lp(' [suman] ', process.stdout);
const logerr = lp(' [suman error] ', process.stderr);

log('a','b','c');
log('log1', 'log2\n3',4,5 + '\n55');

To use colors in the prepending string, simply do:

const chalk = require('chalk');
const log = lp(chalk.blue(' [suman] '), process.stdout);
const logerr = lp(chalk.red(' [suman error] '), process.stderr);

Extra

This works as a rudimentary solution:

const log = console.log.bind(console, ' [suman] ');

But the problem with the above log function is that it won't handle new lines chars that are passed to it.

0.0.1010

7 years ago

0.0.1009

7 years ago

0.0.1008

8 years ago

0.0.1007

8 years ago

0.0.1006

8 years ago

0.0.1005

8 years ago

0.0.1003

8 years ago

0.0.1001

8 years ago