UNPKG

@pexip/signal

Version:

an observer pattern while avoiding boilerplate code. https://en.wikipedia.org/wiki/Signals_and_slots

47 lines (46 loc) 1.4 kB
/** * Log meta and message with respective log level */ export type LogMethod = (meta: unknown, message?: string) => void; export declare enum LogLevels { trace = 10, debug = 20, info = 30, warn = 40, error = 50, fatal = 60, silent = 9007199254740991 } export type LogLevelsString = keyof typeof LogLevels; export type LogMethods = { [key in LogLevelsString]: LogMethod; }; /** * Log Level from high to low, "fatal" | "error" | "warn" | "info" | "debug" | "trace" * Typically, debug and trace logs are only valid for development, and not needed in production */ export interface Logger extends LogMethods { /** * Add a pattern to the redactor and an optional mask for the redaction. * * @see {@link Redactor} * * @param value - The pattern to add. * @param replaceTo - The mask to use for redaction. */ addRedactPattern(value: string, redactTo?: string): void; /** * Redact the provided string by replacing all occurrences of the patterns * and return a new string with redacted values. * * @see {@link Redactor} * * @param text - The string to redact. */ redact(text: string): string; } /** * Create a logger with console API, and map fatal to error, skipping trace * and silent, and there is no redaction */ export declare function createConsoleLogger(): Readonly<Logger>;