dougwilson / nodejs-depd

Deprecate all the things
MIT License
325 stars 87 forks source link

Ability to intercept deprecation warnings #4

Closed dougwilson closed 10 years ago

dougwilson commented 10 years ago

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.