@notross/mongo-singleton
Version:
A lightweight, zero-fuss way to get a single shared MongoDB connection across your Node.js codebase.
47 lines • 1.48 kB
TypeScript
import { LoggerCallback, LogLevel, LogMethod, LogResult } from '../types';
/**
* Logger with in-memory history, optional console output,
* and user-supplied callback support. Supports filtering by level.
*/
export declare class Logger {
private callback;
private logging;
logs: LogResult[];
private levels?;
debug: LogMethod;
error: LogMethod;
info: LogMethod;
log: LogMethod;
warn: LogMethod;
/**
* @param props.logging - Whether logs are echoed to console. Defaults to true.
* @param props.logLevels - If provided, only these levels will be output.
* @param props.callback - Optional function invoked with every log entry.
*/
constructor(props?: {
logging?: boolean;
logLevels?: LogLevel[];
callback?: LoggerCallback;
});
/**
* Set which log levels are allowed to emit.
* @param levels - Array of allowed LogLevel values. Undefined resets to all.
*/
setLevels(levels?: LogLevel[]): void;
/**
* Toggle console logging on or off.
* @param logging - If provided, sets explicitly; otherwise flips current state.
*/
toggleLogging(logging?: boolean): void;
/**
* Internal output to console respecting level filters.
* @private
*/
private output;
/**
* Core log runner; formats the message, stores it, invokes callback, and outputs.
* @private
*/
private run;
}
//# sourceMappingURL=logger.d.ts.map