javascript - 如何在 Node.js CLI 中禁用快速日志?

标签 javascript node.js debugging express

我是 node.js 新手,我正在尝试不再使用 console.log 来调试所有内容。我正在尝试使用

debug("test message")

而不是 console.log 来处理所有事情。

我安装了 debug npm 包,它指示我:

set DEBUG=* node server.js

但是,通过我的 express 包裹,我得到以下信息: code picture

蓝色的应用程序消息是与我唯一相关的消息,因为我尝试使用它而不是 console.log。我怎样才能摆脱这些 express 日志?您认为在某些时候它们会很重要吗?

最佳答案

你可以像这样使用它

dbg=debug('myserver:app')

并使用

输出消息

dbg('一条新消息')

也可以只输出您想要的消息

设置 DEBUG=myserver:app Node server.js

您还可以使用 - 排除或包含 myserver:app,express:*

使用 DEBUG 环境变量,您可以指定输出什么或不输出。更多信息https://www.npmjs.com/package/debug检查通配符和示例

关于javascript - 如何在 Node.js CLI 中禁用快速日志?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43385680/

相关文章:

javascript - 使用变量更改 Parse.com 查询

javascript - 使用数组显示 div 元素。 JavaScript

android-studio - Android工作室2.3 "Debug shows Connected and Disconnected lines but nothing in between"

c - 为什么 GDB 不显示导致段错误的函数地址

css - 在我的 Android 上调试 JQuery Mobile

javascript - 使用自定义局部变量从 javascript 渲染部分

javascript - 禁用一个事件并再次在 jQuery 中启用该事件

node.js - TS2403 : Subsequent variable declarations must have the same type. NPM 安装后

node.js - AWS CloudFormation 与 node.js 10.x 更新错误 "ZipFile can only be used when Runtime is set to <older node.js versions>"

javascript - 如何将回调作为变量传递给 puppeteer 中的 page.evaluate?