Capture function calls and verbose stacktraces
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

CallTrace build status NPM version

Install with npm

$ npm install calltrace


var trace = require( 'calltrace' )

Calltrace will emit capture events, keep in mind to bind to them:

trace.on( 'capture', function( info ) {
  console.log( info )

Where the info will consist of an object with the following properties:

  • String name: name of captured function
  • Function fn: original (replaced) function,
  • Array argv: array of arguments passed into the function
  • Number time: milliseconds spent int the function
  • Object stack: verbose stack trace, if enabled

In case you want to monitor a globally available function:

trace.capture( 'require' ) // OR
trace.capture( 'require.resolve' )

Or, if you want to keep an eye on a method you only have access to in this scope:

trace.capture( someObject.subPath, 'methodName' )

Also, in case you want to turn off stack trace capturing, pass false as last parameter to capture():

trace.capture( 'fn', false ) // OR
trace.capture( bla, 'methodName', false )