@innei/pretty-logger-core 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,190 +1,206 @@
1
- import EventEmitter from 'events';
1
+ import EventEmitter from "node:events";
2
2
 
3
+ //#region consola/types.d.ts
3
4
  interface ConsolaOptions {
4
- reporters: ConsolaReporter[];
5
- types: Record<LogType, InputLogObject>;
6
- level: LogLevel;
7
- defaults: InputLogObject;
8
- throttle: number;
9
- throttleMin: number;
10
- stdout?: NodeJS.WriteStream;
11
- stderr?: NodeJS.WriteStream;
12
- mockFn?: (type: LogType, defaults: InputLogObject) => (...args: any) => void;
13
- formatOptions: FormatOptions;
5
+ reporters: ConsolaReporter[];
6
+ types: Record<LogType, InputLogObject>;
7
+ level: LogLevel;
8
+ defaults: InputLogObject;
9
+ throttle: number;
10
+ throttleMin: number;
11
+ stdout?: NodeJS.WriteStream;
12
+ stderr?: NodeJS.WriteStream;
13
+ mockFn?: (type: LogType, defaults: InputLogObject) => (...args: any) => void;
14
+ formatOptions: FormatOptions;
14
15
  }
15
16
  /**
16
17
  * @see https://nodejs.org/api/util.html#util_util_inspect_object_showhidden_depth_colors
17
18
  */
18
19
  interface FormatOptions {
19
- columns?: number;
20
- date?: boolean;
21
- colors?: boolean;
22
- compact?: boolean | number;
23
- [key: string]: unknown;
20
+ columns?: number;
21
+ date?: boolean;
22
+ colors?: boolean;
23
+ compact?: boolean | number;
24
+ [key: string]: unknown;
24
25
  }
25
26
  interface InputLogObject {
26
- level?: LogLevel;
27
- tag?: string;
28
- type?: LogType;
29
- message?: string;
30
- additional?: string | string[];
31
- args?: any[];
32
- date?: Date;
27
+ level?: LogLevel;
28
+ tag?: string;
29
+ type?: LogType;
30
+ message?: string;
31
+ additional?: string | string[];
32
+ args?: any[];
33
+ date?: Date;
33
34
  }
34
35
  interface LogObject extends InputLogObject {
35
- level: LogLevel;
36
- type: LogType;
37
- tag: string;
38
- args: any[];
39
- date: Date;
40
- [key: string]: unknown;
36
+ level: LogLevel;
37
+ type: LogType;
38
+ tag: string;
39
+ args: any[];
40
+ date: Date;
41
+ [key: string]: unknown;
41
42
  }
42
43
  interface ConsolaReporter {
43
- log: (logObj: LogObject, ctx: {
44
- options: ConsolaOptions;
45
- }) => void;
44
+ log: (logObj: LogObject, ctx: {
45
+ options: ConsolaOptions;
46
+ }) => void;
46
47
  }
47
48
  interface WrappedConsola extends ConsolaInstance {
48
- onData: (handler: (data: string) => any) => WrappedConsola;
49
- onStdOut: (handler: (data: string) => any) => WrappedConsola;
50
- onStdErr: (handler: (data: string) => any) => WrappedConsola;
51
- }
52
-
49
+ onData: (handler: (data: string) => any) => WrappedConsola;
50
+ onStdOut: (handler: (data: string) => any) => WrappedConsola;
51
+ onStdErr: (handler: (data: string) => any) => WrappedConsola;
52
+ } //#endregion
53
+ //#region consola/constants.d.ts
53
54
  type LogLevel = 0 | 1 | 2 | 3 | 4 | 5 | (number & {});
54
55
  declare const LogLevels: Record<LogType, number>;
55
56
  type LogType = 'silent' | 'fatal' | 'error' | 'warn' | 'log' | 'info' | 'success' | 'fail' | 'ready' | 'start' | 'box' | 'debug' | 'trace' | 'verbose';
56
57
  declare const LogTypes: Record<LogType, Partial<LogObject>>;
