UNPKG

@amo-tm/wsc

Version:

The amo WSC component of the amo JS SDK

56 lines (55 loc) 1.83 kB
declare type LogLevelString = 'debug' | 'verbose' | 'info' | 'warn' | 'error' | 'silent'; /** * The JS SDK supports 5 log levels and also allows a user the ability to * silence the logs altogether. * * The order is a follows: * DEBUG < VERBOSE < INFO < WARN < ERROR * * All of the log types above the current log level will be captured (i.e. if * you set the log level to `INFO`, errors will still be logged, but `DEBUG` and * `VERBOSE` logs will not) */ export declare enum LogLevel { DEBUG = 0, VERBOSE = 1, INFO = 2, WARN = 3, ERROR = 4, SILENT = 5 } declare type LogHandler = (loggerInstance: Logger, logType: LogLevel, ...args: unknown[]) => void; export declare class Logger { name: string; /** * Gives you an instance of a Logger to capture messages according to * Amo's logging scheme. * * @param name The name that the logs will be associated with */ constructor(name: string); /** * The log level of the given Logger instance. */ private _logLevel; get logLevel(): LogLevel; set logLevel(val: LogLevel); setLogLevel(val: LogLevel | LogLevelString): void; /** * The main (internal) log handler for the Logger instance. * Can be set to a new function in internal package code but not by user. */ private _logHandler; get logHandler(): LogHandler; set logHandler(val: LogHandler); /** * The functions below are all based on the `console` interface */ debug(...args: unknown[]): void; log(...args: unknown[]): void; info(...args: unknown[]): void; warn(...args: unknown[]): void; error(...args: unknown[]): void; } export declare function setLogLevel(level: LogLevelString | LogLevel): void; export {};