Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to color console.trace in node.js?

For making output colorful in node.js I am using chalk. I wonder, if there are any ways to color console.trace() output?

like image 586
James Akwuh Avatar asked Feb 18 '26 19:02

James Akwuh


1 Answers

In Node.js, method console.trace compiles the data and then forwards it into console.error.

Below is an example of using module manakin:

require('manakin').global;    
console.trace(); // prints the trace using red

Since the library assigns red color by default to method console.error, the trace will also appear red, though you can change it:

var con = require('manakin').global;
con.error.color = 35; // use magenta for errors;
console.trace(); // prints the trace using magenta
like image 137
vitaly-t Avatar answered Feb 20 '26 08:02

vitaly-t



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!