Electrum Trace
The Trace
class provides static tracing functions:
log()
, info()
, warn()
and error()
which are by default forwarding
to console
.dir()
which is by default forwarding to console
too.
The user of Trace
can reconfigure the tracing:
intercept(name, func)
→ intercepts the named call and calls func
before calling the default. Multiple calls to intercept
can be donc with
the same name
. The calls will be dispatched first to the last added funciton.reset()
→ resets to the default forwarding.clear()
→ clears all forwarding, making calls to log()
, 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');
Trace.intercept ('log', x => { });
Trace.log ('Hello, world');
Trace.reset ();
Trace.log ('Hello, world');
Trace.clear ('log');
Trace.log ('Hello, world');