Skip to content

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

@a3957273

Description

@a3957273

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions