Skip to content

Commit 4a8da6d

Browse files
committed
Merge pull request #823 from fintura/debug
Refactor debug mode not to break old code and to work with NODE_DEBUG too
2 parents 4f79370 + 159bc80 commit 4a8da6d

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

index.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,13 @@ var net = require("net"),
1414
connection_id = 0,
1515
default_port = 6379,
1616
default_host = "127.0.0.1",
17-
debug;
18-
19-
/* istanbul ignore next */
20-
if (util.debuglog) {
21-
debug = util.debuglog('redis');
22-
} else if (/\bredis\b/i.test(process.env.NODE_DEBUG)) {
23-
debug = console.error;
24-
} else {
25-
debug = function() {};
26-
}
17+
debug = function(msg) {
18+
if (exports.debug_mode) {
19+
console.error(msg);
20+
}
21+
};
22+
23+
exports.debug_mode = /\bredis\b/i.test(process.env.NODE_DEBUG);
2724

2825
// hiredis might not be installed
2926
try {

0 commit comments

Comments
 (0)