dougwilson/nodejs-depd

Ability to intercept deprecation warnings

Closed this issue · 0 comments

Since the deprecation warnings are simply written to stderr, they are not easy to instrument or intercept. An example would be a large system that wants to write all events to an external service but would like more structured messages than just stderr log lines. Possible interface:

process.on('deprecation', function ondeprecation(err) {
  // err is an Error object representing the deprecation
  // err.namespace
  // err.stack
  // err.message
  console.log(err.stack)
})

If there are any deprecation listeners attached to process, then nothing is written to stderr.