Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added command_logging option

  • Loading branch information...
commit 297ddf9e8777dcba9f4e6efff09123739da95e2e 1 parent e6449a7
@carlos8f authored
View
5 README.md
@@ -115,7 +115,6 @@ To see what's under the hood, try setting `redis.debug_mode = true`, and you can
see the failover process in detail:
```
-[19:27:58](#1) info: set on 127.0.0.1:6380 (master default)
[19:27:58](#1) warning: MASTER is down! (127.0.0.1:6380)
[19:27:58](#1) info: reorientating (node down) in 2000ms
Redis connection gone from end event.
@@ -131,9 +130,11 @@ Redis connection gone from end event.
[19:28:00](#1) info: renegotating subSlave away from master
[19:28:00](#1) info: subSlave is now 127.0.0.1:6382
[19:28:00](#1) info: ready, using 127.0.0.1:6381 as master
-[19:28:00](#1) info: set on 127.0.0.1:6381 (master default)
```
+To get info on which commands are executed on which servers, try setting
+`redis.command_logging = true`.
+
Running tests
=============
View
13 index.js
@@ -19,6 +19,7 @@ function createClient(nodes, options, etc) {
}
exports.createClient = createClient;
exports.debug_mode = false;
+exports.command_logging = false;
exports.print = redis.print;
function RedisHAClient(nodeList, options) {
@@ -165,7 +166,9 @@ commands.forEach(function(k) {
}
}
}
- self.log(k + ' on ' + this.subSlave);
+ if (exports.command_logging) {
+ self.log(k + ' on ' + this.subSlave);
+ }
return callCommand(this.subSlave.subClient, k, args);
case 'select':
// Need to execute on all nodes.
@@ -198,7 +201,9 @@ commands.forEach(function(k) {
var client, node;
if (this.options.auto_slaveok || this.slaveOk(k)) {
if (node = this.randomSlave()) {
- self.log(k + ' on ' + node);
+ if (exports.command_logging) {
+ self.log(k + ' on ' + node);
+ }
client = node.client;
}
}
@@ -208,7 +213,9 @@ commands.forEach(function(k) {
function callCommand(client, command, args) {
self._slaveOk = false;
if (!client) {
- self.log(command + ' on ' + self.master + ' (master default)');
+ if (exports.command_logging) {
+ self.log(command + ' on ' + self.master + ' (master default)');
+ }
client = self.master.client;
}
client[command].apply(client, args);
View
1  test/basic.js
@@ -2,6 +2,7 @@ var redis = require('../')
, uuid = require('../lib/uuid')
;
+redis.debug_mode = true;
var client = redis.createClient([6380, 6381, 6382]);
var cmd_per_sec = 0;
View
1  test/pubsub-oneclient.js
@@ -2,6 +2,7 @@ var redis = require('../')
, uuid = require('../lib/uuid')
;
+redis.debug_mode = true;
var nodes = [6380, 6381, 6382];
var client = redis.createClient(nodes);
View
1  test/pubsub.js
@@ -2,6 +2,7 @@ var redis = require('../')
, uuid = require('../lib/uuid')
;
+redis.debug_mode = true;
var nodes = [6380, 6381, 6382];
var client = redis.createClient(nodes);
var subClient = redis.createClient(nodes);
Please sign in to comment.
Something went wrong with that request. Please try again.