1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

Merge pull request #823 from fintura/debug

Refactor debug mode not to break old code and to work with NODE_DEBUG too
This commit is contained in:
Ruben Bridgewater
2015-09-14 23:12:50 +02:00

View File

@@ -14,16 +14,13 @@ var net = require("net"),
connection_id = 0,
default_port = 6379,
default_host = "127.0.0.1",
debug;
debug = function(msg) {
if (exports.debug_mode) {
console.error(msg);
}
};
/* istanbul ignore next */
if (util.debuglog) {
debug = util.debuglog('redis');
} else if (/\bredis\b/i.test(process.env.NODE_DEBUG)) {
debug = console.error;
} else {
debug = function() {};
}
exports.debug_mode = /\bredis\b/i.test(process.env.NODE_DEBUG);
// hiredis might not be installed
try {