Skip to content

Commit a0d5b25

Browse files
9point6luin
authored andcommitted
feat: include source and database in monitor events (#308)
* Include missing data in monitor events * Revert generated docs, update comments
1 parent 6ee56b2 commit a0d5b25

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ Here is a simple example:
445445

446446
```javascript
447447
redis.monitor(function (err, monitor) {
448-
monitor.on('monitor', function (time, args) {
448+
monitor.on('monitor', function (time, args, source, database) {
449449
});
450450
});
451451
```

lib/redis.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -462,14 +462,14 @@ Redis.prototype.silentEmit = function (eventName) {
462462
* var redis = new Redis();
463463
* redis.monitor(function (err, monitor) {
464464
* // Entering monitoring mode.
465-
* monitor.on('monitor', function (time, args) {
465+
* monitor.on('monitor', function (time, args, source, database) {
466466
* console.log(time + ": " + util.inspect(args));
467467
* });
468468
* });
469469
*
470470
* // supports promise as well as other commands
471471
* redis.monitor().then(function (monitor) {
472-
* monitor.on('monitor', function (time, args) {
472+
* monitor.on('monitor', function (time, args, source, database) {
473473
* console.log(time + ": " + util.inspect(args));
474474
* });
475475
* });

lib/redis/parser.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ exports.returnReply = function (reply) {
9797
var args = replyStr.slice(argindex + 1, -1).split('" "').map(function (elem) {
9898
return elem.replace(/\\"/g, '"');
9999
});
100-
this.emit('monitor', timestamp, args);
100+
var dbAndSource = replyStr.slice(len + 2, argindex - 2).split(' ');
101+
this.emit('monitor', timestamp, args, dbAndSource[1], dbAndSource[0]);
101102
return;
102103
}
103104
}

0 commit comments

Comments
 (0)