bendataclear
bendataclear

Reputation: 3850

Express.js debugging info missing timing

I have an application running inside a docker container, using express.js 4.17.1.

I am trying to debug some performance issues and have enabled the Express debugging using the DEBUG=express:* env setting, this is working and giving me output as below:

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"

However in all the examples, the output includes the critical timing information:

  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

How can I enable this timing information on the debug output?

Upvotes: 0

Views: 62

Answers (1)

RWD
RWD

Reputation: 1326

This appears to be related to the different behaviour of the debug module in TTY vs non-TTY environments.

In a Docker container, colours are disabled by default, and with that the timing information appears to be omitted.

Try running the container with the additional env var DEBUG_COLORS=1.

Upvotes: 1

Related Questions