1.1.2 • Published 9 years ago
electrum-trace v1.1.2
Electrum Trace
The Trace class provides static tracing functions:
log(),info(),warn()anderror()which are by default forwarding toconsole.dir()which is by default forwarding toconsoletoo.
The user of Trace can reconfigure the tracing:
intercept(name, func)→ intercepts the named call and callsfuncbefore calling the default. Multiple calls tointerceptcan be donc with the samename. The calls will be dispatched first to the last added funciton.reset()→ resets to the default forwarding.clear()→ clears all forwarding, making calls tolog(), etc. equivalent to a no-op.clear(name)→ clears the named call; this replaces it with a no-op.clear(name1, name2, ...)→ clears multiple named calls.
How to use
Install with:
npm install electrum-trace
Import with:
import Trace from 'electrum-trace';and use like this:
Trace.log ('Hello, world');
// With interception
Trace.intercept ('log', x => { /* do something */ });
Trace.log ('Hello, world');
// Resetting interception
Trace.reset ();
Trace.log ('Hello, world');
// Suppressing messages
Trace.clear ('log');
Trace.log ('Hello, world');