123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- import {LEVEL, MESSAGE, SPLAT} from 'triple-beam'
- export interface TransformableInfo {
- level: string;
- message: unknown;
- [LEVEL]?: string;
- [MESSAGE]?: unknown;
- [SPLAT]?: unknown;
- [key: string | symbol]: unknown;
- }
- export type TransformFunction = (info: TransformableInfo, opts?: unknown) => TransformableInfo | boolean;
- export type Colors = { [key: string]: string | string[] };
- export type FormatWrap = (opts?: unknown) => Format;
- export class Format {
- constructor(opts?: object);
- options?: object;
- transform: TransformFunction;
- }
- export class Colorizer extends Format {
- constructor(opts?: object);
- createColorize: (opts?: object) => Colorizer;
- addColors: (colors: Colors) => Colors;
- colorize: (level: string, message: string) => string;
- }
- export function format(transform: TransformFunction): FormatWrap;
- export function levels(config: object): object;
- export namespace format {
- function align(): Format;
- function cli(opts?: CliOptions): Format;
- function colorize(opts?: ColorizeOptions): Colorizer;
- function combine(...formats: Format[]): Format;
- function errors(opts?: object): Format;
- function json(opts?: JsonOptions): Format;
- function label(opts?: LabelOptions): Format;
- function logstash(): Format;
- function metadata(opts?: MetadataOptions): Format;
- function ms(): Format;
- function padLevels(opts?: PadLevelsOptions): Format;
- function prettyPrint(opts?: PrettyPrintOptions): Format;
- function printf(templateFunction: (info: TransformableInfo) => string): Format;
- function simple(): Format;
- function splat(): Format;
- function timestamp(opts?: TimestampOptions): Format;
- function uncolorize(opts?: UncolorizeOptions): Format;
- }
- export interface CliOptions extends ColorizeOptions, PadLevelsOptions { }
- export interface ColorizeOptions {
-
- level?: boolean;
-
- all?: boolean;
-
- message?: boolean;
-
- colors?: Record<string, string | string[]>;
- }
- export interface JsonOptions {
-
- replacer?: (this: unknown, key: string, value: unknown) => unknown;
-
- space?: number;
-
-
-
- bigint?: boolean,
-
- circularValue?: string | null | TypeErrorConstructor | ErrorConstructor,
-
- deterministic?: boolean,
-
- maximumBreadth?: number,
-
- maximumDepth?: number,
- }
- export interface LabelOptions {
-
- label?: string;
-
- message?: boolean;
- }
- export interface MetadataOptions {
-
- key?: string;
-
- fillExcept?: string[];
-
- fillWith?: string[];
- }
- export interface PadLevelsOptions {
-
- levels?: Record<string, number>;
- }
- export interface PrettyPrintOptions {
-
- depth?: number;
-
- colorize?: boolean;
- }
- export interface TimestampOptions {
-
- format?: string | (() => string);
- /**
- * The name of an alias for the timestamp property, that will be added to the `info` object.
- */
- alias?: string;
- }
- export interface UncolorizeOptions {
- /**
- * Disables the uncolorize format for `info.level` if set to `false`.
- */
- level?: boolean;
- /**
- * Disables the uncolorize format for `info.message` if set to `false`.
- */
- message?: boolean;
- /**
- * Disables the uncolorize format for `info[MESSAGE]` if set to `false`.
- */
- raw?: boolean;
- }
|