@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/consola/consola.ts +15 -15
- package/consola/constants.ts +0 -1
- package/consola/index.ts +3 -3
- package/consola/reporters/basic.ts +2 -2
- package/consola/reporters/browser.ts +1 -0
- package/consola/reporters/fancy.ts +8 -8
- package/consola/reporters/file.ts +7 -6
- package/consola/reporters/logger.ts +4 -4
- package/consola/reporters/subscriber.ts +4 -5
- package/consola/shared.ts +3 -4
- package/consola/utils/string.ts +6 -1
- package/consola/utils.ts +3 -3
- package/consola.instance.ts +3 -3
- package/dist/index.d.mts +153 -137
- package/dist/index.d.ts +153 -137
- package/dist/index.js +821 -1064
- package/dist/index.mjs +817 -1022
- package/index.ts +1 -1
- package/package.json +7 -7
- package/tool.util.ts +7 -16
- package/{tsup.config.ts → tsdown.config.ts} +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,190 +1,206 @@
|
|
|
1
|
-
import EventEmitter from
|
|
1
|
+
import EventEmitter from "node:events";
|
|
2
2
|
|
|
3
|
+
//#region consola/types.d.ts
|
|
3
4
|
interface ConsolaOptions {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
columns?: number;
|
|
21
|
+
date?: boolean;
|
|
22
|
+
colors?: boolean;
|
|
23
|
+
compact?: boolean | number;
|
|
24
|
+
[key: string]: unknown;
|
|
24
25
|
}
|
|
25
26
|
interface InputLogObject {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
log: (logObj: LogObject, ctx: {
|
|
45
|
+
options: ConsolaOptions;
|
|
46
|
+
}) => void;
|
|
46
47
|
}
|
|
47
48
|
interface WrappedConsola extends ConsolaInstance {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
94
|
-
|
|
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
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
115
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
-
|
|
179
|
+
writeToFile?: FileReporterConfig;
|
|
169
180
|
}
|
|
170
|
-
declare
|
|
181
|
+
declare function createLoggerConsola(options?: LoggerConsolaOptions): WrappedConsola;
|
|
171
182
|
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region consola/reporters/browser.d.ts
|
|
172
185
|
declare class BrowserReporter {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
-
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region consola/reporters/subscriber.d.ts
|
|
197
|
+
declare function wrapperSubscribers(consola: ConsolaInstance): WrappedConsola;
|
|
183
198
|
declare class SubscriberReporter extends LoggerReporter {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
199
|
+
static subscriber: EventEmitter<[never]>;
|
|
200
|
+
log(logObj: LogObject, ctx: {
|
|
201
|
+
options: ConsolaOptions;
|
|
202
|
+
}): void;
|
|
188
203
|
}
|
|
189
204
|
|
|
190
|
-
|
|
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 };
|