@darksheep/logger 1.3.1 → 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.
Files changed (43) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +35 -13
  3. package/package.json +7 -5
  4. package/src/create-logger.js +4 -4
  5. package/src/formatters/formatter-console/stack.js +1 -1
  6. package/src/formatters/formatter-console.js +2 -2
  7. package/src/index.js +2 -2
  8. package/src/replacer.js +18 -23
  9. package/src/replacers/index.js +1 -1
  10. package/src/replacers/secrets.js +100 -11
  11. package/src/utilities/environment.js +25 -3
  12. package/src/utilities/legacy-secrets.js +36 -0
  13. package/src/utilities/parse-filters.js +2 -2
  14. package/src/utilities/resource-usage.js +9 -6
  15. package/types/create-logger.d.ts +2 -2
  16. package/types/formatter.d.ts +2 -2
  17. package/types/formatters/formatter-console/stack.d.ts +15 -11
  18. package/types/formatters/formatter-console.d.ts +2 -2
  19. package/types/formatters/formatter-json.d.ts +1 -1
  20. package/types/index.d.ts +26 -11
  21. package/types/logger.d.ts +119 -33
  22. package/types/replacer.d.ts +15 -15
  23. package/types/replacers/buffers.d.ts +5 -2
  24. package/types/replacers/error.d.ts +13 -13
  25. package/types/replacers/http-client-request.d.ts +6 -3
  26. package/types/replacers/http-incoming-message.d.ts +8 -4
  27. package/types/replacers/http-server-response.d.ts +6 -3
  28. package/types/replacers/index.d.ts +8 -8
  29. package/types/replacers/long-strings.d.ts +5 -2
  30. package/types/replacers/net-socket.d.ts +6 -3
  31. package/types/replacers/secrets.d.ts +6 -3
  32. package/types/stdout-write.d.ts +1 -1
  33. package/types/utilities/colour.d.ts +30 -30
  34. package/types/utilities/environment.d.ts +14 -22
  35. package/types/utilities/json-path.d.ts +1 -1
  36. package/types/utilities/last-callsite.d.ts +1 -1
  37. package/types/utilities/legacy-secrets.d.ts +33 -0
  38. package/types/utilities/log-filters.d.ts +2 -2
  39. package/types/utilities/log-types.d.ts +30 -4
  40. package/types/utilities/parse-filters.d.ts +1 -1
  41. package/types/utilities/parse-log-level.d.ts +5 -2
  42. package/types/utilities/resource-usage.d.ts +2 -2
  43. package/types/utilities/stacktrace.d.ts +15 -15
package/types/index.d.ts CHANGED
@@ -1,11 +1,26 @@
1
- export { createLogger } from "./create-logger.js";
2
- export const logger: import("./logger.js").Logger;
3
- export { Logger } from "./logger.js";
4
- export { environment } from "./utilities/environment.js";
5
- export { LogLevels } from "./utilities/log-types.js";
6
- export type LogContext = import("./utilities/log-types.js").LogContext;
7
- export type LogEntry = import("./utilities/log-types.js").LogEntry;
8
- export type LogLevel = import("./utilities/log-types.js").LogLevel;
9
- export type Formatter = import("./formatter.js").Formatter;
10
- export type Replacer = import("./replacer.js").Replacer;
11
- export { BufferReplacer, ErrorReplacer, HttpClientRequestReplacer, HttpIncomingMessageReplacer, HttpServerResponseReplacer, LongStringReplacer, NetSocketReplacer, SecretDelete, SecretObscure } from "./replacers/index.js";
1
+ export type LogContext = import('./utilities/log-types.js').LogContext;
2
+ export type LogEntry = import('./utilities/log-types.js').LogEntry;
3
+ export type LogLevel = import('./utilities/log-types.js').LogLevel;
4
+ export type Formatter = import('./formatter.js').Formatter;
5
+ export type Replacer = import('./replacer.js').Replacer;
6
+ /**
7
+ * @typedef {import('./utilities/log-types.js').LogContext} LogContext
8
+ */
9
+ /**
10
+ * @typedef {import('./utilities/log-types.js').LogEntry} LogEntry
11
+ */
12
+ /**
13
+ * @typedef {import('./utilities/log-types.js').LogLevel} LogLevel
14
+ */
15
+ /**
16
+ * @typedef {import('./formatter.js').Formatter} Formatter
17
+ */
18
+ /**
19
+ * @typedef {import('./replacer.js').Replacer} Replacer
20
+ */
21
+ export { createLogger } from './create-logger.js';
22
+ export declare const logger: import("./logger.js").Logger;
23
+ export { Logger } from './logger.js';
24
+ export { BufferReplacer, ErrorReplacer, HttpClientRequestReplacer, HttpIncomingMessageReplacer, HttpServerResponseReplacer, LongStringReplacer, NetSocketReplacer, SecretRedact, SecretRemove, } from './replacers/index.js';
25
+ export { environment } from './utilities/environment.js';
26
+ export { LogLevels } from './utilities/log-types.js';
package/types/logger.d.ts CHANGED
@@ -1,3 +1,31 @@
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.
@@ -5,9 +33,17 @@
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 {
36
+ export declare class Logger {
37
+ #private;
9
38
  /** @type {AsyncLocalStorage<LogContext[]>} */
10
39
  static storage: AsyncLocalStorage<LogContext[]>;
40
+ /** @type {Replacer[]} */
41
+ replacers: Replacer[];
42
+ /**
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);
11
47
  /**
12
48
  * @param {LogContext} context - Context to bind ot the async context.
13
49
  * @returns {void}
@@ -19,7 +55,26 @@ export class Logger {
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;
72
+ /**
73
+ * @template [R=unknown]
74
+ * @overload
75
+ * @param {() => R} callback - The function to wrap the context in.
76
+ * @returns {R}
77
+ */
23
78
  /**
24
79
  * @template [R=unknown]
25
80
  * @overload
@@ -27,14 +82,13 @@ export class Logger {
27
82
  * @param {() => R} callback - The function to wrap the context in.
28
83
  * @returns {R}
29
84
  */
30
- static wrap<R = unknown>(context: LogContext, callback: () => R): R;
31
85
  /**
32
- * @param {LogContext} [context] - Context to add to the logger.
33
- * @param {Options} [options] - Options for the loggers output.
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}
34
90
  */
35
- constructor(context?: LogContext, options?: Options);
36
- /** @type {Replacer[]} */
37
- replacers: Replacer[];
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.
@@ -47,15 +101,67 @@ export class Logger {
47
101
  * @param {LogContext} context - The new context.
48
102
  * @returns {Logger}
49
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
+ */
50
124
  context(context: LogContext): Logger;
51
125
  /**
52
126
  * Creating a new logger with {context, ...this.context}.
53
127
  * @overload
54
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
55
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.
56
149
  * @returns {Logger}
57
150
  */
58
151
  context(context: LogContext, level: LogLevel): Logger;
152
+ /**
153
+ * Creating a new logger with {context, ...this.context}.
154
+ * @overload
155
+ * @param {LogContext} context - The new context.
156
+ * @returns {Logger}
157
+ */
158
+ /**
159
+ * Creating a new logger with {context, ...this.context}.
160
+ * @overload
161
+ * @param {LogContext} context - The new context.
162
+ * @param {LogLevel} level - The log level at which we allow this context.
163
+ * @returns {Logger}
164
+ */
59
165
  /**
60
166
  * Creating a new logger with {context, ...this.context}.
61
167
  * @overload
@@ -63,6 +169,12 @@ export class Logger {
63
169
  * @param {LogContext} context - The new context.
64
170
  * @returns {Logger}
65
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
+ */
66
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.
@@ -147,30 +259,4 @@ export class Logger {
147
259
  * @returns {void}
148
260
  */
149
261
  write(level: LogLevel, message: Error | string, context?: LogContext): void;
150
- #private;
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?: Replacer[];
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 type { Replacer } from './replacer.js';
171
- import type { LogContext } from './utilities/log-types.js';
172
- import type { LogLevel } from './utilities/log-types.js';
173
- import { AsyncLocalStorage } from 'node:async_hooks';
174
- import { replace } from './replacer.js';
175
- import { formatter } from './formatter.js';
176
- import { stdoutWrite } from './stdout-write.js';
@@ -1,18 +1,3 @@
1
- /**
2
- * @template [T=any]
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
1
  export type Replacer<T = any, O = unknown> = {
17
2
  /**
18
3
  * - The name of the replacer.
@@ -31,3 +16,18 @@ export type Replacer<T = any, 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,3 +1,6 @@
1
- /** @type {Replacer<Buffer>} */
2
- export const BufferReplacer: Replacer<Buffer>;
1
+ /**
2
+ * @import { Replacer } from '../replacer.js';
3
+ */
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 {Replacer<Error, NormalisedError>} */
11
- export const ErrorReplacer: 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,9 +11,19 @@ export type BaseError = {
21
11
  /**
22
12
  * - The stacktrace of the error.
23
13
  */
24
- stack: import("../utilities/stacktrace.js").Callsite[];
14
+ stack: import('../utilities/stacktrace.js').Callsite[];
25
15
  };
26
16
  export type NormalisedError = BaseError & {
27
17
  [k: string]: unknown;
28
18
  };
29
- import type { Replacer } from '../replacer.js';
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,4 +1,7 @@
1
- /** @type {Replacer<ClientRequest>} */
2
- export const HttpClientRequestReplacer: Replacer<ClientRequest>;
3
- import { ClientRequest } from 'node:http';
1
+ /**
2
+ * @import { Replacer } from '../replacer.js';
3
+ */
4
4
  import type { Replacer } from '../replacer.js';
5
+ import { ClientRequest } from 'node:http';
6
+ /** @type {Replacer<ClientRequest>} */
7
+ export declare const HttpClientRequestReplacer: Replacer<ClientRequest>;
@@ -1,3 +1,10 @@
1
+ /**
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';
1
8
  /**
2
9
  * @type {Replacer<
3
10
  * IncomingMessage & {
@@ -7,11 +14,8 @@
7
14
  * }
8
15
  * >}
9
16
  */
10
- export const HttpIncomingMessageReplacer: Replacer<IncomingMessage & {
17
+ export declare const HttpIncomingMessageReplacer: Replacer<IncomingMessage & {
11
18
  hostname?: string;
12
19
  originalUrl?: string;
13
20
  req?: ClientRequest;
14
21
  }>;
15
- import { IncomingMessage } from 'node:http';
16
- import type { ClientRequest } from 'node:http';
17
- import type { Replacer } from '../replacer.js';
@@ -1,4 +1,7 @@
1
- /** @type {Replacer<ServerResponse>} */
2
- export const HttpServerResponseReplacer: Replacer<ServerResponse>;
3
- import { ServerResponse } from 'node:http';
1
+ /**
2
+ * @import { Replacer } from '../replacer.js';
3
+ */
4
4
  import type { Replacer } from '../replacer.js';
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 "./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 { SecretDelete, SecretObscure } from "./secrets.js";
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,3 +1,6 @@
1
- /** @type {Replacer<string>} */
2
- export const LongStringReplacer: Replacer<string>;
1
+ /**
2
+ * @import { Replacer } from '../replacer.js';
3
+ */
3
4
  import type { Replacer } from '../replacer.js';
5
+ /** @type {Replacer<string>} */
6
+ export declare const LongStringReplacer: Replacer<string>;
@@ -1,4 +1,7 @@
1
- /** @type {Replacer<Socket>} */
2
- export const NetSocketReplacer: Replacer<Socket>;
3
- import { Socket } from 'node:net';
1
+ /**
2
+ * @import { Replacer } from '../replacer.js';
3
+ */
4
4
  import type { Replacer } from '../replacer.js';
5
+ import { Socket } from 'node:net';
6
+ /** @type {Replacer<Socket>} */
7
+ export declare const NetSocketReplacer: Replacer<Socket>;
@@ -1,5 +1,8 @@
1
+ /**
2
+ * @import { Replacer } from '../replacer.js';
3
+ */
4
+ import type { Replacer } from '../replacer.js';
1
5
  /** @type {Replacer} */
2
- export const SecretDelete: Replacer;
6
+ export declare const SecretRemove: Replacer;
3
7
  /** @type {Replacer} */
4
- export const SecretObscure: Replacer;
5
- import type { Replacer } from '../replacer.js';
8
+ export declare const SecretRedact: Replacer;
@@ -2,4 +2,4 @@
2
2
  * @param {string} output - What should be written to stdout.
3
3
  * @returns {void}
4
4
  */
5
- export function stdoutWrite(output: string): void;
5
+ export declare function stdoutWrite(output: string): void;
@@ -1,17 +1,21 @@
1
- /**
2
- * Should colours be used in the output.
3
- * @returns {boolean}
4
- */
5
- export function shouldColour(): boolean;
6
- /**
7
- * Colour a string.
8
- * @param {string} string - The string to colour.
9
- * @param {ColourOptions | undefined} [options] - The options to use to colour the string.
10
- * @returns {string}
11
- */
12
- export function colourString(string: string, options?: ColourOptions | undefined): string;
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 = "bright" | "dim";
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, "reset">;
44
+ reset?: boolean | Omit<ColourOptions, 'reset'>;
41
45
  };
42
- declare const colours: Readonly<{
43
- black: "0";
44
- red: "1";
45
- green: "2";
46
- yellow: "3";
47
- blue: "4";
48
- magenta: "5";
49
- cyan: "6";
50
- white: "7";
51
- }>;
52
- declare const effects: Readonly<{
53
- bold: number[];
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 namespace environment {
2
- export { LOG_CALLSITES as includeCallsite };
3
- export { LOG_CPU as includeCpuUsage };
4
- export { LOG_MEMORY as includeMemoryUsage };
5
- export let isDevelopment: boolean;
6
- export let isProduction: boolean;
7
- export let isTesting: boolean;
8
- export let logFilters: {
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
- export let logLevel: import("./log-types.js").LogLevel;
13
- export let secretFilters: {
14
- allowed: RegExp[];
15
- blocked: RegExp[];
16
- };
17
- export { LOG_RELATIVE_TO as relativeTo };
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,4 +2,4 @@
2
2
  * @param {string[]} nodes - The nodes to the element.
3
3
  * @returns {string}
4
4
  */
5
- export function nodesToPath(nodes: string[]): string;
5
+ export declare function nodesToPath(nodes: string[]): string;
@@ -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;
@@ -0,0 +1,33 @@
1
+ export type Filters = {
2
+ allowed: RegExp[];
3
+ blocked: RegExp[];
4
+ };
5
+ /**
6
+ * @typedef {{ allowed: RegExp[], blocked: RegExp[] }} Filters
7
+ */
8
+ /**
9
+ * Resolves the redact and remove filters, mapping the legacy `LOG_SECRETS`
10
+ * control onto them when the split vars are not set.
11
+ *
12
+ * In `LOG_SECRETS` a bare pattern obscured (redacted) the value and a
13
+ * `-`-prefixed pattern removed the key -- which is exactly the `allowed` /
14
+ * `blocked` split that `parseFilters` already produces. So the legacy
15
+ * `allowed` patterns become the redact set and the legacy `blocked` patterns
16
+ * become the remove set (neither carried exemptions). Whenever the matching
17
+ * split var is set it wins and the legacy value is ignored for that half.
18
+ *
19
+ * @param {{
20
+ * secrets?: string | undefined;
21
+ * redact?: string | undefined;
22
+ * remove?: string | undefined;
23
+ * }} options - The raw environment values.
24
+ * @returns {{ redactFilters: Filters, removeFilters: Filters }}
25
+ */
26
+ export declare function resolveSecretFilters({ secrets, redact, remove }: {
27
+ secrets?: string | undefined;
28
+ redact?: string | undefined;
29
+ remove?: string | undefined;
30
+ }): {
31
+ redactFilters: Filters;
32
+ removeFilters: Filters;
33
+ };
@@ -3,10 +3,10 @@
3
3
  * @param {import('./log-types.js').LogLevel} level - The log level to check.
4
4
  * @returns {boolean}
5
5
  */
6
- export function checkLogLevel(level: import("./log-types.js").LogLevel): boolean;
6
+ export declare function checkLogLevel(level: import('./log-types.js').LogLevel): boolean;
7
7
  /**
8
8
  * Check to see if a message with {channel} should get logged.
9
9
  * @param {string} [channel] - The channel to check.
10
10
  * @returns {boolean}
11
11
  */
12
- export function checkLogFilters(channel?: string): boolean;
12
+ export declare function checkLogFilters(channel?: string): boolean;