UNPKG

4.59 kBTypeScriptView Raw
1/**
2 * @publicApi
3 */
4export type LogLevel = 'log' | 'error' | 'warn' | 'debug' | 'verbose' | 'fatal';
5/**
6 * @publicApi
7 */
8export interface LoggerService {
9 /**
10 * Write a 'log' level log.
11 */
12 log(message: any, ...optionalParams: any[]): any;
13 /**
14 * Write an 'error' level log.
15 */
16 error(message: any, ...optionalParams: any[]): any;
17 /**
18 * Write a 'warn' level log.
19 */
20 warn(message: any, ...optionalParams: any[]): any;
21 /**
22 * Write a 'debug' level log.
23 */
24 debug?(message: any, ...optionalParams: any[]): any;
25 /**
26 * Write a 'verbose' level log.
27 */
28 verbose?(message: any, ...optionalParams: any[]): any;
29 /**
30 * Write a 'fatal' level log.
31 */
32 fatal?(message: any, ...optionalParams: any[]): any;
33 /**
34 * Set log levels.
35 * @param levels log levels
36 */
37 setLogLevels?(levels: LogLevel[]): any;
38}
39interface LogBufferRecord {
40 /**
41 * Method to execute.
42 */
43 methodRef: Function;
44 /**
45 * Arguments to pass to the method.
46 */
47 arguments: unknown[];
48}
49/**
50 * @publicApi
51 */
52export declare class Logger implements LoggerService {
53 protected context?: string;
54 protected options: {
55 timestamp?: boolean;
56 };
57 protected static logBuffer: LogBufferRecord[];
58 protected static staticInstanceRef?: LoggerService;
59 protected static logLevels?: LogLevel[];
60 private static isBufferAttached;
61 protected localInstanceRef?: LoggerService;
62 private static WrapBuffer;
63 constructor();
64 constructor(context: string);
65 constructor(context: string, options?: {
66 timestamp?: boolean;
67 });
68 get localInstance(): LoggerService;
69 /**
70 * Write an 'error' level log.
71 */
72 error(message: any, stack?: string, context?: string): void;
73 error(message: any, ...optionalParams: [...any, string?, string?]): void;
74 /**
75 * Write a 'log' level log.
76 */
77 log(message: any, context?: string): void;
78 log(message: any, ...optionalParams: [...any, string?]): void;
79 /**
80 * Write a 'warn' level log.
81 */
82 warn(message: any, context?: string): void;
83 warn(message: any, ...optionalParams: [...any, string?]): void;
84 /**
85 * Write a 'debug' level log.
86 */
87 debug(message: any, context?: string): void;
88 debug(message: any, ...optionalParams: [...any, string?]): void;
89 /**
90 * Write a 'verbose' level log.
91 */
92 verbose(message: any, context?: string): void;
93 verbose(message: any, ...optionalParams: [...any, string?]): void;
94 /**
95 * Write a 'fatal' level log.
96 */
97 fatal(message: any, context?: string): void;
98 fatal(message: any, ...optionalParams: [...any, string?]): void;
99 /**
100 * Write an 'error' level log.
101 */
102 static error(message: any, stackOrContext?: string): void;
103 static error(message: any, context?: string): void;
104 static error(message: any, stack?: string, context?: string): void;
105 static error(message: any, ...optionalParams: [...any, string?, string?]): void;
106 /**
107 * Write a 'log' level log.
108 */
109 static log(message: any, context?: string): void;
110 static log(message: any, ...optionalParams: [...any, string?]): void;
111 /**
112 * Write a 'warn' level log.
113 */
114 static warn(message: any, context?: string): void;
115 static warn(message: any, ...optionalParams: [...any, string?]): void;
116 /**
117 * Write a 'debug' level log, if the configured level allows for it.
118 * Prints to `stdout` with newline.
119 */
120 static debug(message: any, context?: string): void;
121 static debug(message: any, ...optionalParams: [...any, string?]): void;
122 /**
123 * Write a 'verbose' level log.
124 */
125 static verbose(message: any, context?: string): void;
126 static verbose(message: any, ...optionalParams: [...any, string?]): void;
127 /**
128 * Write a 'fatal' level log.
129 */
130 static fatal(message: any, context?: string): void;
131 static fatal(message: any, ...optionalParams: [...any, string?]): void;
132 /**
133 * Print buffered logs and detach buffer.
134 */
135 static flush(): void;
136 /**
137 * Attach buffer.
138 * Turns on initialization logs buffering.
139 */
140 static attachBuffer(): void;
141 /**
142 * Detach buffer.
143 * Turns off initialization logs buffering.
144 */
145 static detachBuffer(): void;
146 static getTimestamp(): string;
147 static overrideLogger(logger: LoggerService | LogLevel[] | boolean): any;
148 static isLevelEnabled(level: LogLevel): boolean;
149 private registerLocalInstanceRef;
150}
151export {};