UNPKG

@incubrain/logger

Version:

A modern, format-agnostic logging library for Node.js and browser environments, built on top of Consola with additional features for enterprise applications.

59 lines (58 loc) 1.74 kB
import type { LoggerOptions, LogContext } from "./core/types.js"; import { Logger } from "./core/logger.js"; import type { ErrorHandler } from "./core/errors.js"; export interface FileLoggingOptions { enabled?: boolean; filePath?: string; maxFileSize?: number; maxFiles?: number; format?: "json" | "jsonsl"; pretty?: boolean; bufferSize?: number; flushInterval?: number; } export interface ErrorLoggingOptions { enabled?: boolean; filePath?: string; maxFileSize?: number; maxFiles?: number; level?: number; } export interface SetupOptions extends LoggerOptions { errorHandler?: ErrorHandler; setupErrorHandlers?: boolean; fileLogging?: FileLoggingOptions; errorLogging?: ErrorLoggingOptions; } /** * Setup logger with advanced features (async) */ export declare function setupLogger(options?: SetupOptions): Promise<Logger>; /** * Convenience method for Nuxt plugin */ export declare function createNuxtPlugin(context?: LogContext): { provide: { logger: Logger; }; }; /** * Create a logger factory that allows dynamic context switching * while maintaining global configuration */ export declare function createLoggerFactory(globalOptions?: SetupOptions): Promise<(context: LogContext) => Logger>; export declare function detectLogLevel(): number; /** * Clean up all loggers and resources * Should be called when shutting down the application */ export declare function cleanupLoggers(): Promise<void>; /** * Utility function for quick file logging */ export declare function logToFile(fileName: string, data: any, options?: { maxFileSize?: number; maxFiles?: number; format?: "json" | "jsonsl"; pretty?: boolean; }): Promise<void>;