@vepler/logger
Version:
A lightweight, type-safe logging wrapper around Pino, built by Vepler for modern TypeScript applications.
114 lines (113 loc) • 2.76 kB
TypeScript
import type { Logger, LoggerOptions, Bindings } from 'pino';
/**
* Interface for structured log context
*/
interface LogContext {
[]: unknown;
}
/**
* A lightweight, type-safe logging wrapper around Pino
*/
declare class PinoWrapper {
private static instance;
private logger;
private context;
private constructor();
/**
* Initialize the logger with optional configuration
*/
static initialize(options?: LoggerOptions): void;
/**
* Ensure the logger is initialized
*/
private static ensureInitialized;
/**
* Set global context that will be included in all subsequent logs
*/
static setContext(context: LogContext): void;
/**
* Clear all global context
*/
static clearContext(): void;
/**
* Helper to merge context with additional fields
*/
private static mergeContext;
/**
* Format error objects for structured logging
*/
private static formatError;
/**
* Core log method that all other methods use
*/
private static log;
/**
* Log at INFO level
* Supports:
* - info(message)
* - info(message, context)
* - info(context)
*/
static info(...args: unknown[]): void;
/**
* Log at ERROR level
* Supports:
* - error(message)
* - error(error)
* - error(message, context)
* - error(context)
* - error(error, message)
* - error(error, message, context)
* - error(message, { error })
*/
static error(...args: unknown[]): void;
/**
* Log at DEBUG level
* Supports:
* - debug(message)
* - debug(message, context)
* - debug(context)
*/
static debug(...args: unknown[]): void;
/**
* Log at WARN level
* Supports:
* - warn(message)
* - warn(message, context)
* - warn(context)
*/
static warn(...args: unknown[]): void;
/**
* Log at FATAL level
* Supports:
* - fatal(message)
* - fatal(error)
* - fatal(message, context)
* - fatal(context)
* - fatal(error, message)
* - fatal(error, message, context)
* - fatal(message, { error })
*/
static fatal(...args: unknown[]): void;
/**
* Log at TRACE level
* Supports:
* - trace(message)
* - trace(message, context)
* - trace(context)
*/
static trace(...args: unknown[]): void;
/**
* Create a child logger with bound context
*/
static child(bindings: Bindings): PinoWrapper;
/**
* Get the underlying Pino logger instance
*/
static getRawLogger(): Logger;
/**
* Flush all buffered logs
*/
static flush(): Promise<void>;
}
export default PinoWrapper;