electrum-trace
v1.1.2
Published
Electrum Trace provides a logging abstraction.
Downloads
425
Keywords
Readme
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 toconsole
too.
The user of Trace
can reconfigure the tracing:
intercept(name, func)
→ intercepts the named call and callsfunc
before calling the default. Multiple calls tointercept
can 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');