Skip to content

Commit

Permalink
feat: include source and database in monitor events (#308)
Browse files Browse the repository at this point in the history
* Include missing data in monitor events

* Revert generated docs, update comments
  • Loading branch information
9point6 authored and luin committed May 19, 2016
1 parent 6ee56b2 commit a0d5b25
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
});
});
```
Expand Down
4 changes: 2 additions & 2 deletions lib/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
* });
* });
Expand Down
3 changes: 2 additions & 1 deletion lib/redis/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit a0d5b25

Please sign in to comment.