trentm / node-bunyan

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

How do I specify the parent caller as the path to log out when `src` is enabled? #684

Closed a3957273 closed 2 years ago

a3957273 commented 2 years ago

We use a helper function to log messages to both our server log, as well as a log that clients can see. It's essentially:

function our_log(data: any, message: string) {
  // log using bunyan
  log.info({ requestId, ...data }, message)

  // log to client
  database.append_log_to_client(message)
}

This works well, but breaks when we set src: true in our Bunyan configuration. Suddenly, all log lines think they're coming from our_log, instead of the callee function. Is there a way to tell Bunyan to log the src as being x stack frames higher up the call stack?

a3957273 commented 2 years ago

Closing as dupe of #634