@darksheep/logger 1.0.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 (61) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +191 -0
  3. package/package.json +44 -0
  4. package/src/create-logger.js +36 -0
  5. package/src/formatter.js +14 -0
  6. package/src/formatters/formatter-console.js +243 -0
  7. package/src/formatters/formatter-json.js +7 -0
  8. package/src/index.js +25 -0
  9. package/src/logger.js +369 -0
  10. package/src/replacer.js +68 -0
  11. package/src/replacers/buffers.js +18 -0
  12. package/src/replacers/error.js +40 -0
  13. package/src/replacers/http-client-request.js +18 -0
  14. package/src/replacers/http-incoming-message.js +26 -0
  15. package/src/replacers/http-server-response.js +16 -0
  16. package/src/replacers/index.js +8 -0
  17. package/src/replacers/long-strings.js +11 -0
  18. package/src/replacers/net-socket.js +21 -0
  19. package/src/replacers/secrets.js +50 -0
  20. package/src/stdout-write.js +7 -0
  21. package/src/utilities/colour.js +152 -0
  22. package/src/utilities/environment.js +61 -0
  23. package/src/utilities/json-path.js +17 -0
  24. package/src/utilities/last-callsite.js +11 -0
  25. package/src/utilities/log-filters.js +22 -0
  26. package/src/utilities/log-types.js +46 -0
  27. package/src/utilities/parse-filters.js +47 -0
  28. package/src/utilities/parse-log-level.js +32 -0
  29. package/src/utilities/stacktrace.js +57 -0
  30. package/types/assert.zod.d.ts +18 -0
  31. package/types/create-logger.d.ts +5 -0
  32. package/types/formatter.d.ts +6 -0
  33. package/types/formatters/formatter-console.d.ts +9 -0
  34. package/types/formatters/formatter-json.d.ts +5 -0
  35. package/types/index.d.ts +11 -0
  36. package/types/logger.d.ts +184 -0
  37. package/types/logger.test.d.ts +1 -0
  38. package/types/replacer.d.ts +45 -0
  39. package/types/replacer.test.d.ts +1 -0
  40. package/types/replacers/buffers.d.ts +2 -0
  41. package/types/replacers/buffers.test.d.ts +1 -0
  42. package/types/replacers/error.d.ts +37 -0
  43. package/types/replacers/error.test.d.ts +1 -0
  44. package/types/replacers/http-client-request.d.ts +3 -0
  45. package/types/replacers/http-client-request.test.d.ts +1 -0
  46. package/types/replacers/http-incoming-message.d.ts +15 -0
  47. package/types/replacers/http-server-response.d.ts +3 -0
  48. package/types/replacers/index.d.ts +8 -0
  49. package/types/replacers/long-strings.d.ts +2 -0
  50. package/types/replacers/net-socket.d.ts +3 -0
  51. package/types/replacers/secrets.d.ts +4 -0
  52. package/types/stdout-write.d.ts +5 -0
  53. package/types/utilities/colour.d.ts +76 -0
  54. package/types/utilities/environment.d.ts +25 -0
  55. package/types/utilities/json-path.d.ts +5 -0
  56. package/types/utilities/last-callsite.d.ts +9 -0
  57. package/types/utilities/log-filters.d.ts +12 -0
  58. package/types/utilities/log-types.d.ts +126 -0
  59. package/types/utilities/parse-filters.d.ts +9 -0
  60. package/types/utilities/parse-log-level.d.ts +7 -0
  61. package/types/utilities/stacktrace.d.ts +59 -0
@@ -0,0 +1,184 @@
1
+ /**
2
+ * @typedef {Object} Options
3
+ * @property {typeof replace} [replace] The replacer function to use
4
+ * @property {import('./replacer.js').Replacer<any, any>[]} [replacers] The replacers to use in the replacer
5
+ * @property {typeof formatter} [format] The formatter function to use (eg console or json formatter)
6
+ * @property {typeof stdoutWrite} [write] The place to write the log to
7
+ */
8
+ export class Logger {
9
+ /** @type {AsyncLocalStorage<import('./utilities/log-types.js').LogContext[]>} */
10
+ static storage: AsyncLocalStorage<import("./utilities/log-types.js").LogContext[]>;
11
+ /**
12
+ * @template [R=unknown]
13
+ * @overload
14
+ * @param {() => R} callback The function to wrap the context in
15
+ * @returns {R}
16
+ */
17
+ static wrap<R = unknown>(callback: () => R): R;
18
+ /**
19
+ * @template [R=unknown]
20
+ * @overload
21
+ * @param {import('./utilities/log-types.js').LogContext} context Context to bind ot the async context
22
+ * @param {() => R} callback The function to wrap the context in
23
+ * @returns {R}
24
+ */
25
+ static wrap<R = unknown>(context: import("./utilities/log-types.js").LogContext, callback: () => R): R;
26
+ /**
27
+ * @param {import('./utilities/log-types.js').LogContext} context Context to bind ot the async context
28
+ * @returns {void}
29
+ */
30
+ static addAsyncContext(context: import("./utilities/log-types.js").LogContext): void;
31
+ /**
32
+ * @param {import('./utilities/log-types.js').LogContext} [context] Context to add to the logger
33
+ * @param {Options} [options] Options for the loggers output
34
+ */
35
+ constructor(context?: import("./utilities/log-types.js").LogContext | undefined, options?: Options | undefined);
36
+ /**
37
+ * @template [R=unknown]
38
+ * @param {() => R} callback The function to wrap the context in
39
+ * @returns {R}
40
+ */
41
+ wrap<R = unknown>(callback: () => R): R;
42
+ /** @type {import('./replacer.js').Replacer[]} */
43
+ replacers: import("./replacer.js").Replacer[];
44
+ /**
45
+ * Write a new log entry
46
+ * @param {import('./utilities/log-types.js').LogLevel} level the log level of the message to log
47
+ * @param {Error | string} message The message to log
48
+ * @param {import('./utilities/log-types.js').LogContext} [context] Context to add to the log (merged with this.context, and Logger.contexts)
49
+ * @returns {void}
50
+ */
51
+ write(level: import("./utilities/log-types.js").LogLevel, message: Error | string, context?: import("./utilities/log-types.js").LogContext | undefined): void;
52
+ /**
53
+ * Write a log with the level 'critical' - A crucial part of the application is not working
54
+ *
55
+ * @param {Error | string} message The message to log
56
+ * @param {import('./utilities/log-types.js').LogContext} [context] Additional context
57
+ * @returns {void}
58
+ */
59
+ critical(message: Error | string, context?: import("./utilities/log-types.js").LogContext | undefined): void;
60
+ /**
61
+ * Write a log with the level 'error' - A non critical operation fails
62
+ * @param {Error | string} message The message to log
63
+ * @param {import('./utilities/log-types.js').LogContext} [context] Additional context
64
+ * @returns {void}
65
+ */
66
+ error(message: Error | string, context?: import("./utilities/log-types.js").LogContext | undefined): void;
67
+ /**
68
+ * Write a log with the level 'warning' - An operation might fail in the future
69
+ * @param {Error | string} message The message to log
70
+ * @param {import('./utilities/log-types.js').LogContext} [context] Additional context
71
+ * @returns {void}
72
+ */
73
+ warning(message: Error | string, context?: import("./utilities/log-types.js").LogContext | undefined): void;
74
+ /**
75
+ * Write a log with the level 'notice' - Information about events that may be unusual
76
+ * @param {Error | string} message The message to log
77
+ * @param {import('./utilities/log-types.js').LogContext} [context] Additional context
78
+ * @returns {void}
79
+ */
80
+ notice(message: Error | string, context?: import("./utilities/log-types.js").LogContext | undefined): void;
81
+ /**
82
+ * Write a log with the level 'info' - Information about successful operations
83
+ * @param {Error | string} message The message to log
84
+ * @param {import('./utilities/log-types.js').LogContext} [context] Additional context
85
+ * @returns {void}
86
+ */
87
+ info(message: Error | string, context?: import("./utilities/log-types.js").LogContext | undefined): void;
88
+ /**
89
+ * Write a log with the level 'debug' - Information that is unlikely to help in production
90
+ * @param {Error | string} message The message to log
91
+ * @param {import('./utilities/log-types.js').LogContext} [context] Additional context
92
+ * @returns {void}
93
+ */
94
+ debug(message: Error | string, context?: import("./utilities/log-types.js").LogContext | undefined): void;
95
+ /**
96
+ * Write a log with the level 'silly' - Information to help resolve complex logic issues
97
+ * @param {Error | string} message The message to log
98
+ * @param {import('./utilities/log-types.js').LogContext} [context] Additional context
99
+ * @returns {void}
100
+ */
101
+ silly(message: Error | string, context?: import("./utilities/log-types.js").LogContext | undefined): void;
102
+ /**
103
+ * Creating a new logger with {context, ...this.context}
104
+ * @overload
105
+ * @param {import('./utilities/log-types.js').LogContext} context The new context
106
+ * @returns {Logger}
107
+ */
108
+ context(context: import("./utilities/log-types.js").LogContext): Logger;
109
+ /**
110
+ * Creating a new logger with {context, ...this.context}
111
+ * @overload
112
+ * @param {import('./utilities/log-types.js').LogContext} context The new context
113
+ * @param {import('./utilities/log-types.js').LogLevel} level The log level at which we allow this context
114
+ * @returns {Logger}
115
+ */
116
+ context(context: import("./utilities/log-types.js").LogContext, level: import("./utilities/log-types.js").LogLevel): Logger;
117
+ /**
118
+ * Creating a new logger with {context, ...this.context}
119
+ * @overload
120
+ * @param {import('./utilities/log-types.js').LogLevel} level The log level at which we allow this context
121
+ * @param {import('./utilities/log-types.js').LogContext} context The new context
122
+ * @returns {Logger}
123
+ */
124
+ context(level: import("./utilities/log-types.js").LogLevel, context: import("./utilities/log-types.js").LogContext): Logger;
125
+ /**
126
+ * Get a value from the context by key
127
+ * @param {string} key The key to get from the context
128
+ * @returns {unknown}
129
+ */
130
+ get(key: string): unknown;
131
+ /**
132
+ * Set a value into a new context by key
133
+ * @param {string} key The key to set
134
+ * @param {unknown} value The value to set
135
+ * @returns {Logger}
136
+ */
137
+ set(key: string, value: unknown): Logger;
138
+ /**
139
+ * Set the channel in the new logger
140
+ * @param {string} channel The channel name
141
+ * @returns {Logger}
142
+ */
143
+ channel(channel: string): Logger;
144
+ /**
145
+ * Set the trail in the new logger
146
+ * @param {string} [trail] The trail id
147
+ * @returns {Logger}
148
+ */
149
+ trail(trail?: string | undefined): Logger;
150
+ #private;
151
+ }
152
+ export type Options = {
153
+ /**
154
+ * The replacer function to use
155
+ */
156
+ /**
157
+ * The replacer function to use
158
+ */
159
+ replace?: typeof replace | undefined;
160
+ /**
161
+ * The replacers to use in the replacer
162
+ */
163
+ /**
164
+ * The replacers to use in the replacer
165
+ */
166
+ replacers?: import("./replacer.js").Replacer<any, any>[] | undefined;
167
+ /**
168
+ * The formatter function to use (eg console or json formatter)
169
+ */
170
+ /**
171
+ * The formatter function to use (eg console or json formatter)
172
+ */
173
+ format?: import("./formatter.js").Formatter | undefined;
174
+ /**
175
+ * The place to write the log to
176
+ */
177
+ /**
178
+ * The place to write the log to
179
+ */
180
+ write?: typeof stdoutWrite | undefined;
181
+ };
182
+ import { AsyncLocalStorage } from 'node:async_hooks';
183
+ import { replace } from './replacer.js';
184
+ import { stdoutWrite } from './stdout-write.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,45 @@
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> = {
17
+ /**
18
+ * The name of the replacer
19
+ */
20
+ /**
21
+ * The name of the replacer
22
+ */
23
+ name: string;
24
+ /**
25
+ * Check to see if input can be replaced
26
+ */
27
+ /**
28
+ * Check to see if input can be replaced
29
+ */
30
+ shouldReplace: (input: unknown, path?: string[]) => boolean;
31
+ /**
32
+ * The replace function if shouldReplace returns true
33
+ */
34
+ /**
35
+ * The replace function if shouldReplace returns true
36
+ */
37
+ replace: (input: T, path?: string[]) => O;
38
+ /**
39
+ * Should the traverse stop here
40
+ */
41
+ /**
42
+ * Should the traverse stop here
43
+ */
44
+ stopHere?: boolean | undefined;
45
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ /** @type {import('../replacer.js').Replacer<Buffer>} */
2
+ export const BufferReplacer: import("../replacer.js").Replacer<Buffer>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
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>;
12
+ export type BaseError = {
13
+ /**
14
+ * The error type or name
15
+ */
16
+ /**
17
+ * The error type or name
18
+ */
19
+ type: string;
20
+ /**
21
+ * The error message
22
+ */
23
+ /**
24
+ * The error message
25
+ */
26
+ message: string;
27
+ /**
28
+ * The stacktrace of the error
29
+ */
30
+ /**
31
+ * The stacktrace of the error
32
+ */
33
+ stack: import("../utilities/stacktrace.js").Callsite[];
34
+ };
35
+ export type NormalisedError = BaseError & {
36
+ [k: string]: unknown;
37
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ /** @type {import('../replacer.js').Replacer<ClientRequest>} */
2
+ export const HttpClientRequestReplacer: import("../replacer.js").Replacer<ClientRequest>;
3
+ import { ClientRequest } from 'node:http';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @type {import('../replacer.js').Replacer<
3
+ * IncomingMessage & {
4
+ * hostname?: string,
5
+ * originalUrl?: string,
6
+ * req?: import('node:http').ClientRequest
7
+ * }
8
+ * >}
9
+ */
10
+ export const HttpIncomingMessageReplacer: import("../replacer.js").Replacer<IncomingMessage & {
11
+ hostname?: string;
12
+ originalUrl?: string;
13
+ req?: import("node:http").ClientRequest;
14
+ }>;
15
+ import { IncomingMessage } from 'node:http';
@@ -0,0 +1,3 @@
1
+ /** @type {import('../replacer.js').Replacer<ServerResponse>} */
2
+ export const HttpServerResponseReplacer: import("../replacer.js").Replacer<ServerResponse>;
3
+ import { ServerResponse } from 'node:http';
@@ -0,0 +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";
@@ -0,0 +1,2 @@
1
+ /** @type {import('../replacer.js').Replacer<string>} */
2
+ export const LongStringReplacer: import("../replacer.js").Replacer<string>;
@@ -0,0 +1,3 @@
1
+ /** @type {import('../replacer.js').Replacer<Socket>} */
2
+ export const NetSocketReplacer: import("../replacer.js").Replacer<Socket>;
3
+ import { Socket } from 'node:net';
@@ -0,0 +1,4 @@
1
+ /** @type {import('../replacer.js').Replacer} */
2
+ export const SecretDelete: import("../replacer.js").Replacer;
3
+ /** @type {import('../replacer.js').Replacer} */
4
+ export const SecretObscure: import("../replacer.js").Replacer;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @param {string} output What should be written to stdout
3
+ * @returns {void}
4
+ */
5
+ export function stdoutWrite(output: string): void;
@@ -0,0 +1,76 @@
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} options The options to use to colour the string
10
+ * @returns {string}
11
+ */
12
+ export function colourString(string: string, options: ColourOptions): string;
13
+ export type ColourNames = keyof typeof colours;
14
+ export type ColourMode = "bright" | "dim";
15
+ export type ColourEffects = keyof typeof effects;
16
+ export type ColourOptions = {
17
+ /**
18
+ * The foreground colour name
19
+ */
20
+ /**
21
+ * The foreground colour name
22
+ */
23
+ foreground?: "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | undefined;
24
+ /**
25
+ * The foreground colour mode
26
+ */
27
+ /**
28
+ * The foreground colour mode
29
+ */
30
+ foregroundMode?: ColourMode | undefined;
31
+ /**
32
+ * The background colour name
33
+ */
34
+ /**
35
+ * The background colour name
36
+ */
37
+ background?: "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | undefined;
38
+ /**
39
+ * The background colour mode
40
+ */
41
+ /**
42
+ * The background colour mode
43
+ */
44
+ backgroundMode?: ColourMode | undefined;
45
+ /**
46
+ * The string effents
47
+ */
48
+ /**
49
+ * The string effents
50
+ */
51
+ effects?: ("bold" | "faint" | "italic" | "underline")[] | undefined;
52
+ /**
53
+ * How to handle the string termination
54
+ */
55
+ /**
56
+ * How to handle the string termination
57
+ */
58
+ reset?: boolean | Omit<ColourOptions, "reset"> | undefined;
59
+ };
60
+ declare const colours: Readonly<{
61
+ black: "0";
62
+ red: "1";
63
+ green: "2";
64
+ yellow: "3";
65
+ blue: "4";
66
+ magenta: "5";
67
+ cyan: "6";
68
+ white: "7";
69
+ }>;
70
+ declare const effects: Readonly<{
71
+ bold: number[];
72
+ faint: number[];
73
+ italic: number[];
74
+ underline: number[];
75
+ }>;
76
+ export {};
@@ -0,0 +1,25 @@
1
+ export namespace environment {
2
+ export { isDevelopment };
3
+ export { isTesting };
4
+ export { isProduction };
5
+ export { logLevel };
6
+ export { logFilters };
7
+ export { secretFilters };
8
+ export { includeCallsite };
9
+ export { stringMaxLength };
10
+ }
11
+ declare const isDevelopment: boolean;
12
+ declare const isTesting: boolean;
13
+ declare const isProduction: boolean;
14
+ declare const logLevel: import("./log-types.js").LogLevel;
15
+ declare const logFilters: {
16
+ allowed: RegExp[];
17
+ blocked: RegExp[];
18
+ };
19
+ declare const secretFilters: {
20
+ allowed: RegExp[];
21
+ blocked: RegExp[];
22
+ };
23
+ declare const includeCallsite: boolean;
24
+ declare const stringMaxLength: number;
25
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @param {string[]} nodes The nodes to the element
3
+ * @returns {string}
4
+ */
5
+ export function nodesToPath(nodes: string[]): string;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Get the callsite that we think is outside the package
3
+ * @returns {{ file: string, line: number, column: number } | void}
4
+ */
5
+ export function getLastCallsite(): {
6
+ file: string;
7
+ line: number;
8
+ column: number;
9
+ } | void;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Check to see if {loggerLevel} should get logged
3
+ * @param {import('./log-types.js').LogLevel} level The log level to check
4
+ * @returns {boolean}
5
+ */
6
+ export function checkLogLevel(level: import("./log-types.js").LogLevel): boolean;
7
+ /**
8
+ * Check to see if a message with {channel} should get logged
9
+ * @param {string} [channel] The channel to check
10
+ * @returns {boolean}
11
+ */
12
+ export function checkLogFilters(channel?: string | undefined): boolean;
@@ -0,0 +1,126 @@
1
+ export type LogLevels = {
2
+ /**
3
+ * A crucial part of the application is not working
4
+ */
5
+ /**
6
+ * A crucial part of the application is not working
7
+ */
8
+ critical: 0;
9
+ /**
10
+ * A non critical operation fails
11
+ */
12
+ /**
13
+ * A non critical operation fails
14
+ */
15
+ error: 1;
16
+ /**
17
+ * An operation might fail in the future
18
+ */
19
+ /**
20
+ * An operation might fail in the future
21
+ */
22
+ warning: 2;
23
+ /**
24
+ * Information about events that may be unusual
25
+ */
26
+ /**
27
+ * Information about events that may be unusual
28
+ */
29
+ notice: 3;
30
+ /**
31
+ * Information about successful operations
32
+ */
33
+ /**
34
+ * Information about successful operations
35
+ */
36
+ info: 4;
37
+ /**
38
+ * Information that is unlikely to help in production
39
+ */
40
+ /**
41
+ * Information that is unlikely to help in production
42
+ */
43
+ debug: 5;
44
+ /**
45
+ * Information to help resolve complex logic issues
46
+ */
47
+ /**
48
+ * Information to help resolve complex logic issues
49
+ */
50
+ silly: 6;
51
+ };
52
+ /**
53
+ * @typedef {Object} LogLevels
54
+ * @property {0} critical A crucial part of the application is not working
55
+ * @property {1} error A non critical operation fails
56
+ * @property {2} warning An operation might fail in the future
57
+ * @property {3} notice Information about events that may be unusual
58
+ * @property {4} info Information about successful operations
59
+ * @property {5} debug Information that is unlikely to help in production
60
+ * @property {6} silly Information to help resolve complex logic issues
61
+ */
62
+ /** @type {LogLevels} */
63
+ export const LogLevels: LogLevels;
64
+ export const LogNames: {
65
+ [k: string]: string;
66
+ };
67
+ export type LogLevelNames = keyof LogLevels;
68
+ export type LogLevel = LogLevels[LogLevelNames];
69
+ export type Callsite = import("./stacktrace.js").Callsite;
70
+ export type NormalisedError = import("../replacers/error.js").NormalisedError;
71
+ export type LogInternal = {
72
+ /**
73
+ * A timestamp for the log message
74
+ */
75
+ /**
76
+ * A timestamp for the log message
77
+ */
78
+ timestamp?: Date | undefined;
79
+ /**
80
+ * A channel to bind to the log
81
+ */
82
+ /**
83
+ * A channel to bind to the log
84
+ */
85
+ channel?: string | undefined;
86
+ /**
87
+ * The log level
88
+ */
89
+ /**
90
+ * The log level
91
+ */
92
+ level?: LogLevel | undefined;
93
+ /**
94
+ * A message to use
95
+ */
96
+ /**
97
+ * A message to use
98
+ */
99
+ message?: string | undefined;
100
+ /**
101
+ * The stack trace bound to the log
102
+ */
103
+ /**
104
+ * The stack trace bound to the log
105
+ */
106
+ stack?: string | import("./stacktrace.js").Callsite[] | undefined;
107
+ /**
108
+ * A child error for the core error
109
+ */
110
+ /**
111
+ * A child error for the core error
112
+ */
113
+ cause?: Error | import("../replacers/error.js").NormalisedError | undefined;
114
+ /**
115
+ * The trail id bound to the callsite
116
+ */
117
+ /**
118
+ * The trail id bound to the callsite
119
+ */
120
+ trail?: string | undefined;
121
+ };
122
+ export type LogContext = LogInternal & Record<string, unknown>;
123
+ export type LogEntry = {
124
+ level: LogLevel;
125
+ message: string;
126
+ } & LogInternal & Record<string, unknown>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @param {string} [filter] The filter string
3
+ * @param {RegExp[]} [fallback] Fallback to the following allowed regexp
4
+ * @returns {{ allowed: RegExp[], blocked: RegExp[] }}
5
+ */
6
+ export function parseFilters(filter?: string | undefined, fallback?: RegExp[] | undefined): {
7
+ allowed: RegExp[];
8
+ blocked: RegExp[];
9
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Convert a given string to a LogLevel
3
+ * @param {string} [input] The string to convert
4
+ * @param {string} [node] The current NODE_ENV
5
+ * @returns {import('./log-types.js').LogLevel}
6
+ */
7
+ export function parseLogLevel(input?: string | undefined, node?: string | undefined): import("./log-types.js").LogLevel;