[英]how do I hide debug messages in third party node.js modules?
I'm using the nodemailer
npm module, which references the mailcomposer
npm module, which in turn references the mime
npm module. 我正在使用
nodemailer
npm模块,该模块引用了mailcomposer
npm模块,而后者又引用了mime
npm模块。 The mime module outputs a bunch of ugly, spammy debug messages if process.env.DEBUG
is true. 如果
process.env.DEBUG
为true,则mime模块将输出一堆难看的垃圾邮件调试消息。
Yes, I want debug messages, but only for MY code. 是的,我需要调试消息,但仅适用于我的代码。 How can I stop the mime module from outputting its own debug messages?
如何停止mime模块输出自己的调试消息?
I've tried setting process.env.DEBUG
(which the mime module looks at) to false
right before requiring the nodemailer
module, but it doesn't seem to affect the state of the mime module. 我已经尝试在需要
nodemailer
模块之前将process.env.DEBUG
(mime模块查看)设置为false
,但是它似乎并不影响mime模块的状态。
Have you tried to overwrite the process.stdout.write function? 您是否尝试覆盖process.stdout.write函数?
Something like this: 像这样:
var log = process.stdout.write;
process.stdout.write = function (){};
Then, when you need to output something: 然后,当您需要输出一些内容时:
log ("my message to console");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.