Skip to content

Instantly share code, notes, and snippets.

@maravillas
Created October 22, 2011 18:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maravillas/1306352 to your computer and use it in GitHub Desktop.
Save maravillas/1306352 to your computer and use it in GitHub Desktop.
Trace method calls in console
interceptor = (klass) ->
for own key, value of klass
f = (k, v) ->
if typeof value == "function"
klass[k] = ->
console.log "Called #{k} from #{arguments.callee.caller.toString()}", arguments
v.apply(this, arguments)
f key, value
// interceptor(Foo.prototype)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment