export interface LoggerConfigs { /** * Only logs with level <= of LOG_LEVEL will be printed. */ LOG_LEVEL: LoggerLevels | string; /** * Either default 'text' or 'json' */ LOG_OUTPUT: LoggerOutput; /** * When true, ignores LOG_LEVEL when printing debugging level logs. * * Useful to quickly enable debug logs when debugging (duh). */ DEBUGGING: boolean; /** * This suppresses all the logs. * * The reason why it's called TESTING and not SUPPRESS_ALL_LOGS is because TESTING is what's used by vitest and other unit testing tools. * * Unit tests are exactly the time where you don't want to clog your console with unrelated logs. */ TESTING: boolean; } /** * 'test' is default string logs to stdout/stderr. * * 'json' is used in deployed environments to format output in json so that Promtail/Loki/Grafana Stacks can easily deal with them. */ export type LoggerOutput = 'text' | 'json'; /** * 'unknown' is not inteded to be used on purpose. * * It is only assigned whenever something in configuration fails so that it still has a value Grafana can understand, rather than having Grafana try its best and match it at random. */ export declare enum LoggerLevels { 'unknown' = 0, 'trace' = 1, 'debug' = 2, 'info' = 3, 'warning' = 4, 'error' = 5, 'critical' = 6 } export declare class Logger { private static readonly config; private static jsonlogger; /** * Forces reloading all configs from 'process.env'. * * Useful when you populate environment at runtime after ez-ts-logger is already imported, for example when using 'dotenv'. */ static reloadEnvConfigs(): void; /** * Updates the current config. * @param configs - An object with every config you want to change. */ static changeConfigs(configs: Partial): void; /** * Returns all current configs. * @returns The current configuration object, such as active log levels and output format. */ static currentConfigs(): LoggerConfigs; /** * Prints a 'trace' level message. * @params args - Can be a string or a JSON style object */ static trace(args: string | Record): void; /** * Prints a 'debug' level message. * @params args - Can be a string or a JSON style object */ static debug(args: string | Record): void; /** * Prints an 'info' level message. * * Same as Logger.info(). * @params args - Can be a string or a JSON style object. */ static log(args: string | Record): void; /** * Prints an 'info' level message. * @params args - Can be a string or a JSON style object. */ static info(args: string | Record): void; /** * Prints a 'warning' level message. * * Same as Logger.warn(). * @params args - Can be a string, a JSON style object, an instance of Error or any CustomError that extends Error. */ static warning(args: string | Error | Record): void; /** * Prints a 'warning' level message. * @params args - Can be a string, a JSON style object, an instance of Error or any CustomError that extends Error. */ static warn(args: string | Error | Record): void; /** * Prints an 'error' level message. * @params args - Can be a string, a JSON style object, an instance of Error or any CustomError that extends Error. */ static error(args: string | Error | Record): void; /** * Prints an 'error' level message. * * Then throws the provided error. * @params error - Can be an instance of Error or any CustomError that extends Error. */ static errorAndThrow(error: Error | unknown): void; /** * Print a 'critical' level message. * @params args - Can be a string, a JSON style object, an instance of Error or any CustomError that extends Error. */ static critical(args: string | Error | Record): void; /** * Prints a 'critical' level message. * * Then throws the provided error. * @params error - Can be an instance of Error or any CustomError that extends Error. */ static criticalAndThrow(error: Error | unknown): void; }