File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -70,13 +70,15 @@ callbackFunction((err, ret) => {
7070});
7171```
7272
73- ## ` util.debuglog(section) `
73+ ## ` util.debuglog(section[, callback] ) `
7474<!-- YAML
7575added: v0.11.3
7676-->
7777
7878* ` section ` {string} A string identifying the portion of the application for
7979 which the ` debuglog ` function is being created.
80+ * ` callback ` {Function} A callback invoked the first time the logging function
81+ is called with a function argument that is a more optimized logging function.
8082* Returns: {Function} The logging function
8183
8284The ` util.debuglog() ` method is used to create a function that conditionally
@@ -121,6 +123,19 @@ FOO-BAR 3257: hi there, it's foo-bar [2333]
121123Multiple comma-separated ` section ` names may be specified in the ` NODE_DEBUG `
122124environment variable: ` NODE_DEBUG=fs,net,tls ` .
123125
126+ The optional ` callback ` argument can be used to replace the logging function
127+ with a different function that doesn't have any initialization or
128+ unnecessary wrapping.
129+
130+ ``` js
131+ const util = require (' util' );
132+ let debuglog = util .debuglog (' internals' , (debug ) => {
133+ // Replace with a logging function that optimizes out
134+ // testing if the section is enabled
135+ debuglog = debug;
136+ });
137+ ```
138+
124139## ` util.deprecate(fn, msg[, code]) `
125140<!-- YAML
126141added: v0.8.0
You can’t perform that action at this time.
0 commit comments