1 | import { LoggerService, LogLevel } from './logger.service';
|
2 | export interface ConsoleLoggerOptions {
|
3 | |
4 |
|
5 |
|
6 | logLevels?: LogLevel[];
|
7 | |
8 |
|
9 |
|
10 | timestamp?: boolean;
|
11 | }
|
12 | export declare class ConsoleLogger implements LoggerService {
|
13 | protected context?: string;
|
14 | protected options: ConsoleLoggerOptions;
|
15 | private static lastTimestampAt?;
|
16 | private originalContext?;
|
17 | constructor();
|
18 | constructor(context: string);
|
19 | constructor(context: string, options: ConsoleLoggerOptions);
|
20 | /**
|
21 | * Write a 'log' level log, if the configured level allows for it.
|
22 | * Prints to `stdout` with newline.
|
23 | */
|
24 | log(message: any, context?: string): void;
|
25 | log(message: any, ...optionalParams: [...any, string?]): void;
|
26 | /**
|
27 | * Write an 'error' level log, if the configured level allows for it.
|
28 | * Prints to `stderr` with newline.
|
29 | */
|
30 | error(message: any, stackOrContext?: string): void;
|
31 | error(message: any, stack?: string, context?: string): void;
|
32 | error(message: any, ...optionalParams: [...any, string?, string?]): void;
|
33 | /**
|
34 | * Write a 'warn' level log, if the configured level allows for it.
|
35 | * Prints to `stdout` with newline.
|
36 | */
|
37 | warn(message: any, context?: string): void;
|
38 | warn(message: any, ...optionalParams: [...any, string?]): void;
|
39 | /**
|
40 | * Write a 'debug' level log, if the configured level allows for it.
|
41 | * Prints to `stdout` with newline.
|
42 | */
|
43 | debug(message: any, context?: string): void;
|
44 | debug(message: any, ...optionalParams: [...any, string?]): void;
|
45 | /**
|
46 | * Write a 'verbose' level log, if the configured level allows for it.
|
47 | * Prints to `stdout` with newline.
|
48 | */
|
49 | verbose(message: any, context?: string): void;
|
50 | verbose(message: any, ...optionalParams: [...any, string?]): void;
|
51 | /**
|
52 | * Write a 'fatal' level log, if the configured level allows for it.
|
53 | * Prints to `stdout` with newline.
|
54 | */
|
55 | fatal(message: any, context?: string): void;
|
56 | fatal(message: any, ...optionalParams: [...any, string?]): void;
|
57 | /**
|
58 | * Set log levels
|
59 | * @param levels log levels
|
60 | */
|
61 | setLogLevels(levels: LogLevel[]): void;
|
62 | /**
|
63 | * Set logger context
|
64 | * @param context context
|
65 | */
|
66 | setContext(context: string): void;
|
67 | /**
|
68 | * Resets the logger context to the value that was passed in the constructor.
|
69 | */
|
70 | resetContext(): void;
|
71 | isLevelEnabled(level: LogLevel): boolean;
|
72 | protected getTimestamp(): string;
|
73 | protected printMessages(messages: unknown[], context?: string, logLevel?: LogLevel, writeStreamType?: 'stdout' | 'stderr'): void;
|
74 | protected formatPid(pid: number): string;
|
75 | protected formatContext(context: string): string;
|
76 | protected formatMessage(logLevel: LogLevel, message: unknown, pidMessage: string, formattedLogLevel: string, contextMessage: string, timestampDiff: string): string;
|
77 | protected stringifyMessage(message: unknown, logLevel: LogLevel): any;
|
78 | protected colorize(message: string, logLevel: LogLevel): string;
|
79 | protected printStackTrace(stack: string): void;
|
80 | protected updateAndGetTimestampDiff(): string;
|
81 | protected formatTimestampDiff(timestampDiff: number): string;
|
82 | private getContextAndMessagesToPrint;
|
83 | private getContextAndStackAndMessagesToPrint;
|
84 | private isStackFormat;
|
85 | private getColorByLogLevel;
|
86 | }
|