@runejs/common
Version:
Common logging, networking, compression, and other miscellaneous functionality for RuneJS.
89 lines (88 loc) • 3.05 kB
TypeScript
import { Logger, LoggerOptions, TimeFn } from 'pino';
import SonicBoom from 'sonic-boom';
export declare const LOGGER_DEFAULT_TIME_FN: true | TimeFn;
/**
* The main RuneJS wrapper class for the Pino logger.
* @see https://www.npmjs.com/package/pino
* @see https://www.npmjs.com/package/sonic-boom
*/
export declare class RuneLogger {
/**
* The logger's active date/time format function for log messages.
* IE timestamp: () => `,"time":"${new Date(Date.now()).toISOString()}"`
*/
loggerTimeFn: true | TimeFn;
/**
* The main pino logger instance for the wrapper object.
*/
pinoLogger: Logger;
private _options;
private _boom;
constructor(options?: LoggerOptions);
/**
* Log at `'log'` level the given messages.
* @param messages The log messages to write.
*/
log(...messages: any[]): void;
/**
* Log at `'info'` level the given messages.
* @param messages The log messages to write.
*/
info(...messages: any[]): void;
/**
* Log at `'debug'` level the given messages.
* @param messages The log messages to write.
*/
debug(...messages: any[]): void;
/**
* Log at `'warn'` level the given messages.
* @param messages The log messages to write.
*/
warn(...messages: any[]): void;
/**
* Log at `'error'` level the given messages.
* @param messages The log messages to write.
*/
error(...messages: any[]): void;
/**
* Log at `'trace'` level the given messages.
* @param messages The log messages to write.
*/
trace(...messages: any[]): void;
/**
* Log at `'fatal'` level the given messages.
* @param messages The log messages to write.
*/
fatal(...messages: any[]): void;
/**
* Sets the logger's output log file destination path.
* @param dest The path for the log file to be written to.
* @return A `SonicBoom` object that controls the log output stream.
* @see https://www.npmjs.com/package/sonic-boom
*/
destination(dest: string): SonicBoom;
/**
* Sets the logger options to the given options object.
* @param options The options to supply to the `pino` logger instance.
*/
setOptions(options: LoggerOptions): void;
/**
* Sets the logger prettyPrint value.
* @param prettyPrint The value to set prettyPrint to.
*/
setPrettyPrint(prettyPrint: boolean): void;
/**
* Sets the logger's date/time function to the given value.
* @param format The function that will return the partial JSON value of the current time for Pino to ingest.
* IE timestamp: () => `,"time":"${new Date(Date.now()).toISOString()}"`
*/
setTimeFormat(format: TimeFn): void;
private logMessages;
private pinoInit;
get boom(): SonicBoom;
get options(): LoggerOptions;
}
/**
* The main logger singleton instance.
*/
export declare const logger: RuneLogger;