standard-log 12.1.2 → 13.0.1
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/README.md +8 -8
- package/cjs/_virtual/_rolldown/runtime.js +23 -0
- package/cjs/console.d.ts +10 -7
- package/cjs/console.d.ts.map +1 -1
- package/cjs/console.js +53 -71
- package/cjs/console.js.map +1 -1
- package/cjs/errors.d.ts +9 -6
- package/cjs/errors.d.ts.map +1 -1
- package/cjs/errors.js +22 -45
- package/cjs/errors.js.map +1 -1
- package/cjs/formatter.d.ts +9 -6
- package/cjs/formatter.d.ts.map +1 -1
- package/cjs/formatter.js +41 -50
- package/cjs/formatter.js.map +1 -1
- package/cjs/index.d.ts +8 -9
- package/cjs/index.js +26 -28
- package/cjs/log_levels.d.ts +76 -73
- package/cjs/log_levels.d.ts.map +1 -1
- package/cjs/log_levels.js +104 -110
- package/cjs/log_levels.js.map +1 -1
- package/cjs/log_store.d.ts +20 -17
- package/cjs/log_store.d.ts.map +1 -1
- package/cjs/log_store.js +43 -39
- package/cjs/log_store.js.map +1 -1
- package/cjs/logger.d.ts +6 -3
- package/cjs/logger.d.ts.map +1 -1
- package/cjs/logger.js +66 -88
- package/cjs/logger.js.map +1 -1
- package/cjs/memory.d.ts +20 -17
- package/cjs/memory.d.ts.map +1 -1
- package/cjs/memory.js +54 -64
- package/cjs/memory.js.map +1 -1
- package/cjs/platform.browser.d.ts +7 -4
- package/cjs/platform.browser.d.ts.map +1 -1
- package/cjs/platform.browser.js +8 -6
- package/cjs/platform.browser.js.map +1 -1
- package/cjs/platform.d.ts +7 -4
- package/cjs/platform.d.ts.map +1 -1
- package/cjs/platform.js +9 -7
- package/cjs/platform.js.map +1 -1
- package/cjs/standard_log.ctx.d.ts +11 -8
- package/cjs/standard_log.ctx.d.ts.map +1 -1
- package/cjs/standard_log.ctx.js +6 -5
- package/cjs/standard_log.ctx.js.map +1 -1
- package/cjs/standard_log.d.ts +14 -12
- package/cjs/standard_log.d.ts.map +1 -1
- package/cjs/standard_log.js +83 -112
- package/cjs/standard_log.js.map +1 -1
- package/cjs/standard_log.testing.d.ts +16 -13
- package/cjs/standard_log.testing.d.ts.map +1 -1
- package/cjs/standard_log.testing.js +19 -35
- package/cjs/standard_log.testing.js.map +1 -1
- package/cjs/testing/index.d.ts +3 -3
- package/cjs/testing/index.js +3 -6
- package/cjs/types.d.ts +125 -124
- package/cjs/types.d.ts.map +1 -1
- package/cjs/types.js +0 -3
- package/dist/standard-log.esm.js +873 -1430
- package/dist/standard-log.esm.js.map +1 -1
- package/dist/standard-log.iife.js +952 -0
- package/dist/standard-log.iife.js.map +1 -0
- package/esm/console.d.ts +10 -7
- package/esm/console.d.ts.map +1 -1
- package/esm/console.js +54 -64
- package/esm/console.js.map +1 -1
- package/esm/errors.d.ts +9 -6
- package/esm/errors.d.ts.map +1 -1
- package/esm/errors.js +21 -21
- package/esm/errors.js.map +1 -1
- package/esm/formatter.d.ts +9 -6
- package/esm/formatter.d.ts.map +1 -1
- package/esm/formatter.js +38 -32
- package/esm/formatter.js.map +1 -1
- package/esm/index.d.ts +8 -9
- package/esm/index.js +7 -7
- package/esm/log_levels.d.ts +76 -73
- package/esm/log_levels.d.ts.map +1 -1
- package/esm/log_levels.js +102 -107
- package/esm/log_levels.js.map +1 -1
- package/esm/log_store.d.ts +20 -17
- package/esm/log_store.d.ts.map +1 -1
- package/esm/log_store.js +44 -37
- package/esm/log_store.js.map +1 -1
- package/esm/logger.d.ts +6 -3
- package/esm/logger.d.ts.map +1 -1
- package/esm/logger.js +66 -65
- package/esm/logger.js.map +1 -1
- package/esm/memory.d.ts +20 -17
- package/esm/memory.d.ts.map +1 -1
- package/esm/memory.js +55 -62
- package/esm/memory.js.map +1 -1
- package/esm/platform.browser.d.ts +7 -4
- package/esm/platform.browser.d.ts.map +1 -1
- package/esm/platform.browser.js +7 -3
- package/esm/platform.browser.js.map +1 -1
- package/esm/platform.d.ts +7 -4
- package/esm/platform.d.ts.map +1 -1
- package/esm/platform.js +8 -4
- package/esm/platform.js.map +1 -1
- package/esm/standard_log.ctx.d.ts +11 -8
- package/esm/standard_log.ctx.d.ts.map +1 -1
- package/esm/standard_log.ctx.js +6 -2
- package/esm/standard_log.ctx.js.map +1 -1
- package/esm/standard_log.d.ts +14 -12
- package/esm/standard_log.d.ts.map +1 -1
- package/esm/standard_log.js +83 -98
- package/esm/standard_log.js.map +1 -1
- package/esm/standard_log.testing.d.ts +16 -13
- package/esm/standard_log.testing.d.ts.map +1 -1
- package/esm/standard_log.testing.js +19 -20
- package/esm/standard_log.testing.js.map +1 -1
- package/esm/testing/index.d.ts +3 -3
- package/esm/testing/index.js +2 -2
- package/esm/types.d.ts +125 -124
- package/esm/types.d.ts.map +1 -1
- package/esm/types.js +0 -1
- package/package.json +21 -67
- package/ts/console.ts +7 -8
- package/ts/errors.ts +5 -2
- package/ts/formatter.ts +1 -2
- package/ts/index.ts +3 -3
- package/ts/log_levels.ts +2 -2
- package/ts/logger.ts +14 -7
- package/ts/memory.ts +3 -5
- package/ts/platform.ts +1 -1
- package/ts/standard_log.ts +2 -2
- package/ts/testing/index.ts +3 -3
- package/ts/types.ts +1 -1
- package/cjs/index.d.ts.map +0 -1
- package/cjs/index.js.map +0 -1
- package/cjs/testing/index.d.ts.map +0 -1
- package/cjs/testing/index.js.map +0 -1
- package/cjs/types.js.map +0 -1
- package/dist/standard-log.es5.js +0 -10184
- package/dist/standard-log.es5.js.gz +0 -0
- package/dist/standard-log.es5.js.map +0 -1
- package/dist/standard-log.es5.js.map.gz +0 -0
- package/dist/standard-log.esm.js.gz +0 -0
- package/dist/standard-log.esm.js.map.gz +0 -0
- package/esm/index.d.ts.map +0 -1
- package/esm/index.js.map +0 -1
- package/esm/testing/index.d.ts.map +0 -1
- package/esm/testing/index.js.map +0 -1
- package/esm/types.js.map +0 -1
package/cjs/types.d.ts
CHANGED
|
@@ -1,144 +1,145 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { StackTraceMeta } from "@just-func/types";
|
|
2
|
+
//#region ts/types.d.ts
|
|
3
|
+
type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
|
|
4
|
+
/**
|
|
5
|
+
* A map of custom log levels.
|
|
6
|
+
*
|
|
7
|
+
* Each logger created will have a method for each custom level.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { createStandardLog } from 'standard-log'
|
|
11
|
+
*
|
|
12
|
+
* const sl = createStandardLog({ customLevels: { foo: 100 } })
|
|
13
|
+
* const logger = sl.getLogger('my-logger')
|
|
14
|
+
*
|
|
15
|
+
* logger.foo('Hello world!') // 2020-01-01T00:00:00.000Z my-logger (FOO) Hello world!
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
customLevels?: Record<CustomLevelNames, number>;
|
|
19
|
+
logLevel?: number;
|
|
20
|
+
reporters?: LogReporter[];
|
|
20
21
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
interface LoggerOptions extends StackTraceMeta {
|
|
23
|
+
level?: number;
|
|
24
|
+
writeTo?: LogReporter | ReporterFilter;
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} & {
|
|
42
|
-
[k in N]: LogMethod;
|
|
43
|
-
};
|
|
26
|
+
type Logger<N extends string = LogMethodNames> = {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
/**
|
|
29
|
+
* Logger local log level.
|
|
30
|
+
*/
|
|
31
|
+
level?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Logs with an increment counter.
|
|
34
|
+
* This is useful during debugging to check for steps executed.
|
|
35
|
+
*/
|
|
36
|
+
count(...args: any[]): void;
|
|
37
|
+
on(level: number | N, logFunction: LogFunction): void;
|
|
38
|
+
/**
|
|
39
|
+
* Write custom log entries.
|
|
40
|
+
*/
|
|
41
|
+
write(entry: LogEntry): void;
|
|
42
|
+
} & { [k in N]: LogMethod; };
|
|
44
43
|
/**
|
|
45
44
|
* Names of the standard log methods.
|
|
46
45
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
type LogMethodNames = 'emergency' | 'alert' | 'critical' | 'error' | 'warn' | 'notice' | 'info' | 'debug' | 'trace' | 'planck';
|
|
47
|
+
type LogEntry = {
|
|
48
|
+
id: string;
|
|
49
|
+
level: number;
|
|
50
|
+
args: any[];
|
|
51
|
+
timestamp: Date;
|
|
53
52
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
91
|
-
|
|
53
|
+
type LogMethod = (...args: any[]) => void;
|
|
54
|
+
type LogFunction = (log: LogMethod, logLevel: number) => string | undefined | void;
|
|
55
|
+
type ReporterFilter = string | RegExp | ((reporterId: string) => boolean);
|
|
56
|
+
interface StandardLogInstance<N extends string = LogMethodNames> {
|
|
57
|
+
/**
|
|
58
|
+
* The current log level.
|
|
59
|
+
*/
|
|
60
|
+
logLevel: number;
|
|
61
|
+
/**
|
|
62
|
+
* Convert log level number to log level name.
|
|
63
|
+
*/
|
|
64
|
+
toLogLevelName(level: number): string;
|
|
65
|
+
/**
|
|
66
|
+
* Convert log level name to log level number.
|
|
67
|
+
*/
|
|
68
|
+
toLogLevel(name: N): number;
|
|
69
|
+
/**
|
|
70
|
+
* Get a logger instance with the specified id.
|
|
71
|
+
*
|
|
72
|
+
* ```ts
|
|
73
|
+
* const logger = getLogger('my-logger')
|
|
74
|
+
*
|
|
75
|
+
* logger.info('Hello world!') // 2020-01-01T00:00:00.000Z my-logger (INFO) Hello world!
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
getLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>;
|
|
79
|
+
/**
|
|
80
|
+
* Get a non-console logger instance with the specified id.
|
|
81
|
+
*
|
|
82
|
+
* The resulting logger will only send to the reporters that are not console reporters.
|
|
83
|
+
*
|
|
84
|
+
* ```ts
|
|
85
|
+
* const logger = getNonConsoleLogger('my-logger')
|
|
86
|
+
*
|
|
87
|
+
* logger.info('Hello world!') // will not send to any console reporter
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
getNonConsoleLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>;
|
|
92
91
|
}
|
|
93
92
|
/**
|
|
94
93
|
* Formats a log entry.
|
|
95
94
|
* Depends on the reporter, it can expect a different return type.
|
|
96
95
|
* By default the return type is `any[]` which the `console` accepts.
|
|
97
96
|
*/
|
|
98
|
-
|
|
97
|
+
type LogFormatter<T = any[]> = (entry: LogEntry) => T;
|
|
99
98
|
/**
|
|
100
99
|
* Determines whether the entry should be written.
|
|
101
100
|
*/
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
type LogFilter = (entry: LogEntry) => boolean;
|
|
102
|
+
type LogLevelEntry = {
|
|
103
|
+
name: string;
|
|
104
|
+
level: number;
|
|
106
105
|
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
106
|
+
interface LogReporter<T = any> {
|
|
107
|
+
readonly id: string;
|
|
108
|
+
/**
|
|
109
|
+
* Specifies the formatter to be used by the reporter.
|
|
110
|
+
* Using this you can customize how the reporter writes the log entry.
|
|
111
|
+
*/
|
|
112
|
+
readonly formatter: LogFormatter<T>;
|
|
113
|
+
/**
|
|
114
|
+
* Specifies a filter to determine should the log be written.
|
|
115
|
+
*/
|
|
116
|
+
readonly filter?: LogFilter;
|
|
117
|
+
/**
|
|
118
|
+
* Indicates if this is a console reporter.
|
|
119
|
+
* There is only one console reporter can be present in the system.
|
|
120
|
+
*/
|
|
121
|
+
readonly isConsoleReporter?: boolean;
|
|
122
|
+
write(entry: LogEntry): void;
|
|
124
123
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
124
|
+
type LogReporterOptions<T = any> = {
|
|
125
|
+
id?: string;
|
|
126
|
+
/**
|
|
127
|
+
* Specifies the formatter to be used by the reporter.
|
|
128
|
+
* Using this you can customize how the reporter writes the log entry.
|
|
129
|
+
*/
|
|
130
|
+
formatter?: LogFormatter<T>;
|
|
131
|
+
/**
|
|
132
|
+
* Specifies a filter to determine should the log be written.
|
|
133
|
+
*/
|
|
134
|
+
filter?: LogFilter;
|
|
136
135
|
};
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
136
|
+
type LogLevel = number;
|
|
137
|
+
interface ConsoleLike {
|
|
138
|
+
debug(...args: any[]): void;
|
|
139
|
+
info(...args: any[]): void;
|
|
140
|
+
warn(...args: any[]): void;
|
|
141
|
+
error(...args: any[]): void;
|
|
143
142
|
}
|
|
143
|
+
//#endregion
|
|
144
|
+
export { ConsoleLike, LogEntry, LogFilter, LogFormatter, LogFunction, LogLevel, LogLevelEntry, LogMethod, LogMethodNames, LogReporter, LogReporterOptions, Logger, LoggerOptions, ReporterFilter, StandardLogInstance, StandardLogOptions };
|
|
144
145
|
//# sourceMappingURL=types.d.ts.map
|
package/cjs/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../ts/types.ts"],"mappings":";;KAEY,mBAAmB,kCAAkC;;;;;;;;;;;;;;;EAehE,eAAe,OAAO;EACtB;EACA,YAAY;;UAGI,sBAAsB;EACtC;EACA,UAAU,cAAc;;KAGb,OAAO,mBAAmB;WAC5B;;;;EAIT;;;;;EAKA,SAAS;EACT,GAAG,gBAAgB,GAAG,aAAa;;;;EAInC,MAAM,OAAO;OACP,KAAK,IAAI;;;;KAKJ;KAYA;EACX;EACA;EAEA;EACA,WAAW;;KAGA,gBAAgB;KAEhB,eAAe,KAAK,WAAW;KAE/B,0BAA0B,WAAW;UAEhC,oBAAoB,mBAAmB;;;;EAIvD;;;;EAIA,eAAe;;;;EAIf,WAAW,MAAM;;;;;;;;;;EAUjB,UAAU,YAAY,UAAU,gBAAgB,OAAO,IAAI;;;;;;;;;;;;EAY3D,oBAAoB,YAAY,UAAU,gBAAgB,OAAO,IAAI;;;;;;;KAQ1D,aAAa,cAAc,OAAO,aAAa;;;;KAK/C,aAAa,OAAO;KAEpB;EAAkB;EAAc;;UAE3B,YAAY;WACnB;;;;;WAKA,WAAW,aAAa;;;;WAIxB,SAAS;;;;;WAKT;EACT,MAAM,OAAO;;KAGF,mBAAmB;EAC9B;;;;;EAKA,YAAY,aAAa;;;;EAIzB,SAAS;;KAGE;UAEK;EAChB,SAAS;EACT,QAAQ;EACR,QAAQ;EACR,SAAS"}
|
package/cjs/types.js
CHANGED