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) => {
70
70
});
71
71
```
72
72
73
- ## ` util.debuglog(section) `
73
+ ## ` util.debuglog(section[, callback] ) `
74
74
<!-- YAML
75
75
added: v0.11.3
76
76
-->
77
77
78
78
* ` section ` {string} A string identifying the portion of the application for
79
79
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.
80
82
* Returns: {Function} The logging function
81
83
82
84
The ` 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]
121
123
Multiple comma-separated ` section ` names may be specified in the ` NODE_DEBUG `
122
124
environment variable: ` NODE_DEBUG=fs,net,tls ` .
123
125
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
+
124
139
## ` util.deprecate(fn, msg[, code]) `
125
140
<!-- YAML
126
141
added: v0.8.0
You can’t perform that action at this time.
0 commit comments