import { Hooks } from "@tsed/hooks"; import { LogLevel } from "@tsed/logger"; import { DILogger } from "../../common/index.js"; /** * Options for creating a context logger instance. * * @public */ export interface ContextLoggerOptions extends Record { id: string; logger?: DILogger; level?: "debug" | "info" | "warn" | "error" | "off" | "all"; maxStackSize?: number; additionalProps?: Record; } /** * Context-aware logger for scoped logging within a request or execution context. * * Buffers log messages and associates them with a specific context (like an HTTP request). * Supports log level filtering, buffering, and automatic flushing when the context ends. * * ### Usage * * ```typescript * import {ContextLogger} from "@tsed/di"; * * const logger = new ContextLogger({id: "req-123"}); * * logger.info("Processing request"); * logger.debug("Debug info"); * * await logger.flush(); // Write buffered logs * ``` * * @public */ export declare class ContextLogger { #private; readonly dateStart: Date; readonly id: string; maxStackSize: number; constructor({ id, logger, dateStart, level, maxStackSize, additionalProps }: ContextLoggerOptions); set level(level: "debug" | "info" | "warn" | "error" | "off" | "all" | LogLevel); get level(): "debug" | "info" | "warn" | "error" | "off" | "all" | LogLevel; get hooks(): Hooks; private get stack(); alterLog(cb: (data: any, level: "debug" | "info" | "warn" | "error" | "all", withRequest: boolean) => any): Hooks; alterIgnoreLog(cb: (ignore: boolean, data: any) => boolean): Hooks; info(obj: any): this; debug(obj: any): this; warn(obj: any): this; error(obj: any): this; fatal(obj: any): this; trace(obj: any): this; flush(stream?: boolean): void; isLevelEnabled(otherLevel: string | LogLevel): boolean; /** * Return the duration between the time when LogIncomingRequest has handle the request and now. * @returns {number} */ protected getDuration(): number; protected getData(obj: any): any; protected run(level: LogLevel, obj: any, withRequest?: boolean): void; }