0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/doc/api
James M Snell c6656db352 process: add 'warning' event and process.emitWarning()
In several places throughout the code we write directly to stderr
to report warnings (deprecation, possible eventemitter memory leak).
The current design of simply dumping the text to stderr is less
than ideal. This PR introduces a new "process warnings" mechanism
that emits 'warning' events on the global process object. These are
invoked with a `warning` argument whose value is an Error object.

By default, these warnings will be printed to stderr. This can be
suppressed using the `--no-warnings` and `--no-deprecation` command
line flags. For warnings, the 'warning' event will still be emitted
by the process, allowing applications to handle the warnings in custom
ways. The existing `--no-deprecation` flag will continue to supress
all deprecation output generated by the core lib.

The `--trace-warnings` command line flag will tell Node.js to print
the full stack trace of warnings as part of the default handling.

The existing `--no-deprecation`, `--throw-deprecation` and
`--trace-deprecation` flags continue to work as they currently do,
but the exact output of the warning message is modified to occur
on process.nextTick().

The stack trace for the warnings and deprecations preserve and point
to the correct call site.

A new `process.emitWarning()` API is provided to permit userland
to emit warnings and deprecations using the same consistent
mechanism.

Test cases and documentation are included.

PR-URL: https://github.com/nodejs/node/pull/4782
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Wyatt Preul <wpreul@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2016-03-24 13:19:11 -07:00
..
_toc.markdown doc: add a cli options doc page 2016-03-21 17:33:42 -04:00
addons.markdown doc: fix typo in api/addons 2016-03-14 08:48:08 -07:00
all.markdown deps: update v8 to 4.4.63.9 2015-08-04 11:56:14 -07:00
assert.markdown doc: mention prototype check in deepStrictEqual() 2016-02-23 09:17:11 -05:00
buffer.markdown buffer: add swap16() and swap32() methods 2016-03-23 08:52:44 -07:00
child_process.markdown doc: Add note about use of JSON.stringify() 2016-03-15 09:38:28 -07:00
cli.markdown process: add 'warning' event and process.emitWarning() 2016-03-24 13:19:11 -07:00
cluster.markdown doc: add missing property in cluster example 2016-02-27 14:04:51 +01:00
console.markdown console: check that stderr is writable 2016-03-15 19:10:55 -07:00
crypto.markdown crypto: fail early when loading crypto without openssl 2016-03-23 10:34:40 -07:00
debugger.markdown doc: replace function expressions with arrows 2016-01-27 23:00:20 +01:00
dgram.markdown doc: fix typo in api/dgram 2016-03-14 08:48:03 -07:00
dns.markdown doc: fix dns.resolveCname description typo 2016-03-10 02:16:36 +01:00
documentation.markdown doc: add info to docs on how to submit docs patch 2016-03-07 11:25:15 -08:00
domain.markdown doc: fix type references for link gen, link css 2016-02-09 13:12:21 +01:00
errors.markdown doc: fix markdown links 2016-03-10 14:09:26 +01:00
events.markdown doc: use consistent event name parameter 2016-03-24 15:26:37 +02:00
fs.markdown fs: add the fs.mkdtemp() function. 2016-03-20 11:49:02 +02:00
globals.markdown doc: proper markdown escaping -> \_\_, \*, \_ 2016-01-22 21:32:50 -08:00
http.markdown doc: fix markdown links 2016-03-10 14:09:26 +01:00
https.markdown doc: minor improvement to HTTPS doc 2016-02-01 09:14:42 -08:00
index.markdown Remove util.print from docs 2010-11-07 17:22:56 -08:00
modules.markdown doc: explain error message on missing main file 2016-03-21 14:59:13 -07:00
net.markdown net: emit host in lookup event 2016-03-18 11:04:02 -05:00
os.markdown doc: minor improvement in OS docs 2016-02-04 19:25:07 +01:00
path.markdown doc: explain path.format expected properties 2016-03-22 23:46:33 +02:00
process.markdown process: add 'warning' event and process.emitWarning() 2016-03-24 13:19:11 -07:00
punycode.markdown doc: fenced all code blocks, typo fixes 2016-01-21 20:55:09 +01:00
querystring.markdown doc: fix multiline return comments in querystring 2016-03-17 17:15:06 -03:00
readline.markdown doc: don't use "interface" as a variable name 2016-01-30 00:33:14 +01:00
repl.markdown repl: Assignment of _ allowed with warning 2016-03-18 21:03:40 +01:00
stream.markdown lib: reduce usage of self = this 2016-03-21 15:48:51 -07:00
string_decoder.markdown doc: fenced all code blocks, typo fixes 2016-01-21 20:55:09 +01:00
synopsis.markdown doc: harmonize $ node command line notation 2016-01-22 19:57:19 +01:00
timers.markdown doc: grammar, clarity and links in timers doc 2016-03-21 09:48:54 +02:00
tls.markdown doc: align doc/api/tls.markdown with style guide 2016-03-20 10:42:04 +02:00
tty.markdown doc: fenced all code blocks, typo fixes 2016-01-21 20:55:09 +01:00
url.markdown doc: fenced all code blocks, typo fixes 2016-01-21 20:55:09 +01:00
util.markdown doc: document deprecation of util._extend 2016-03-16 12:55:55 -07:00
v8.markdown doc: update V8 URL 2016-03-02 23:22:29 +01:00
vm.markdown vm: fix produceCachedData 2016-02-21 14:59:35 -05:00
zlib.markdown doc: clarify type of first argument in zlib 2016-03-15 12:09:38 -03:00