@ledgerhq/logs v6.12.0
@ledgerhq/logs
Utility library that is used by all Ledger libraries to dispatch logs so we can deal with them in a unified way.
API
Table of Contents
Log
A Log object
type
A namespaced identifier of the log (not a level like "debug", "error" but more like "apdu", "hw", etc...)
Type: LogType
data
Data associated to the log event
Type: LogData
context
Context data, coming for example from the caller's parent, to enable a simple tracing system
Type: TraceContext
id
Unique id among all logs
Type: string
log
Logs something
Parameters
typeLogType a namespaced identifier of the log (it is not a level like "debug", "error" but more like "apdu-in", "apdu-out", etc...)messagestring? a clear message of the log associated to the typedataLogData?
trace
A simple tracer function, only expanding the existing log function
Its goal is to capture more context than a log function. This is simple for now, but can be improved later.
Parameters
context{type: LogType, message: string?, data: LogData?, context: TraceContext?} Anything representing the context where the log occurredcontext.typecontext.messagecontext.datacontext.context
LocalTracer
A simple tracer class, that can be used to avoid repetition when using the trace function
Its goal is to capture more context than a log function. This is simple for now, but can be improved later.
Parameters
typeA given type (not level) for the current local tracer ("hw", "withDevice", etc.)contextAnything representing the context where the log occurred
withType
Create a new instance of the LocalTracer with an updated type
It does not mutate the calling instance, but returns a new LocalTracer, following a simple builder pattern.
Parameters
typeLogType
Returns LocalTracer
withContext
Create a new instance of the LocalTracer with a new context
It does not mutate the calling instance, but returns a new LocalTracer, following a simple builder pattern.
Parameters
contextTraceContext? A TraceContext, that can undefined to reset the context
Returns LocalTracer
withUpdatedContext
Create a new instance of the LocalTracer with an updated context,
on which an additional context is merged with the existing one.
It does not mutate the calling instance, but returns a new LocalTracer, following a simple builder pattern.
Parameters
contextToAddTraceContext
Returns LocalTracer
listen
Adds a subscribers to the emitted logs.
Parameters
cbSubscriber that is called for each future log() with the Log object
Returns Unsubscribe a function that can be called to unsubscribe the listener
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago