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, stack?: string, context?: string): void;
|
31 | error(message: any, ...optionalParams: [...any, string?, string?]): void;
|
32 | /**
|
33 | * Write a 'warn' level log, if the configured level allows for it.
|
34 | * Prints to `stdout` with newline.
|
35 | */
|
36 | warn(message: any, context?: string): void;
|
37 | warn(message: any, ...optionalParams: [...any, string?]): void;
|
38 | /**
|
39 | * Write a 'debug' level log, if the configured level allows for it.
|
40 | * Prints to `stdout` with newline.
|
41 | */
|
42 | debug(message: any, context?: string): void;
|
43 | debug(message: any, ...optionalParams: [...any, string?]): void;
|
44 | /**
|
45 | * Write a 'verbose' level log, if the configured level allows for it.
|
46 | * Prints to `stdout` with newline.
|
47 | */
|
48 | verbose(message: any, context?: string): void;
|
49 | verbose(message: any, ...optionalParams: [...any, string?]): void;
|
50 | /**
|
51 | * Set log levels
|
52 | * @param levels log levels
|
53 | */
|
54 | setLogLevels(levels: LogLevel[]): void;
|
55 | /**
|
56 | * Set logger context
|
57 | * @param context context
|
58 | */
|
59 | setContext(context: string): void;
|
60 | /**
|
61 | * Resets the logger context to the value that was passed in the constructor.
|
62 | */
|
63 | resetContext(): void;
|
64 | isLevelEnabled(level: LogLevel): boolean;
|
65 | protected getTimestamp(): string;
|
66 | protected printMessages(messages: unknown[], context?: string, logLevel?: LogLevel, writeStreamType?: 'stdout' | 'stderr'): void;
|
67 | protected formatPid(pid: number): string;
|
68 | protected formatMessage(logLevel: LogLevel, message: unknown, pidMessage: string, formattedLogLevel: string, contextMessage: string, timestampDiff: string): string;
|
69 | protected stringifyMessage(message: unknown, logLevel: LogLevel): string;
|
70 | protected colorize(message: string, logLevel: LogLevel): string;
|
71 | protected printStackTrace(stack: string): void;
|
72 | private updateAndGetTimestampDiff;
|
73 | private getContextAndMessagesToPrint;
|
74 | private getContextAndStackAndMessagesToPrint;
|
75 | private getColorByLogLevel;
|
76 | }
|