Express.js debugging info missing timing



我有一个在docker容器内运行的应用程序,使用express.js 4.17.1。

我正在尝试调试一些性能问题,并使用DEBUG=express:*env设置启用了快速调试,这正在工作并给我如下输出:

Fri, 20 May 2022 13:24:09 GMT express:router use '/sitemap.txt' router
Fri, 20 May 2022 13:24:09 GMT express:router:layer new '/sitemap.txt'
Fri, 20 May 2022 13:24:09 GMT express:router use '/health' <anonymous>
...
Fri, 20 May 2022 13:24:09 GMT express:router use '/' <anonymous>
Fri, 20 May 2022 13:24:09 GMT express:router:layer new '/'
Fri, 20 May 2022 13:24:09 GMT express:application set "port" to 3000
...
Fri, 20 May 2022 13:25:17 GMT express:router dispatching GET /
Fri, 20 May 2022 13:25:17 GMT express:router query  : /
Fri, 20 May 2022 13:25:17 GMT express:router expressInit  : /
Fri, 20 May 2022 13:25:17 GMT express:router <anonymous>  : /
Fri, 20 May 2022 13:25:17 GMT express:router corsMiddleware  : /
...
Fri, 20 May 2022 13:25:17 GMT express:router router  : /
Fri, 20 May 2022 13:25:17 GMT express:router dispatching GET /
Fri, 20 May 2022 13:25:19 GMT express:view require "pug"
Fri, 20 May 2022 13:25:19 GMT express:view lookup "user/views/index.pug"
Fri, 20 May 2022 13:25:19 GMT express:view stat "/usr/app/pug/user/views/index.pug"
Fri, 20 May 2022 13:25:19 GMT express:view render "/usr/app/pug/user/views/index.pug"

然而,在所有的例子中,输出包括关键的定时信息:

express:router:route new / +0ms
express:router:layer new / +1ms
express:router:route get / +1ms
express:router:layer new / +0ms
express:router:route new / +1ms
express:router:layer new / +0ms
express:router:route get / +0ms
express:router:layer new / +0ms
express:application compile etag weak +1ms

如何在调试输出中启用此定时信息?

这似乎与调试模块在TTY和非TTY环境中的不同行为有关。

在Docker容器中,颜色在默认情况下是禁用的,因此时间信息似乎被省略了。

尝试使用附加的env varDEBUG_COLORS=1运行容器。

最新更新