import { DistinctLogger, LogLevel } from '../logging'; import LogManager from './logManager'; import { LogEntry } from './logEntry'; /** * Log filter function that can be used to filter log entries * when returning false the log entry will be ignored otherwise it will be written */ export type LogFilter = (ops: { logger: Logger; severity: LogLevel; args: any[]; }) => boolean; export interface LogWriter { /** * Write a entry to the log * @param entry Entry to write */ write(entry: LogEntry): void | Promise; /** * Optionally focus the output/log channel to the forground (only for supported channels) */ focus?(): void | Promise; } export declare class Logger { private readonly manager; readonly name: string; private readonly writer?; /** * Null logger, logs straight to /dev/null */ static readonly null: Logger; constructor(manager: LogManager | undefined, name: string, writer?: LogWriter | undefined); focus(): void; /** * {@link Logger.write} */ log(...args: any[]): void; /** * {@link Logger.write} */ info(...args: any[]): void; /** * {@link Logger.write} */ verbose(...args: any[]): void; /** * {@link Logger.write} */ warn(...args: any[]): void; /** * {@link Logger.write} */ error(...args: any[]): void; /** * {@link Logger.write} */ debug(...args: any[]): void; /** * Write a log entry to the log, this will be filtered by the log level and optional filters that are set. * * Messages are formatted using the following rules: * - If a single argument is passed it will be used as the message * - If a single argument is passed and it is an error it will be used as the message and the stack trace will be appended * - If a single argument is passed and it is an object it will be serialized to JSON * - If a single argument is passed and it is a function it will be executed and the result will be used as the message * - If multiple arguments are passed the first argument will be used as a format string and the remaining arguments will be used as format arguments * - If a format string is used it can contain the following format specifiers: * - `%s` String * - `%i` Integer (no decimals) * - `%d` Decimal with 2 decimals * - `%d:` Decimal with X decimals * - `%S` String in uppercase * - `%` The character will be ignored * * @example * ```typescript * logger.write(LogLevel.info, 'Hello', 'world'); // Hello world this is great * logger.write(LogLevel.info, 'Hello %s', 'world'); // Hello world * logger.write(LogLevel.info, 'Hello %S', 'world'); // Hello WORLD * logger.write(LogLevel.info, 'Hello %d', 1.234); // Hello 1.23 * logger.write(LogLevel.info, 'Hello %d:3', 1.234); // Hello 1.234 * logger.write(LogLevel.info, 'Hello %i', 1.234); // Hello 1 * logger.write(LogLevel.info, 'Hello %i', 1234); // Hello 1234 * logger.write(LogLevel.info, 'Hello %s', { foo: 'bar' }); // Hello {"foo":"bar"} * logger.write(LogLevel.info, 'Hello %s', () => 'world'); // Hello world * logger.write(LogLevel.info, 'Hello %s', 'world', 'this', 'is', 'great'); // Hello world this is great * logger.write(LogLevel.info, 'Hello', 'world %s %s %s', 'this', 'is', 'great'); // Hello world this is great * ``` * @param level Log level of the entry to write * @param args Arguments to write to the log entr. If a single argument is * passed it will be used as the message, otherwise the first argument will be used * as a format string and the remaining arguments will be used as format arguments */ write(level: LogLevel, ...args: any[]): void; writeEntry(entry: LogEntry): void; /** * Returns a new logger that wraps the current logger and filters out duplicate log messages. * @returns A new `DistinctLogger` instance. */ distinct(): DistinctLogger; } //# sourceMappingURL=logger.d.ts.map