The library provides a global Log namespace to control the verbosity of logs and to inject custom logging implementations. This is useful for integrating the library's logs into your application's existing logging infrastructure.
Setting the Log Level
Use Log.setLevel(value) to set the current logging level. The available levels are defined in the Log enum:
Log.NONE (0): No logging.Log.ERROR (1): Only error messages.Log.WARN (2): Errors and warnings.Log.INFO (3): Errors, warnings, and info messages.Log.DEBUG (4): All messages, including debug logs.
Using a Custom Logger
To use your own logging logic, implement the ILogger interface and pass it to Log.setLogger(value). The interface requires the following methods:
debug(...args: unknown[]): voiderror(...args: unknown[]): voidinfo(...args: unknown[]): voidwarn(...args: unknown[]): void
export enum Log {
// (undocumented)
DEBUG = 4,
ERROR = 1,
INFO = 3,
NONE = 0,
WARN = 2
}
// (undocumented)
export namespace Log {
// (undocumented)
export function reset(): void;
// (undocumented)
export function setLevel(value: Log): void;
// (undocumented)
export function setLogger(value: ILogger): void;
}