trentm / node-bunyan

a simple and fast JSON logging module for node.js services
Other
7.15k stars 513 forks source link

Bunyan fails to log 'src' when running in Node 20 versus Node 18 #714

Open a3957273 opened 10 months ago

a3957273 commented 10 months ago

Consider the following basic example of logging:

const bunyan = require("bunyan");

const log = bunyan.createLogger({
  name: "test",
  src: true,
});

log.info("test");

When run in Node 18, this produces the expected result:

ubuntu:~/git/bunyan-src-bug$ nvm use 18
Now using node v18.17.1 (npm v9.6.7)
ubuntu:~/git/bunyan-src-bug$ node --version
v18.17.1
ubuntu@ip-10-0-142-245:~/git/bunyan-src-bug$ node index.js
{"name":"test","hostname":"redacted","pid":116506,"level":30,"msg":"test","time":"2023-09-02T22:45:14.794Z","src":{"file":"/home/ubuntu/git/bunyan-src-bug/index.js","line":8},"v":0}

However, when run in Node 20 it no longer logs a valid source:

ubuntu:~/git/bunyan-src-bug$ nvm use 20
Now using node v20.5.1 (npm v9.8.0)
ubuntu:~/git/bunyan-src-bug$ node --version
v20.5.1
ubuntu:~/git/bunyan-src-bug$ node index.js 
{"name":"test","hostname":"redacted","pid":116714,"level":30,"msg":"test","time":"2023-09-02T22:45:30.143Z","src":{},"v":0}

Note the empty object.