57
58
 
59
+ //#endregion
60
+ //#region consola/consola.d.ts
58
61
  declare class Consola {
59
- options: ConsolaOptions;
60
- _lastLog: {
61
- serialized?: string;
62
- object?: LogObject;
63
- count?: number;
64
- time?: Date;
65
- timeout?: ReturnType<typeof setTimeout>;
66
- };
67
- _mockFn?: ConsolaOptions['mockFn'];
68
- constructor(options?: Partial<ConsolaOptions>);
69
- get level(): LogLevel;
70
- set level(level: LogLevel);
71
- create(options: Partial<ConsolaOptions>): ConsolaInstance;
72
- withDefaults(defaults: InputLogObject): ConsolaInstance;
73
- withTag(tag: string): ConsolaInstance;
74
- addReporter(reporter: ConsolaReporter): this;
75
- removeReporter(reporter: ConsolaReporter): ConsolaReporter[] | this;
76
- setReporters(reporters: ConsolaReporter[]): this;
77
- wrapAll(): void;
78
- restoreAll(): void;
79
- wrapConsole(): void;
80
- restoreConsole(): void;
81
- wrapStd(): void;
82
- _wrapStream(stream: NodeJS.WriteStream | undefined, type: LogType): void;
83
- restoreStd(): void;
84
- _restoreStream(stream?: NodeJS.WriteStream): void;
85
- pauseLogs(): void;
86
- resumeLogs(): void;
87
- mockTypes(mockFn?: ConsolaOptions['mockFn']): void;
88
- _wrapLogFn(defaults: InputLogObject, isRaw?: boolean): (...args: any[]) => false | undefined;
89
- _logFn(defaults: InputLogObject, args: any[], isRaw?: boolean): false | undefined;
90
- _log(logObj: LogObject): void;
62
+ options: ConsolaOptions;
63
+ _lastLog: {
64
+ serialized?: string;
65
+ object?: LogObject;
66
+ count?: number;
67
+ time?: Date;
68
+ timeout?: ReturnType<typeof setTimeout>;
69
+ };
70
+ _mockFn?: ConsolaOptions['mockFn'];
71
+ constructor(options?: Partial<ConsolaOptions>);
72
+ get level(): LogLevel;
73
+ set level(level: LogLevel);
74
+ create(options: Partial<ConsolaOptions>): ConsolaInstance;
75
+ withDefaults(defaults: InputLogObject): ConsolaInstance;
76
+ withTag(tag: string): ConsolaInstance;
77
+ addReporter(reporter: ConsolaReporter): this;
78
+ removeReporter(reporter: ConsolaReporter): this | ConsolaReporter[];
79
+ setReporters(reporters: ConsolaReporter[]): this;
80
+ wrapAll(): void;
81
+ restoreAll(): void;
82
+ wrapConsole(): void;
83
+ restoreConsole(): void;
84
+ wrapStd(): void;
85
+ _wrapStream(stream: NodeJS.WriteStream | undefined, type: LogType): void;
86
+ restoreStd(): void;
87
+ _restoreStream(stream?: NodeJS.WriteStream): void;
88
+ pauseLogs(): void;
89
+ resumeLogs(): void;
90
+ mockTypes(mockFn?: ConsolaOptions['mockFn']): void;
91
+ _wrapLogFn(defaults: InputLogObject, isRaw?: boolean): (...args: any[]) => false | undefined;
92
+ _logFn(defaults: InputLogObject, args: any[], isRaw?: boolean): false | undefined;
93
+ _log(logObj: LogObject): void;
91
94
  }
92
95
  interface LogFn {
93
- (message: InputLogObject | any, ...args: any[]): void;
94
- raw: (...args: any[]) => void;
96
+ (message: InputLogObject | any, ...args: any[]): void;
97
+ raw: (...args: any[]) => void;
95
98
  }
96
99
  type ConsolaInstance = Consola & Record<LogType, LogFn>;
97
100
 
101
+ //#endregion
102
+ //#region consola/index.d.ts
98
103
  declare function createConsola(options?: Partial<ConsolaOptions & {
99
- fancy: boolean;
104
+ fancy: boolean;
100
105
  }>): ConsolaInstance;
101
106
  declare const consola: ConsolaInstance;
102
107
 
108
+ //#endregion
109
+ //#region consola/reporters/basic.d.ts
103
110
  declare class BasicReporter implements ConsolaReporter {
104
- formatStack(stack: string, opts: FormatOptions): string;
105
- formatArgs(args: any[], opts: FormatOptions): string;
106
- formatDate(date: Date, opts: FormatOptions): string;
107
- filterAndJoin(arr: any[]): string;
108
- formatLogObj(logObj: LogObject, opts: FormatOptions): string;
109
- log(logObj: LogObject, ctx: {
110
- options: ConsolaOptions;
111
- }): any;
111
+ formatStack(stack: string, _opts: FormatOptions): string;
112
+ formatArgs(args: any[], opts: FormatOptions): string;
113
+ formatDate(date: Date, opts: FormatOptions): string;
114
+ filterAndJoin(arr: any[]): string;
115
+ formatLogObj(logObj: LogObject, opts: FormatOptions): string;
116
+ log(logObj: LogObject, ctx: {
117
+ options: ConsolaOptions;
118
+ }): any;
112
119
  }
113
120
 
114
- declare const TYPE_COLOR_MAP: {
115
- [k in LogType]?: string;
116
- };
117
- declare const LEVEL_COLOR_MAP: {
118
- [k in LogLevel]?: string;
119
- };
121
+ //#endregion
122
+ //#region consola/reporters/fancy.d.ts
123
+ declare const TYPE_COLOR_MAP: Partial<Record<LogType, string>>;
124
+ declare const LEVEL_COLOR_MAP: Partial<Record<LogLevel, string>>;
120
125
  declare class FancyReporter extends BasicReporter {
121
- formatStack(stack: string): string;
122
- formatType(logObj: LogObject, isBadge: boolean, opts: FormatOptions): any;
123
- formatLogObj(logObj: LogObject, opts: FormatOptions): string;
126
+ formatStack(stack: string): string;
127
+ formatType(logObj: LogObject, isBadge: boolean, _opts: FormatOptions): any;
128
+ formatLogObj(logObj: LogObject, opts: FormatOptions): string;
124
129
  }
125
130
 
131
+ //#endregion
132
+ //#region consola/reporters/logger.d.ts
126
133
  declare class LoggerReporter extends FancyReporter {
127
- private latestLogTime;
128
- formatDate(date: Date, opts: FormatOptions): string;
129
- formatLogObj(logObj: LogObject, opts: FormatOptions): string;
134
+ private latestLogTime;
135
+ formatDate(date: Date, opts: FormatOptions): string;
136
+ formatLogObj(logObj: LogObject, opts: FormatOptions): string;
130
137
  }
131
138
 
139
+ //#endregion
140
+ //#region consola/reporters/file.d.ts
132
141
  interface FileReporterConfig {
133
- loggerDir: string;
134
- /**
135
- * @default 'stdout_%d%.log'
136
- */
137
- stdoutFileFormat?: string;
138
- /**
139
- * @default 'error.log'
140
- */
141
- stderrFileFormat?: string;
142
- /**
143
- * refresh logger file stream
144
- * @default '0 0 * * *'
145
- */
146
- cron?: string;
147
- /**
148
- * Error log will be written to stdout and stderr
149
- * @default false
150
- */
151
- errWriteToStdout?: boolean;
142
+ loggerDir: string;
143
+ /**
144
+ * @default 'stdout_%d%.log'
145
+ */
146
+ stdoutFileFormat?: string;
147
+ /**
148
+ * @default 'error.log'
149
+ */
150
+ stderrFileFormat?: string;
151
+ /**
152
+ * refresh logger file stream
153
+ * @default '0 0 * * *'
154
+ */
155
+ cron?: string;
156
+ /**
157
+ * Error log will be written to stdout and stderr
158
+ * @default false
159
+ */
160
+ errWriteToStdout?: boolean;
152
161
  }
153
162
  declare class FileReporter extends LoggerReporter {
154
- private readonly configs;
155
- constructor(configs: FileReporterConfig);
156
- private stdoutStream?;
157
- private stderrStream?;
158
- private __job?;
159
- private scheduleRefreshWriteStream;
160
- teardown(): void;
161
- private refreshWriteStream;
162
- log(logObj: LogObject, ctx: {
163
- options: ConsolaOptions;
164
- }): any;
163
+ private readonly configs;
164
+ constructor(configs: FileReporterConfig);
165
+ private stdoutStream?;
166
+ private stderrStream?;
167
+ private __job?;
168
+ private scheduleRefreshWriteStream;
169
+ teardown(): void;
170
+ private refreshWriteStream;
171
+ log(logObj: LogObject, ctx: {
172
+ options: ConsolaOptions;
173
+ }): any;
165
174
  }
166
175
 
176
+ //#endregion
177
+ //#region consola.instance.d.ts
167
178
  interface LoggerConsolaOptions extends Partial<ConsolaOptions> {
168
- writeToFile?: FileReporterConfig;
179
+ writeToFile?: FileReporterConfig;
169
180
  }
170
- declare const createLoggerConsola: (options?: LoggerConsolaOptions) => WrappedConsola;
181
+ declare function createLoggerConsola(options?: LoggerConsolaOptions): WrappedConsola;
171
182
 
183
+ //#endregion
184
+ //#region consola/reporters/browser.d.ts
172
185
  declare class BrowserReporter {
173
- options: any;
174
- defaultColor: string;
175
- levelColorMap: Record<number, string>;
176
- typeColorMap: Record<string, string>;
177
- constructor(options: any);
178
- _getLogFn(level: number): any;
179
- log(logObj: LogObject): void;
186
+ options: any;
187
+ defaultColor: string;
188
+ levelColorMap: Record<number, string>;
189
+ typeColorMap: Record<string, string>;
190
+ constructor(options: any);
191
+ _getLogFn(level: number): any;
192
+ log(logObj: LogObject): void;
180
193
  }
181
194
 
182
- declare const wrapperSubscribers: (consola: ConsolaInstance) => WrappedConsola;
195
+ //#endregion
196
+ //#region consola/reporters/subscriber.d.ts
197
+ declare function wrapperSubscribers(consola: ConsolaInstance): WrappedConsola;
183
198
  declare class SubscriberReporter extends LoggerReporter {
184
- static subscriber: EventEmitter;
185
- log(logObj: LogObject, ctx: {
186
- options: ConsolaOptions;
187
- }): void;
199
+ static subscriber: EventEmitter<[never]>;
200
+ log(logObj: LogObject, ctx: {
201
+ options: ConsolaOptions;
202
+ }): void;
188
203
  }
189
204
 
190
- export { BasicReporter, BrowserReporter, Consola, type ConsolaInstance, type ConsolaOptions, type ConsolaReporter, FancyReporter, FileReporter, type FileReporterConfig, type FormatOptions, type InputLogObject, LEVEL_COLOR_MAP, type LogLevel, LogLevels, type LogObject, type LogType, LogTypes, type LoggerConsolaOptions, LoggerReporter, SubscriberReporter, TYPE_COLOR_MAP, type WrappedConsola, consola, createConsola, createLoggerConsola, wrapperSubscribers };
205
+ //#endregion
206
+ export { BasicReporter, BrowserReporter, Consola, ConsolaInstance, ConsolaOptions, ConsolaReporter, FancyReporter, FileReporter, FileReporterConfig, FormatOptions, InputLogObject, LEVEL_COLOR_MAP, LogLevel, LogLevels, LogObject, LogType, LogTypes, LoggerConsolaOptions, LoggerReporter, SubscriberReporter, TYPE_COLOR_MAP, WrappedConsola, consola, createConsola, createLoggerConsola, wrapperSubscribers };