blaze-2d
Version:
A fast and simple WebGL 2 2D game engine written in TypeScript
42 lines (41 loc) • 1.46 kB
TypeScript
export declare type LoggerArg = string | number | bigint | boolean;
export declare type LogString = string;
export declare type WarnString = string;
export declare type ErrorString = string;
export declare type LogType = "log" | "error" | "warning";
export declare type LogCallback = (type: LogType, str: string, id?: string, args?: LoggerArg[]) => void;
export default abstract class Logger {
static errorColor: string;
static successColor: string;
static warnColor: string;
static listeners: LogCallback[];
/**
* Logs a message.
*
* @param id The identifier of who is logging
* @param args The args to log
*/
static log(id: string, ...args: LoggerArg[]): LogString;
static error(id: string, ...args: LoggerArg[]): ErrorString;
static warn(id: string, ...args: LoggerArg[]): WarnString;
/**
* Constructs the string to be logged.
*
* @param id The identifier of who is logging
* @param args The args to log
*/
static str(id: string, ...args: LoggerArg[]): string;
private static callListeners;
/**
* Adds a callback which will be called whenever a message is logged.
*
* @param callback The listener's callback
*/
static addListener(callback: LogCallback): void;
/**
* Removes a listener from the logger.
*
* @param callback The listener to remove
*/
static removeListener(callback: LogCallback): void;
}