UNPKG

perfect-logger

Version:

A zero-dependency, isomorphic logger for Node.js and Browsers with plugin support.

31 lines (30 loc) 1.33 kB
import { LogManager } from './LogManager'; /** * The user-facing logger class. * It provides methods for logging at different levels (info, warn, error, etc.) * and for creating contextual child loggers. */ export declare class Logger { private readonly logManager; readonly namespace: string; private readonly context; /** * @param logManager The singleton LogManager instance. * @param namespace The name of the logger (e.g., "AuthService"). * @param context Contextual data to be included with every log from this logger. */ constructor(logManager: LogManager, namespace: string, context?: Record<string, any>); trace(message: string, context?: Record<string, any>): void; debug(message: string, context?: Record<string, any>): void; info(message: string, context?: Record<string, any>): void; warn(message: string, context?: Record<string, any>): void; error(message: string, error?: Error, context?: Record<string, any>): void; fatal(message: string, error?: Error, context?: Record<string, any>): void; /** * Creates a child logger that inherits the parent's context. * @param context Additional context to add to the child logger. * @returns A new Logger instance. */ child(context: Record<string, any>): Logger; private log; }