Skip to content

Instantly share code, notes, and snippets.

@bnoordhuis
Created January 3, 2012 14:38
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save bnoordhuis/1555127 to your computer and use it in GitHub Desktop.
Save bnoordhuis/1555127 to your computer and use it in GitHub Desktop.
Trace all events in a node.js application
(function() {
var EventEmitter = require('events').EventEmitter;
var inspect = require('util').inspect;
var emit_ = EventEmitter.prototype.emit;
EventEmitter.prototype.emit = function(name) {
var args = Array.prototype.slice.call(arguments);
if (!(this === process.stderr && name === 'drain')) {
console.error("Event '%s', arguments: %s",
name, inspect(args.slice(1), false, 1));
}
return emit_.apply(this, args);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment