standard-log 11.5.0 → 11.5.2
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/cjs/console.d.ts +3 -3
- package/cjs/console.d.ts.map +1 -1
- package/cjs/console.js +17 -8
- package/cjs/console.js.map +1 -1
- package/cjs/errors.d.ts.map +1 -1
- package/cjs/errors.js.map +1 -1
- package/cjs/formatter.d.ts +1 -1
- package/cjs/formatter.d.ts.map +1 -1
- package/cjs/formatter.js.map +1 -1
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/logLevels.d.ts.map +1 -1
- package/cjs/logLevels.js.map +1 -1
- package/cjs/logStore.d.ts.map +1 -1
- package/cjs/logStore.js.map +1 -1
- package/cjs/logger.d.ts.map +1 -1
- package/cjs/logger.js +15 -13
- package/cjs/logger.js.map +1 -1
- package/cjs/memory.d.ts +2 -2
- package/cjs/memory.d.ts.map +1 -1
- package/cjs/memory.js +15 -8
- package/cjs/memory.js.map +1 -1
- package/cjs/platform.d.ts.map +1 -1
- package/cjs/platform.js +1 -2
- package/cjs/platform.js.map +1 -1
- package/cjs/standardLog.ctx.d.ts.map +1 -1
- package/cjs/standardLog.ctx.js.map +1 -1
- package/cjs/standardLog.d.ts +2 -2
- package/cjs/standardLog.d.ts.map +1 -1
- package/cjs/standardLog.js +19 -14
- package/cjs/standardLog.js.map +1 -1
- package/cjs/types.d.ts +12 -12
- package/cjs/types.d.ts.map +1 -1
- package/cjs/types.js.map +1 -1
- package/dist/standard-log.es5.js +1190 -801
- package/dist/standard-log.es5.js.gz +0 -0
- package/dist/standard-log.es5.js.map +1 -1
- package/dist/standard-log.es5.js.map.gz +0 -0
- package/dist/standard-log.esm.js +173 -119
- package/dist/standard-log.esm.js.gz +0 -0
- package/dist/standard-log.esm.js.map +1 -1
- package/dist/standard-log.esm.js.map.gz +0 -0
- package/esm/console.d.ts +3 -3
- package/esm/console.d.ts.map +1 -1
- package/esm/console.js +20 -9
- package/esm/console.js.map +1 -1
- package/esm/errors.d.ts.map +1 -1
- package/esm/errors.js.map +1 -1
- package/esm/formatter.d.ts +1 -1
- package/esm/formatter.d.ts.map +1 -1
- package/esm/formatter.js.map +1 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js.map +1 -1
- package/esm/logLevels.d.ts.map +1 -1
- package/esm/logLevels.js.map +1 -1
- package/esm/logStore.d.ts.map +1 -1
- package/esm/logStore.js.map +1 -1
- package/esm/logger.d.ts.map +1 -1
- package/esm/logger.js +1 -1
- package/esm/logger.js.map +1 -1
- package/esm/memory.d.ts +2 -2
- package/esm/memory.d.ts.map +1 -1
- package/esm/memory.js +15 -8
- package/esm/memory.js.map +1 -1
- package/esm/platform.d.ts.map +1 -1
- package/esm/platform.js +1 -2
- package/esm/platform.js.map +1 -1
- package/esm/standardLog.ctx.d.ts.map +1 -1
- package/esm/standardLog.ctx.js.map +1 -1
- package/esm/standardLog.d.ts +2 -2
- package/esm/standardLog.d.ts.map +1 -1
- package/esm/standardLog.js +23 -18
- package/esm/standardLog.js.map +1 -1
- package/esm/types.d.ts +12 -12
- package/esm/types.d.ts.map +1 -1
- package/esm/types.js.map +1 -1
- package/package.json +17 -9
- package/ts/console.ts +54 -45
- package/ts/errors.ts +6 -6
- package/ts/formatter.ts +18 -18
- package/ts/index.ts +21 -6
- package/ts/logLevels.ts +90 -91
- package/ts/logStore.ts +46 -37
- package/ts/logger.ts +67 -57
- package/ts/memory.ts +66 -54
- package/ts/platform.ts +2 -2
- package/ts/standardLog.ctx.ts +2 -2
- package/ts/standardLog.ts +113 -94
- package/ts/types.ts +72 -62
package/ts/types.ts
CHANGED
|
@@ -1,45 +1,55 @@
|
|
|
1
1
|
import type { StackTraceMeta } from '@just-func/types'
|
|
2
2
|
|
|
3
3
|
export type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
customLevels?: Record<CustomLevelNames, number>
|
|
5
|
+
logLevel?: number
|
|
6
|
+
reporters?: LogReporter[]
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export interface LoggerOptions extends StackTraceMeta {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
level?: number
|
|
11
|
+
writeTo?: LogReporter | ReporterFilter
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export type Logger<N extends string = LogMethodNames> = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
15
|
+
readonly id: string
|
|
16
|
+
/**
|
|
17
|
+
* Logger local log level.
|
|
18
|
+
*/
|
|
19
|
+
level?: number
|
|
20
|
+
/**
|
|
21
|
+
* Logs with an increment counter.
|
|
22
|
+
* This is useful during debugging to check for steps executed.
|
|
23
|
+
*/
|
|
24
|
+
count(...args: any[]): void
|
|
25
|
+
on(level: number | N, logFunction: LogFunction): void
|
|
26
|
+
/**
|
|
27
|
+
* Write custom log entries.
|
|
28
|
+
*/
|
|
29
|
+
write(entry: LogEntry): void
|
|
30
30
|
} & { [k in N]: LogMethod }
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Names of the standard log methods.
|
|
34
34
|
*/
|
|
35
|
-
export type LogMethodNames =
|
|
35
|
+
export type LogMethodNames =
|
|
36
|
+
| 'emergency'
|
|
37
|
+
| 'alert'
|
|
38
|
+
| 'critical'
|
|
39
|
+
| 'error'
|
|
40
|
+
| 'warn'
|
|
41
|
+
| 'notice'
|
|
42
|
+
| 'info'
|
|
43
|
+
| 'debug'
|
|
44
|
+
| 'trace'
|
|
45
|
+
| 'planck'
|
|
36
46
|
|
|
37
47
|
export type LogEntry = {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
id: string
|
|
49
|
+
level: number
|
|
50
|
+
// args instead of messages because it is `any[]` instead of `string[]`
|
|
51
|
+
args: any[]
|
|
52
|
+
timestamp: Date
|
|
43
53
|
}
|
|
44
54
|
|
|
45
55
|
export type LogMethod = (...args: any[]) => void
|
|
@@ -49,11 +59,11 @@ export type LogFunction = (log: LogMethod, logLevel: number) => string | void
|
|
|
49
59
|
export type ReporterFilter = string | RegExp | ((reporterId: string) => boolean)
|
|
50
60
|
|
|
51
61
|
export interface StandardLogInstance<N extends string = LogMethodNames> {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
logLevel: number
|
|
63
|
+
toLogLevelName(level: number): string
|
|
64
|
+
toLogLevel(name: N): number
|
|
65
|
+
getLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>
|
|
66
|
+
getNonConsoleLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>
|
|
57
67
|
}
|
|
58
68
|
|
|
59
69
|
/**
|
|
@@ -68,45 +78,45 @@ export type LogFormatter<T = any[]> = (entry: LogEntry) => T
|
|
|
68
78
|
*/
|
|
69
79
|
export type LogFilter = (entry: LogEntry) => boolean
|
|
70
80
|
|
|
71
|
-
export type LogLevelEntry = { name: string
|
|
81
|
+
export type LogLevelEntry = { name: string; level: number }
|
|
72
82
|
|
|
73
83
|
export interface LogReporter<T = any> {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
readonly id: string
|
|
85
|
+
/**
|
|
86
|
+
* Specifies the formatter to be used by the reporter.
|
|
87
|
+
* Using this you can customize how the reporter writes the log entry.
|
|
88
|
+
*/
|
|
89
|
+
readonly formatter: LogFormatter<T>
|
|
90
|
+
/**
|
|
91
|
+
* Specifies a filter to determine should the log be written.
|
|
92
|
+
*/
|
|
93
|
+
readonly filter?: LogFilter
|
|
94
|
+
/**
|
|
95
|
+
* Indicate if this is a console reporter.
|
|
96
|
+
* There is only one console reporter can be present in the system.
|
|
97
|
+
*/
|
|
98
|
+
readonly isConsoleReporter?: boolean
|
|
99
|
+
write(entry: LogEntry): void
|
|
90
100
|
}
|
|
91
101
|
|
|
92
102
|
export type LogReporterOptions<T = any> = {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
id?: string
|
|
104
|
+
/**
|
|
105
|
+
* Specifies the formatter to be used by the reporter.
|
|
106
|
+
* Using this you can customize how the reporter writes the log entry.
|
|
107
|
+
*/
|
|
108
|
+
formatter?: LogFormatter<T>
|
|
109
|
+
/**
|
|
110
|
+
* Specifies a filter to determine should the log be written.
|
|
111
|
+
*/
|
|
112
|
+
filter?: LogFilter
|
|
103
113
|
}
|
|
104
114
|
|
|
105
115
|
export type LogLevel = number
|
|
106
116
|
|
|
107
117
|
export interface ConsoleLike {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
118
|
+
debug(...args: any[]): void
|
|
119
|
+
info(...args: any[]): void
|
|
120
|
+
warn(...args: any[]): void
|
|
121
|
+
error(...args: any[]): void
|
|
112
122
|
}
|