Node-bunyan: Colors disappear from output when piping through bunyan

Created on 23 Dec 2014  路  4Comments  路  Source: trentm/node-bunyan

2014-12-23 16-51-42

#!/usr/bin/env node
console.log(require('chalk').red('foo'));

bunyan's colors are printed correctly

Most helpful comment

chalk uses https://github.com/sindresorhus/supports-color to enable or disable colors.
You can pass a --color flag to force colors https://github.com/sindresorhus/supports-color/blob/master/index.js#L11

Alternatively you can enable it directly via code

#!/usr/bin/env node
var chalk = require('chalk');
chalk.enabled = true;
console.log(chalk.red('foo'));

All 4 comments

chalk uses https://github.com/sindresorhus/supports-color to enable or disable colors.
You can pass a --color flag to force colors https://github.com/sindresorhus/supports-color/blob/master/index.js#L11

Alternatively you can enable it directly via code

#!/usr/bin/env node
var chalk = require('chalk');
chalk.enabled = true;
console.log(chalk.red('foo'));

So, iiuc, not a bunyan issue.

For those using colors.js instead of chalk, see this https://github.com/Marak/colors.js/issues/125.

I recommend having it in readme.

Was this page helpful?
0 / 5 - 0 ratings