Chalk: Coloring stdout and stderr in node

Created on 3 Sep 2014  路  4Comments  路  Source: chalk/chalk

I guess this in not chalk fault, but I'm still puzzled.

I would like stderr in red fo a clear differentiation. However :

var chalk = require('chalk');

console.log('msg on stdout');         <-- black
console.error('msg on stderr');       <-- black

console.log(chalk.styles.blue.open);  <-- I expect to set stdout to blue (for test)

console.log('msg on stdout');         <-- blue
console.error('msg on stderr');       <-- blue, why ?

console.error(chalk.styles.red.open);  <-- I expect to set stderr to red

console.log('msg on stdout');         <-- red, why ?
console.error('msg on stderr');       <-- red

node.js console documentation explicitely states that log goes to stdout and error to stderr. So how comes colors are set for both outputs ?

All 4 comments

Use StackOverflow for support questions.

wow.

The reason that colors are set for both outputs is that you are rendering them in the same stream.

If you'd redirect stdout and stderr to different files the coloring of the individual streams would match your expectations.

@jbnicolai thanks. Got it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DawnImpulse picture DawnImpulse  路  7Comments

erquhart picture erquhart  路  6Comments

HillTravis picture HillTravis  路  8Comments

ORESoftware picture ORESoftware  路  6Comments

basickarl picture basickarl  路  3Comments