@exmg/livery
Version:
Ex Machina Group Livery Web SDK.
152 lines (151 loc) • 3.54 kB
TypeScript
/**
* Log level name to LogLevel map.
*/
declare const LOG_LEVEL_MAP: {
readonly QUIET: {
readonly weight: 6;
};
readonly ERROR: {
readonly weight: 5;
readonly emoji: "❌";
readonly consoleMethod: "error";
};
readonly WARN: {
readonly weight: 4;
readonly emoji: "⚠️";
readonly consoleMethod: "warn";
};
readonly INFO: {
readonly weight: 3;
readonly emoji: "🔹";
readonly consoleMethod: "info";
};
readonly DEBUG: {
readonly weight: 2;
readonly emoji: "🔸";
readonly consoleMethod: "debug";
};
readonly SPAM: {
readonly weight: 1;
readonly emoji: "⬩";
readonly consoleMethod: "debug";
};
};
/**
* Log level name.
*/
export declare type LogLevelName = keyof typeof LOG_LEVEL_MAP;
/**
* Parameters passed to custom log method.
*/
interface CustomLogParams {
/**
* Log level emoji character.
*/
emoji: string;
/**
* True if this log level is enabled.
*/
enabled: boolean;
/**
* Level of this log call.
*/
level: LogLevelName;
/**
* Name of Logger.
*/
name: string;
/**
* Logger instance number.
*/
nr: number;
/**
* Timestamp (HH:MM:SS.xxx) of this log call.
*/
timestamp: string;
}
/**
* Custom log method.
*/
export declare type CustomLogMethod = (params: CustomLogParams, args: unknown[]) => void;
/**
* A simple Logger class that can be hooked up to custom log methods (e.g: for logging to DOM)
* and can be enabled/disabled by level.
*/
export declare class Logger {
private name;
static options: {
/**
* Global log level.
*/
level: "QUIET" | "ERROR" | "WARN" | "INFO" | "DEBUG" | "SPAM";
/**
* If true then log to console.
*/
console: boolean;
/**
* Custom log method to use (if any).
*/
customLog: CustomLogMethod | undefined;
};
private static nameCountMap;
private nr;
/**
* Logger constructor.
*
* @param name Name of Logger, used as prefix
*/
constructor(name: string);
/**
* Type guard function that returns true if the specified value is a LogLevelName.
*
* @param name Name to check
*/
static isLevelName(name: string): name is LogLevelName;
/**
* Log debug information.
*
* @param args Debug arguments, e.g: message
*/
debug(...args: unknown[]): void;
/**
* Log an error.
*
* @param args Error arguments, e.g: an Error instance
*/
error(...args: unknown[]): void;
/**
* Log information.
*
* @param args Information arguments, e.g: message
*/
info(...args: unknown[]): void;
/**
* Log spam information.
*
* @param args Spam arguments, e.g: message
*/
spam(...args: unknown[]): void;
/**
* Log a warning.
*
* @param args Warning arguments, e.g: message
*/
warn(...args: unknown[]): void;
/**
* Log arguments at specified level.
*
* Calls the `customLog` method (if any).
*
* Logs to console if that is enabled and the call level has a weight equal or higher than the Logger level.
*
* @param levelName Name of LogLevel
* @param args Arguments to log
*/
private log;
}
/**
* Log method name.
*/
export declare type LogMethodName = keyof Logger;
export {};