为了使 Node.js 中的输出变得丰富多彩,我使用 chalk 。我想知道是否有任何方法可以对 console.trace() 输出进行着色?
最佳答案
在 Node.js 中,方法 console.trace
编译数据,然后将其转发到 console.error
。
下面是使用模块 manakin 的示例:
require('manakin').global;
console.trace(); // prints the trace using red
由于库默认为方法 console.error
分配红色,因此跟踪也将显示为红色,但您可以更改它:
var con = require('manakin').global;
con.error.color = 35; // use magenta for errors;
console.trace(); // prints the trace using magenta
关于node.js - 如何在node.js中为console.trace着色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39446613/