import { type LogEntry } from "@thi.ng/logger/api"; import type { Transducer } from "@thi.ng/transducers"; import type { BodyFormat, DateFormat, LogEntryObj } from "./api.js"; export declare const isoDate: (dt: number) => string; /** * Log entry formatter/transducer. Formats a {@link LogEntry} tuple as string * using optionally provided formatters. * * @remarks * If `wrap` is given, it will be called with both the already formatted message * string and the original log entry. The function can be used to post-process * the message (e.g. to wrap it in ANSI color escape sequences, based on logger * ID and/or level, also see [thi.ng/text-format](https://thi.ng/text-format)) * * @param dateFmt * @param bodyFmt * @param wrap */ export declare const formatString: (dateFmt?: DateFormat, bodyFmt?: BodyFormat, wrap?: (msg: string, entry: LogEntry) => string) => Transducer; /** * Takes an array of regex patterns and optional `mask` string. Returns * transducer which replaces all found pattern occurrences with `mask`. * Intended to be used in combination / after {@link formatString} to avoid * leaking of sensitive information via logged messages. * * * @example * ```ts tangle:../export/mask-secrets.ts * import { * Logger, formatString, maskSecrets, writeConsole * } from "@thi.ng/rstream-log"; * * const logger = new Logger(); * * logger.stream.transform( * formatString(), * maskSecrets([/(?<=[A-Z0-9_]\=)\w+/g]) * ).subscribe( * writeConsole() * ); * * logger.info("logged in USER=toxi, using TOKEN=123456"); * // [INFO] logger-0: 2024-06-21T12:22:58.004Z logged in USER=****, using TOKEN=**** * ``` * * @param patterns - * @param mask - */ export declare const maskSecrets: (patterns: RegExp[], mask?: string) => Transducer; /** * Log entry transducer which converts a {@link LogEntry} tuple to a * {@link LogEntryObj}. */ export declare const formatObject: () => Transducer; /** * Log entry formatter/transducer. Format a {@link LogEntry} tuple into a * serialized JSON string (object keys: `id`, `level`, `time`, `body`), with the * entry's timestamp formatted using given `dateFmt` (default: {@link isoDate}). * * @param dateFmt */ export declare const formatJSON: (dateFmt?: DateFormat) => Transducer; //# sourceMappingURL=format.d.ts.map