diff --git a/README.md b/README.md index 7e722cb1..eee8d7f5 100644 --- a/README.md +++ b/README.md @@ -445,7 +445,7 @@ Here is a simple example: ```javascript redis.monitor(function (err, monitor) { - monitor.on('monitor', function (time, args) { + monitor.on('monitor', function (time, args, source, database) { }); }); ``` diff --git a/lib/redis.js b/lib/redis.js index d6246ab4..01aeb616 100644 --- a/lib/redis.js +++ b/lib/redis.js @@ -462,14 +462,14 @@ Redis.prototype.silentEmit = function (eventName) { * var redis = new Redis(); * redis.monitor(function (err, monitor) { * // Entering monitoring mode. - * monitor.on('monitor', function (time, args) { + * monitor.on('monitor', function (time, args, source, database) { * console.log(time + ": " + util.inspect(args)); * }); * }); * * // supports promise as well as other commands * redis.monitor().then(function (monitor) { - * monitor.on('monitor', function (time, args) { + * monitor.on('monitor', function (time, args, source, database) { * console.log(time + ": " + util.inspect(args)); * }); * }); diff --git a/lib/redis/parser.js b/lib/redis/parser.js index 2068c42f..15c4dd09 100644 --- a/lib/redis/parser.js +++ b/lib/redis/parser.js @@ -97,7 +97,8 @@ exports.returnReply = function (reply) { var args = replyStr.slice(argindex + 1, -1).split('" "').map(function (elem) { return elem.replace(/\\"/g, '"'); }); - this.emit('monitor', timestamp, args); + var dbAndSource = replyStr.slice(len + 2, argindex - 2).split(' '); + this.emit('monitor', timestamp, args, dbAndSource[1], dbAndSource[0]); return; } }