@creejs/commons-logging
Version:
Common Utils About Logging
174 lines (173 loc) • 6.24 kB
TypeScript
/**
* Abstract Logger Class of All Logger
* @abstract
*/
export default class Logger {
/**
* Creates a new Logger instance.
* @constructor
* @param {string} name - The name identifier for the logger
* @param {*} [nativeLogger]
* @param {number} [level] - The logging level, default is Level.ERROR=1
*/
constructor(name: string, nativeLogger?: any, level?: number);
_name: string;
_nativeLogger: any;
_level: number;
get nativeLogger(): any;
get level(): number;
/**
* Gets the name of the logger instance.
* @returns {string} The name of the logger.
*/
get name(): string;
/**
* Checks if FATAL level logging is enabled for this logger.
* @returns {boolean} True if FATAL level logging is enabled, false otherwise.
*/
get fatalEnabled(): boolean;
/**
* Checks if ERROR level logging is enabled for this logger.
* @returns {boolean} True if ERROR level logging is enabled, false otherwise.
*/
get errorEnabled(): boolean;
/**
* Checks if WARN level logging is enabled for this logger.
* @returns {boolean} True if WARN level logging is enabled, false otherwise.
*/
get warnEnabled(): boolean;
/**
* Checks if DEBUG level logging is enabled for this logger.
* @returns {boolean} True if DEBUG level logging is enabled, false otherwise.
*/
get debugEnabled(): boolean;
/**
* Checks if INFO level logging is enabled for this logger.
* @returns {boolean} True if INFO level logging is enabled, false otherwise.
*/
get infoEnabled(): boolean;
/**
* Checks if TRACE level logging is enabled for this logger.
* @returns {boolean} True if TRACE level logging is enabled, false otherwise.
*/
get traceEnabled(): boolean;
/**
* change log level for current logger instance.
* @param {number} level - new log level to set
* @throws {Error} Currently throws an error as this method is Not Impled Yet.
* @abstract
*/
setLevel(level: number): void;
/**
* Logs a fatal error message with timestamp and logger name.
* Only outputs if fatal logging is enabled for this logger instance.
* @param {...any} args - Arguments to log (will be space-separated)
*/
fatal(...args: any[]): void;
/**
* Logs an error message to the console with timestamp and logger name.
* Only logs if error logging is enabled for this logger instance.
* @param {...any} args - Arguments to be logged as error message
*/
error(...args: any[]): void;
/**
* Logs a warning message to the console if warn logging is enabled.
* @param {...any} args - The arguments to log as a warning message.
*/
warn(...args: any[]): void;
/**
* Logs debug messages to console if debug mode is enabled.
* @param {...any} args - The data to be logged
*/
debug(...args: any[]): void;
/**
* Logs an info message to the console with timestamp and logger name.
* @param {...any} args - The data to be logged. Accepts multiple arguments.
*/
info(...args: any[]): void;
/**
* Logs a trace message with timestamp and logger name if trace logging is enabled.
* @param {...any} args - Data to be logged as trace message.
*/
trace(...args: any[]): void;
/**
* Checks if FATAL level logging is enabled for this logger.
* @returns {boolean} True if FATAL level logging is enabled, false otherwise.
*/
isFatalEnabled(): boolean;
/**
* Checks if ERROR level logging is enabled for this logger.
* @returns {boolean} True if ERROR level logging is enabled, false otherwise.
*/
isErrorEnabled(): boolean;
/**
* Checks if WARN level logging is enabled for this logger.
* @returns {boolean} True if WARN level logging is enabled, false otherwise.
*/
isWarnEnabled(): boolean;
/**
* Checks if DEBUG level logging is enabled for this logger.
* @returns {boolean} True if DEBUG level logging is enabled, false otherwise.
*/
isDebugEnabled(): boolean;
/**
* Checks if INFO level logging is enabled for this logger.
* @returns {boolean} True if INFO level logging is enabled, false otherwise.
*/
isInfoEnabled(): boolean;
/**
* Checks if TRACE level logging is enabled for this logger.
* @returns {boolean} True if TRACE level logging is enabled, false otherwise.
*/
isTraceEnabled(): boolean;
/**
* Sets the logging level
* @param {number} level
* @throws {Error} Always throws "Not Impled Yet Yet" error.
* @protected
* @abstract
*/
protected _setLevel(level: number): void;
/**
* Override this method to implement fatal logging.
* @protected
* @param {...*} args - Variable arguments
* @throws {Error} Always throws "Not Impled Yet Yet" error
*/
protected _fatal(...args: any[]): void;
/**
* Override this method to implement error logging.
* @protected
* @param {...*} args - Variable arguments
* @throws {Error} Always throws "Not Impled Yet Yet" error
*/
protected _error(...args: any[]): void;
/**
* Override this method to implement warn logging.
* @protected
* @param {...*} args - Variable arguments
* @throws {Error} Always throws "Not Impled Yet Yet" error
*/
protected _warn(...args: any[]): void;
/**
* Override this method to implement debug logging.
* @protected
* @param {...*} args - Variable arguments
* @throws {Error} Always throws "Not Impled Yet Yet" error
*/
protected _debug(...args: any[]): void;
/**
* Override this method to implement info logging.
* @protected
* @param {...*} args - Variable arguments
* @throws {Error} Always throws "Not Impled Yet Yet" error
*/
protected _info(...args: any[]): void;
/**
* Override this method to implement trace logging.
* @protected
* @param {...*} args - Variable arguments
* @throws {Error} Always throws "Not Impled Yet Yet" error
*/
protected _trace(...args: any[]): void;
}