API Reference
Logging Functions
All logging functions accept any type: strings, objects, arrays, or primitives. Complex objects are safely serialized (handles circular references, NaN, BigInt, etc.).
ts
logger.trace(message: any): void // Detailed debug information
logger.debug(message: any): void // Debug-level messages
logger.info(message: any): void // Informational messages
logger.warn(message: any): void // Warning messages
logger.error(message: any): void // Error messages
logger.fatal(message: any): void // Critical failuresConfiguration
setConfig
Sets the logger configuration. Returns the active config or null if invalid. Automatically selects dev or prod based on NODE_ENV.
ts
logger.setConfig(config: LoggerConfig): EnvConfig | nullLifecycle
shutdown
Flushes all buffered logs and cleanly shuts down background threads. Call this before process exit to ensure no logs are lost.
ts
logger.shutdown(): voidTypes & Enums
LoggerConfig
ts
interface LoggerConfig {
dev?: EnvConfig;
prod?: EnvConfig;
}EnvConfig
ts
interface EnvConfig {
output: OutputConfig;
fields?: FieldsConfig;
}OutputConfig
color: booleanformat: OutputFormattarget: OutputTargetfilePath?: stringmaxFileSize?: numbermaxBackups?: numberrotateDaily?: booleanbatchEnabled?: booleanbatchSize?: numberbatchIntervalMs?: numbermasking?: MaskingConfig
Enums
ts
enum LogLevel {
Trace = 0,
Debug = 1,
Info = 2,
Warn = 3,
Error = 4,
Fatal = 5
}
enum OutputFormat {
Text = 0, // Human-readable text output
Json = 1 // JSON Lines format
}
enum OutputTarget {
Stdout = 0,
Stderr = 1,
File = 2,
Null = 3
}