@darksheep/logger 1.3.0 → 1.4.0
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/CHANGELOG.md +23 -0
- package/README.md +36 -16
- package/package.json +7 -5
- package/src/create-logger.js +5 -5
- package/src/formatters/formatter-console/stack.js +1 -1
- package/src/formatters/formatter-console.js +2 -2
- package/src/index.js +17 -7
- package/src/logger.js +43 -38
- package/src/replacer.js +25 -21
- package/src/replacers/buffers.js +5 -1
- package/src/replacers/error.js +5 -2
- package/src/replacers/http-client-request.js +5 -1
- package/src/replacers/http-incoming-message.js +7 -2
- package/src/replacers/http-server-response.js +5 -1
- package/src/replacers/index.js +1 -1
- package/src/replacers/long-strings.js +5 -1
- package/src/replacers/net-socket.js +5 -1
- package/src/replacers/secrets.js +106 -13
- package/src/utilities/environment.js +25 -3
- package/src/utilities/legacy-secrets.js +36 -0
- package/src/utilities/log-types.js +12 -4
- package/src/utilities/parse-filters.js +3 -3
- package/src/utilities/parse-log-level.js +5 -1
- package/src/utilities/resource-usage.js +9 -6
- package/types/create-logger.d.ts +3 -2
- package/types/formatter.d.ts +2 -2
- package/types/formatters/formatter-console/stack.d.ts +15 -11
- package/types/formatters/formatter-console.d.ts +2 -2
- package/types/formatters/formatter-json.d.ts +1 -1
- package/types/index.d.ts +26 -11
- package/types/logger.d.ts +150 -61
- package/types/replacer.d.ts +16 -16
- package/types/replacers/buffers.d.ts +6 -2
- package/types/replacers/error.d.ts +13 -12
- package/types/replacers/http-client-request.d.ts +6 -2
- package/types/replacers/http-incoming-message.d.ts +11 -5
- package/types/replacers/http-server-response.d.ts +6 -2
- package/types/replacers/index.d.ts +8 -8
- package/types/replacers/long-strings.d.ts +6 -2
- package/types/replacers/net-socket.d.ts +6 -2
- package/types/replacers/secrets.d.ts +8 -4
- package/types/stdout-write.d.ts +1 -1
- package/types/utilities/colour.d.ts +30 -30
- package/types/utilities/environment.d.ts +14 -22
- package/types/utilities/json-path.d.ts +1 -1
- package/types/utilities/last-callsite.d.ts +1 -1
- package/types/utilities/legacy-secrets.d.ts +33 -0
- package/types/utilities/log-filters.d.ts +2 -2
- package/types/utilities/log-types.d.ts +30 -4
- package/types/utilities/parse-filters.d.ts +1 -1
- package/types/utilities/parse-log-level.d.ts +6 -2
- package/types/utilities/resource-usage.d.ts +2 -2
- package/types/utilities/stacktrace.d.ts +15 -15
package/types/logger.d.ts
CHANGED
|
@@ -1,40 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import { LogLevel, LogContext, LogEntry} from './utilities/log-types.js'
|
|
3
|
+
* @import { Replacer } from './replacer.js';
|
|
4
|
+
*/
|
|
5
|
+
import type { LogLevel, LogContext } from './utilities/log-types.js';
|
|
6
|
+
import type { Replacer } from './replacer.js';
|
|
7
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
8
|
+
import { formatter } from './formatter.js';
|
|
9
|
+
import { replace } from './replacer.js';
|
|
10
|
+
import { stdoutWrite } from './stdout-write.js';
|
|
11
|
+
export type Options = {
|
|
12
|
+
/**
|
|
13
|
+
* - The replacer function to use.
|
|
14
|
+
*/
|
|
15
|
+
replace?: typeof replace;
|
|
16
|
+
/**
|
|
17
|
+
* - The replacers to use in the replacer.
|
|
18
|
+
*/
|
|
19
|
+
replacers?: Replacer[];
|
|
20
|
+
/**
|
|
21
|
+
* - The formatter function to use (eg console or json formatter).
|
|
22
|
+
*/
|
|
23
|
+
format?: typeof formatter;
|
|
24
|
+
/**
|
|
25
|
+
* - The place to write the log to.
|
|
26
|
+
*/
|
|
27
|
+
write?: typeof stdoutWrite;
|
|
28
|
+
};
|
|
1
29
|
/**
|
|
2
30
|
* @typedef {Object} Options
|
|
3
31
|
* @property {typeof replace} [replace] - The replacer function to use.
|
|
4
|
-
* @property {
|
|
32
|
+
* @property {Replacer[]} [replacers] - The replacers to use in the replacer.
|
|
5
33
|
* @property {typeof formatter} [format] - The formatter function to use (eg console or json formatter).
|
|
6
34
|
* @property {typeof stdoutWrite} [write] - The place to write the log to.
|
|
7
35
|
*/
|
|
8
|
-
export class Logger {
|
|
9
|
-
|
|
10
|
-
|
|
36
|
+
export declare class Logger {
|
|
37
|
+
#private;
|
|
38
|
+
/** @type {AsyncLocalStorage<LogContext[]>} */
|
|
39
|
+
static storage: AsyncLocalStorage<LogContext[]>;
|
|
40
|
+
/** @type {Replacer[]} */
|
|
41
|
+
replacers: Replacer[];
|
|
11
42
|
/**
|
|
12
|
-
* @param {
|
|
43
|
+
* @param {LogContext} [context] - Context to add to the logger.
|
|
44
|
+
* @param {Options} [options] - Options for the loggers output.
|
|
45
|
+
*/
|
|
46
|
+
constructor(context?: LogContext, options?: Options);
|
|
47
|
+
/**
|
|
48
|
+
* @param {LogContext} context - Context to bind ot the async context.
|
|
13
49
|
* @returns {void}
|
|
14
50
|
*/
|
|
15
|
-
static addAsyncContext(context:
|
|
51
|
+
static addAsyncContext(context: LogContext): void;
|
|
16
52
|
/**
|
|
17
53
|
* @template [R=unknown]
|
|
18
54
|
* @overload
|
|
19
55
|
* @param {() => R} callback - The function to wrap the context in.
|
|
20
56
|
* @returns {R}
|
|
21
57
|
*/
|
|
58
|
+
/**
|
|
59
|
+
* @template [R=unknown]
|
|
60
|
+
* @overload
|
|
61
|
+
* @param {LogContext} context - Context to bind ot the async context.
|
|
62
|
+
* @param {() => R} callback - The function to wrap the context in.
|
|
63
|
+
* @returns {R}
|
|
64
|
+
*/
|
|
65
|
+
/**
|
|
66
|
+
* @template [R=unknown]
|
|
67
|
+
* @param {unknown} context - Context to bind ot the async context.
|
|
68
|
+
* @param {unknown} [callback] - The function to wrap the context in.
|
|
69
|
+
* @returns {R}
|
|
70
|
+
*/
|
|
22
71
|
static wrap<R = unknown>(callback: () => R): R;
|
|
23
72
|
/**
|
|
24
73
|
* @template [R=unknown]
|
|
25
74
|
* @overload
|
|
26
|
-
* @param {import('./utilities/log-types.js').LogContext} context - Context to bind ot the async context.
|
|
27
75
|
* @param {() => R} callback - The function to wrap the context in.
|
|
28
76
|
* @returns {R}
|
|
29
77
|
*/
|
|
30
|
-
static wrap<R = unknown>(context: import("./utilities/log-types.js").LogContext, callback: () => R): R;
|
|
31
78
|
/**
|
|
32
|
-
* @
|
|
33
|
-
* @
|
|
79
|
+
* @template [R=unknown]
|
|
80
|
+
* @overload
|
|
81
|
+
* @param {LogContext} context - Context to bind ot the async context.
|
|
82
|
+
* @param {() => R} callback - The function to wrap the context in.
|
|
83
|
+
* @returns {R}
|
|
34
84
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
85
|
+
/**
|
|
86
|
+
* @template [R=unknown]
|
|
87
|
+
* @param {unknown} context - Context to bind ot the async context.
|
|
88
|
+
* @param {unknown} [callback] - The function to wrap the context in.
|
|
89
|
+
* @returns {R}
|
|
90
|
+
*/
|
|
91
|
+
static wrap<R = unknown>(context: LogContext, callback: () => R): R;
|
|
38
92
|
/**
|
|
39
93
|
* Set the channel in the new logger.
|
|
40
94
|
* @param {string} channel - The channel name.
|
|
@@ -44,48 +98,106 @@ export class Logger {
|
|
|
44
98
|
/**
|
|
45
99
|
* Creating a new logger with {context, ...this.context}.
|
|
46
100
|
* @overload
|
|
47
|
-
* @param {
|
|
101
|
+
* @param {LogContext} context - The new context.
|
|
102
|
+
* @returns {Logger}
|
|
103
|
+
*/
|
|
104
|
+
/**
|
|
105
|
+
* Creating a new logger with {context, ...this.context}.
|
|
106
|
+
* @overload
|
|
107
|
+
* @param {LogContext} context - The new context.
|
|
108
|
+
* @param {LogLevel} level - The log level at which we allow this context.
|
|
109
|
+
* @returns {Logger}
|
|
110
|
+
*/
|
|
111
|
+
/**
|
|
112
|
+
* Creating a new logger with {context, ...this.context}.
|
|
113
|
+
* @overload
|
|
114
|
+
* @param {LogLevel} level - The log level at which we allow this context.
|
|
115
|
+
* @param {LogContext} context - The new context.
|
|
116
|
+
* @returns {Logger}
|
|
117
|
+
*/
|
|
118
|
+
/**
|
|
119
|
+
* Creating a new logger with {context, ...this.context}.
|
|
120
|
+
* @param {LogContext | LogLevel} contextOrLevel - The log level at which we allow this context.
|
|
121
|
+
* @param {LogLevel | LogContext} [levelOrContext] - The new context.
|
|
122
|
+
* @returns {Logger}
|
|
123
|
+
*/
|
|
124
|
+
context(context: LogContext): Logger;
|
|
125
|
+
/**
|
|
126
|
+
* Creating a new logger with {context, ...this.context}.
|
|
127
|
+
* @overload
|
|
128
|
+
* @param {LogContext} context - The new context.
|
|
129
|
+
* @returns {Logger}
|
|
130
|
+
*/
|
|
131
|
+
/**
|
|
132
|
+
* Creating a new logger with {context, ...this.context}.
|
|
133
|
+
* @overload
|
|
134
|
+
* @param {LogContext} context - The new context.
|
|
135
|
+
* @param {LogLevel} level - The log level at which we allow this context.
|
|
136
|
+
* @returns {Logger}
|
|
137
|
+
*/
|
|
138
|
+
/**
|
|
139
|
+
* Creating a new logger with {context, ...this.context}.
|
|
140
|
+
* @overload
|
|
141
|
+
* @param {LogLevel} level - The log level at which we allow this context.
|
|
142
|
+
* @param {LogContext} context - The new context.
|
|
143
|
+
* @returns {Logger}
|
|
144
|
+
*/
|
|
145
|
+
/**
|
|
146
|
+
* Creating a new logger with {context, ...this.context}.
|
|
147
|
+
* @param {LogContext | LogLevel} contextOrLevel - The log level at which we allow this context.
|
|
148
|
+
* @param {LogLevel | LogContext} [levelOrContext] - The new context.
|
|
48
149
|
* @returns {Logger}
|
|
49
150
|
*/
|
|
50
|
-
context(context:
|
|
151
|
+
context(context: LogContext, level: LogLevel): Logger;
|
|
51
152
|
/**
|
|
52
153
|
* Creating a new logger with {context, ...this.context}.
|
|
53
154
|
* @overload
|
|
54
|
-
* @param {
|
|
55
|
-
* @param {import('./utilities/log-types.js').LogLevel} level - The log level at which we allow this context.
|
|
155
|
+
* @param {LogContext} context - The new context.
|
|
56
156
|
* @returns {Logger}
|
|
57
157
|
*/
|
|
58
|
-
context(context: import("./utilities/log-types.js").LogContext, level: import("./utilities/log-types.js").LogLevel): Logger;
|
|
59
158
|
/**
|
|
60
159
|
* Creating a new logger with {context, ...this.context}.
|
|
61
160
|
* @overload
|
|
62
|
-
* @param {
|
|
63
|
-
* @param {
|
|
161
|
+
* @param {LogContext} context - The new context.
|
|
162
|
+
* @param {LogLevel} level - The log level at which we allow this context.
|
|
64
163
|
* @returns {Logger}
|
|
65
164
|
*/
|
|
66
|
-
|
|
165
|
+
/**
|
|
166
|
+
* Creating a new logger with {context, ...this.context}.
|
|
167
|
+
* @overload
|
|
168
|
+
* @param {LogLevel} level - The log level at which we allow this context.
|
|
169
|
+
* @param {LogContext} context - The new context.
|
|
170
|
+
* @returns {Logger}
|
|
171
|
+
*/
|
|
172
|
+
/**
|
|
173
|
+
* Creating a new logger with {context, ...this.context}.
|
|
174
|
+
* @param {LogContext | LogLevel} contextOrLevel - The log level at which we allow this context.
|
|
175
|
+
* @param {LogLevel | LogContext} [levelOrContext] - The new context.
|
|
176
|
+
* @returns {Logger}
|
|
177
|
+
*/
|
|
178
|
+
context(level: LogLevel, context: LogContext): Logger;
|
|
67
179
|
/**
|
|
68
180
|
* Write a log with the level 'critical' - A crucial part of the application is not working.
|
|
69
181
|
*
|
|
70
182
|
* @param {Error | string} message - The message to log.
|
|
71
|
-
* @param {
|
|
183
|
+
* @param {LogContext} [context] - Additional context.
|
|
72
184
|
* @returns {void}
|
|
73
185
|
*/
|
|
74
|
-
critical(message: Error | string, context?:
|
|
186
|
+
critical(message: Error | string, context?: LogContext): void;
|
|
75
187
|
/**
|
|
76
188
|
* Write a log with the level 'debug' - Information that is unlikely to help in production.
|
|
77
189
|
* @param {Error | string} message - The message to log.
|
|
78
|
-
* @param {
|
|
190
|
+
* @param {LogContext} [context] - Additional context.
|
|
79
191
|
* @returns {void}
|
|
80
192
|
*/
|
|
81
|
-
debug(message: Error | string, context?:
|
|
193
|
+
debug(message: Error | string, context?: LogContext): void;
|
|
82
194
|
/**
|
|
83
195
|
* Write a log with the level 'error' - A non critical operation fails.
|
|
84
196
|
* @param {Error | string} message - The message to log.
|
|
85
|
-
* @param {
|
|
197
|
+
* @param {LogContext} [context] - Additional context.
|
|
86
198
|
* @returns {void}
|
|
87
199
|
*/
|
|
88
|
-
error(message: Error | string, context?:
|
|
200
|
+
error(message: Error | string, context?: LogContext): void;
|
|
89
201
|
/**
|
|
90
202
|
* Get a value from the context by key.
|
|
91
203
|
* @param {string} key - The key to get from the context.
|
|
@@ -95,17 +207,17 @@ export class Logger {
|
|
|
95
207
|
/**
|
|
96
208
|
* Write a log with the level 'info' - Information about successful operations.
|
|
97
209
|
* @param {Error | string} message - The message to log.
|
|
98
|
-
* @param {
|
|
210
|
+
* @param {LogContext} [context] - Additional context.
|
|
99
211
|
* @returns {void}
|
|
100
212
|
*/
|
|
101
|
-
info(message: Error | string, context?:
|
|
213
|
+
info(message: Error | string, context?: LogContext): void;
|
|
102
214
|
/**
|
|
103
215
|
* Write a log with the level 'notice' - Information about events that may be unusual.
|
|
104
216
|
* @param {Error | string} message - The message to log.
|
|
105
|
-
* @param {
|
|
217
|
+
* @param {LogContext} [context] - Additional context.
|
|
106
218
|
* @returns {void}
|
|
107
219
|
*/
|
|
108
|
-
notice(message: Error | string, context?:
|
|
220
|
+
notice(message: Error | string, context?: LogContext): void;
|
|
109
221
|
/**
|
|
110
222
|
* Set a value into a new context by key.
|
|
111
223
|
* @param {string} key - The key to set.
|
|
@@ -116,10 +228,10 @@ export class Logger {
|
|
|
116
228
|
/**
|
|
117
229
|
* Write a log with the level 'silly' - Information to help resolve complex logic issues.
|
|
118
230
|
* @param {Error | string} message - The message to log.
|
|
119
|
-
* @param {
|
|
231
|
+
* @param {LogContext} [context] - Additional context.
|
|
120
232
|
* @returns {void}
|
|
121
233
|
*/
|
|
122
|
-
silly(message: Error | string, context?:
|
|
234
|
+
silly(message: Error | string, context?: LogContext): void;
|
|
123
235
|
/**
|
|
124
236
|
* Set the trail in the new logger.
|
|
125
237
|
* @param {string} [trail] - The trail id.
|
|
@@ -129,10 +241,10 @@ export class Logger {
|
|
|
129
241
|
/**
|
|
130
242
|
* Write a log with the level 'warning' - An operation might fail in the future.
|
|
131
243
|
* @param {Error | string} message - The message to log.
|
|
132
|
-
* @param {
|
|
244
|
+
* @param {LogContext} [context] - Additional context.
|
|
133
245
|
* @returns {void}
|
|
134
246
|
*/
|
|
135
|
-
warning(message: Error | string, context?:
|
|
247
|
+
warning(message: Error | string, context?: LogContext): void;
|
|
136
248
|
/**
|
|
137
249
|
* @template [R=unknown]
|
|
138
250
|
* @param {() => R} callback - The function to wrap the context in.
|
|
@@ -141,33 +253,10 @@ export class Logger {
|
|
|
141
253
|
wrap<R = unknown>(callback: () => R): R;
|
|
142
254
|
/**
|
|
143
255
|
* Write a new log entry.
|
|
144
|
-
* @param {
|
|
256
|
+
* @param {LogLevel} level - The log level of the message to log.
|
|
145
257
|
* @param {Error | string} message - The message to log.
|
|
146
|
-
* @param {
|
|
258
|
+
* @param {LogContext} [context] - Context to add to the log (merged with this.context, and Logger.contexts).
|
|
147
259
|
* @returns {void}
|
|
148
260
|
*/
|
|
149
|
-
write(level:
|
|
150
|
-
#private;
|
|
261
|
+
write(level: LogLevel, message: Error | string, context?: LogContext): void;
|
|
151
262
|
}
|
|
152
|
-
export type Options = {
|
|
153
|
-
/**
|
|
154
|
-
* - The replacer function to use.
|
|
155
|
-
*/
|
|
156
|
-
replace?: typeof replace;
|
|
157
|
-
/**
|
|
158
|
-
* - The replacers to use in the replacer.
|
|
159
|
-
*/
|
|
160
|
-
replacers?: import("./replacer.js").Replacer<any, any>[];
|
|
161
|
-
/**
|
|
162
|
-
* - The formatter function to use (eg console or json formatter).
|
|
163
|
-
*/
|
|
164
|
-
format?: typeof formatter;
|
|
165
|
-
/**
|
|
166
|
-
* - The place to write the log to.
|
|
167
|
-
*/
|
|
168
|
-
write?: typeof stdoutWrite;
|
|
169
|
-
};
|
|
170
|
-
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
171
|
-
import { replace } from './replacer.js';
|
|
172
|
-
import { formatter } from './formatter.js';
|
|
173
|
-
import { stdoutWrite } from './stdout-write.js';
|
package/types/replacer.d.ts
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @template [T=unknown]
|
|
3
|
-
* @template [O=unknown]
|
|
4
|
-
* @typedef {Object} Replacer
|
|
5
|
-
* @property {string} name - The name of the replacer.
|
|
6
|
-
* @property {(input: unknown, path?: string[]) => boolean} shouldReplace - Check to see if input can be replaced.
|
|
7
|
-
* @property {(input: T, path?: string[]) => O} replace - The replace function if shouldReplace returns true.
|
|
8
|
-
* @property {boolean} [stopHere] - Should the traverse stop here.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* @param {unknown} object - The object we're replacing.
|
|
12
|
-
* @param {Replacer[]} replacers - The Replacer array to execute.
|
|
13
|
-
* @returns {unknown}
|
|
14
|
-
*/
|
|
15
|
-
export function replace(object: unknown, replacers?: Replacer[]): unknown;
|
|
16
|
-
export type Replacer<T = unknown, O = unknown> = {
|
|
1
|
+
export type Replacer<T = any, O = unknown> = {
|
|
17
2
|
/**
|
|
18
3
|
* - The name of the replacer.
|
|
19
4
|
*/
|
|
@@ -31,3 +16,18 @@ export type Replacer<T = unknown, O = unknown> = {
|
|
|
31
16
|
*/
|
|
32
17
|
stopHere?: boolean;
|
|
33
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* @template [T=any]
|
|
21
|
+
* @template [O=unknown]
|
|
22
|
+
* @typedef {Object} Replacer
|
|
23
|
+
* @property {string} name - The name of the replacer.
|
|
24
|
+
* @property {(input: unknown, path?: string[]) => boolean} shouldReplace - Check to see if input can be replaced.
|
|
25
|
+
* @property {(input: T, path?: string[]) => O} replace - The replace function if shouldReplace returns true.
|
|
26
|
+
* @property {boolean} [stopHere] - Should the traverse stop here.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* @param {unknown} object - The object we're replacing.
|
|
30
|
+
* @param {Replacer[]} replacers - The Replacer array to execute.
|
|
31
|
+
* @returns {unknown}
|
|
32
|
+
*/
|
|
33
|
+
export declare function replace(object: unknown, replacers?: Replacer[]): unknown;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @import { Replacer } from '../replacer.js';
|
|
3
|
+
*/
|
|
4
|
+
import type { Replacer } from '../replacer.js';
|
|
5
|
+
/** @type {Replacer<Buffer>} */
|
|
6
|
+
export declare const BufferReplacer: Replacer<Buffer>;
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @typedef {Object} BaseError
|
|
3
|
-
* @property {string} type - The error type or name.
|
|
4
|
-
* @property {string} message - The error message.
|
|
5
|
-
* @property {import('../utilities/stacktrace.js').Callsite[]} stack - The stacktrace of the error.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {BaseError & { [k: string]: unknown }} NormalisedError
|
|
9
|
-
*/
|
|
10
|
-
/** @type {import('../replacer.js').Replacer<Error, NormalisedError>} */
|
|
11
|
-
export const ErrorReplacer: import("../replacer.js").Replacer<Error, NormalisedError>;
|
|
1
|
+
import type { Replacer } from '../replacer.js';
|
|
12
2
|
export type BaseError = {
|
|
13
3
|
/**
|
|
14
4
|
* - The error type or name.
|
|
@@ -21,8 +11,19 @@ export type BaseError = {
|
|
|
21
11
|
/**
|
|
22
12
|
* - The stacktrace of the error.
|
|
23
13
|
*/
|
|
24
|
-
stack: import(
|
|
14
|
+
stack: import('../utilities/stacktrace.js').Callsite[];
|
|
25
15
|
};
|
|
26
16
|
export type NormalisedError = BaseError & {
|
|
27
17
|
[k: string]: unknown;
|
|
28
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {Object} BaseError
|
|
21
|
+
* @property {string} type - The error type or name.
|
|
22
|
+
* @property {string} message - The error message.
|
|
23
|
+
* @property {import('../utilities/stacktrace.js').Callsite[]} stack - The stacktrace of the error.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {BaseError & { [k: string]: unknown }} NormalisedError
|
|
27
|
+
*/
|
|
28
|
+
/** @type {Replacer<Error, NormalisedError>} */
|
|
29
|
+
export declare const ErrorReplacer: Replacer<Error, NormalisedError>;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @import { Replacer } from '../replacer.js';
|
|
3
|
+
*/
|
|
4
|
+
import type { Replacer } from '../replacer.js';
|
|
3
5
|
import { ClientRequest } from 'node:http';
|
|
6
|
+
/** @type {Replacer<ClientRequest>} */
|
|
7
|
+
export declare const HttpClientRequestReplacer: Replacer<ClientRequest>;
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @import { ClientRequest } from 'node:http'
|
|
3
|
+
* @import { Replacer } from '../replacer.js'
|
|
4
|
+
*/
|
|
5
|
+
import type { ClientRequest } from 'node:http';
|
|
6
|
+
import type { Replacer } from '../replacer.js';
|
|
7
|
+
import { IncomingMessage } from 'node:http';
|
|
8
|
+
/**
|
|
9
|
+
* @type {Replacer<
|
|
3
10
|
* IncomingMessage & {
|
|
4
11
|
* hostname?: string,
|
|
5
12
|
* originalUrl?: string,
|
|
6
|
-
* req?:
|
|
13
|
+
* req?: ClientRequest
|
|
7
14
|
* }
|
|
8
15
|
* >}
|
|
9
16
|
*/
|
|
10
|
-
export const HttpIncomingMessageReplacer:
|
|
17
|
+
export declare const HttpIncomingMessageReplacer: Replacer<IncomingMessage & {
|
|
11
18
|
hostname?: string;
|
|
12
19
|
originalUrl?: string;
|
|
13
|
-
req?:
|
|
20
|
+
req?: ClientRequest;
|
|
14
21
|
}>;
|
|
15
|
-
import { IncomingMessage } from 'node:http';
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @import { Replacer } from '../replacer.js';
|
|
3
|
+
*/
|
|
4
|
+
import type { Replacer } from '../replacer.js';
|
|
3
5
|
import { ServerResponse } from 'node:http';
|
|
6
|
+
/** @type {Replacer<ServerResponse>} */
|
|
7
|
+
export declare const HttpServerResponseReplacer: Replacer<ServerResponse>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { BufferReplacer } from
|
|
2
|
-
export { ErrorReplacer } from
|
|
3
|
-
export { HttpClientRequestReplacer } from
|
|
4
|
-
export { HttpIncomingMessageReplacer } from
|
|
5
|
-
export { HttpServerResponseReplacer } from
|
|
6
|
-
export { LongStringReplacer } from
|
|
7
|
-
export { NetSocketReplacer } from
|
|
8
|
-
export {
|
|
1
|
+
export { BufferReplacer } from './buffers.js';
|
|
2
|
+
export { ErrorReplacer } from './error.js';
|
|
3
|
+
export { HttpClientRequestReplacer } from './http-client-request.js';
|
|
4
|
+
export { HttpIncomingMessageReplacer } from './http-incoming-message.js';
|
|
5
|
+
export { HttpServerResponseReplacer } from './http-server-response.js';
|
|
6
|
+
export { LongStringReplacer } from './long-strings.js';
|
|
7
|
+
export { NetSocketReplacer } from './net-socket.js';
|
|
8
|
+
export { SecretRedact, SecretRemove } from './secrets.js';
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @import { Replacer } from '../replacer.js';
|
|
3
|
+
*/
|
|
4
|
+
import type { Replacer } from '../replacer.js';
|
|
5
|
+
/** @type {Replacer<string>} */
|
|
6
|
+
export declare const LongStringReplacer: Replacer<string>;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @import { Replacer } from '../replacer.js';
|
|
3
|
+
*/
|
|
4
|
+
import type { Replacer } from '../replacer.js';
|
|
3
5
|
import { Socket } from 'node:net';
|
|
6
|
+
/** @type {Replacer<Socket>} */
|
|
7
|
+
export declare const NetSocketReplacer: Replacer<Socket>;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @import { Replacer } from '../replacer.js';
|
|
3
|
+
*/
|
|
4
|
+
import type { Replacer } from '../replacer.js';
|
|
5
|
+
/** @type {Replacer} */
|
|
6
|
+
export declare const SecretRemove: Replacer;
|
|
7
|
+
/** @type {Replacer} */
|
|
8
|
+
export declare const SecretRedact: Replacer;
|
package/types/stdout-write.d.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
declare const colours: Readonly<{
|
|
2
|
+
black: "0";
|
|
3
|
+
red: "1";
|
|
4
|
+
green: "2";
|
|
5
|
+
yellow: "3";
|
|
6
|
+
blue: "4";
|
|
7
|
+
magenta: "5";
|
|
8
|
+
cyan: "6";
|
|
9
|
+
white: "7";
|
|
10
|
+
}>;
|
|
11
|
+
declare const effects: Readonly<{
|
|
12
|
+
bold: number[];
|
|
13
|
+
faint: number[];
|
|
14
|
+
italic: number[];
|
|
15
|
+
underline: number[];
|
|
16
|
+
}>;
|
|
13
17
|
export type ColourNames = keyof typeof colours;
|
|
14
|
-
export type ColourMode =
|
|
18
|
+
export type ColourMode = 'bright' | 'dim';
|
|
15
19
|
export type ColourEffects = keyof typeof effects;
|
|
16
20
|
export type ColourOptions = {
|
|
17
21
|
/**
|
|
@@ -37,22 +41,18 @@ export type ColourOptions = {
|
|
|
37
41
|
/**
|
|
38
42
|
* - How to handle the string termination.
|
|
39
43
|
*/
|
|
40
|
-
reset?: boolean | Omit<ColourOptions,
|
|
44
|
+
reset?: boolean | Omit<ColourOptions, 'reset'>;
|
|
41
45
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
faint: number[];
|
|
55
|
-
italic: number[];
|
|
56
|
-
underline: number[];
|
|
57
|
-
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Should colours be used in the output.
|
|
48
|
+
* @returns {boolean}
|
|
49
|
+
*/
|
|
50
|
+
export declare function shouldColour(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Colour a string.
|
|
53
|
+
* @param {string} string - The string to colour.
|
|
54
|
+
* @param {ColourOptions | undefined} [options] - The options to use to colour the string.
|
|
55
|
+
* @returns {string}
|
|
56
|
+
*/
|
|
57
|
+
export declare function colourString(string: string, options?: ColourOptions | undefined): string;
|
|
58
58
|
export {};
|
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
export declare const environment: {
|
|
2
|
+
includeCallsite: boolean;
|
|
3
|
+
includeCpuUsage: boolean;
|
|
4
|
+
includeMemoryUsage: boolean;
|
|
5
|
+
isDevelopment: boolean;
|
|
6
|
+
isProduction: boolean;
|
|
7
|
+
isTesting: boolean;
|
|
8
|
+
logFilters: {
|
|
9
9
|
allowed: RegExp[];
|
|
10
10
|
blocked: RegExp[];
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export { LOG_MAX_LENGTH as stringMaxLength };
|
|
19
|
-
}
|
|
20
|
-
declare const LOG_CALLSITES: boolean;
|
|
21
|
-
declare const LOG_CPU: boolean;
|
|
22
|
-
declare const LOG_MEMORY: boolean;
|
|
23
|
-
declare const LOG_RELATIVE_TO: string | undefined;
|
|
24
|
-
declare const LOG_MAX_LENGTH: number;
|
|
25
|
-
export {};
|
|
12
|
+
logLevel: import("./log-types.js").LogLevel;
|
|
13
|
+
redactFilters: import("./legacy-secrets.js").Filters;
|
|
14
|
+
relativeTo: string | undefined;
|
|
15
|
+
removeFilters: import("./legacy-secrets.js").Filters;
|
|
16
|
+
stringMaxLength: number;
|
|
17
|
+
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Get the callsite that we think is outside the package.
|
|
3
3
|
* @returns {{ file: string, line: number, column: number } | void}
|
|
4
4
|
*/
|
|
5
|
-
export function getLastCallsite(): {
|
|
5
|
+
export declare function getLastCallsite(): {
|
|
6
6
|
file: string;
|
|
7
7
|
line: number;
|
|
8
8
|
column: number;
|