@darksheep/logger 1.0.6 → 1.0.8
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 +22 -0
- package/package.json +5 -7
- package/src/create-logger.js +1 -1
- package/src/formatters/formatter-console.js +22 -22
- package/src/formatters/formatter-json.js +1 -1
- package/src/logger.js +70 -66
- package/src/replacer.js +9 -8
- package/src/replacers/buffers.js +1 -1
- package/src/replacers/error.js +4 -8
- package/src/stdout-write.js +1 -1
- package/src/utilities/colour.js +20 -20
- package/src/utilities/environment.js +1 -1
- package/src/utilities/json-path.js +4 -4
- package/src/utilities/last-callsite.js +1 -1
- package/src/utilities/log-filters.js +4 -4
- package/src/utilities/log-types.js +14 -14
- package/src/utilities/parse-filters.js +15 -10
- package/src/utilities/parse-log-level.js +13 -13
- package/src/utilities/stacktrace.js +8 -8
- package/types/assert.zod.d.ts +4 -4
- package/types/create-logger.d.ts +1 -1
- package/types/formatters/formatter-console.d.ts +1 -1
- package/types/formatters/formatter-json.d.ts +1 -1
- package/types/logger.d.ts +62 -61
- package/types/replacer.d.ts +11 -11
- package/types/replacers/error.d.ts +6 -6
- package/types/stdout-write.d.ts +1 -1
- package/types/utilities/colour.d.ts +16 -16
- package/types/utilities/json-path.d.ts +1 -1
- package/types/utilities/last-callsite.d.ts +1 -1
- package/types/utilities/log-filters.d.ts +4 -4
- package/types/utilities/log-types.d.ts +28 -28
- package/types/utilities/parse-filters.d.ts +2 -2
- package/types/utilities/parse-log-level.d.ts +3 -3
- package/types/utilities/stacktrace.d.ts +16 -16
- package/types/logger.test.d.ts +0 -1
- package/types/replacer.test.d.ts +0 -1
- package/types/replacers/buffers.test.d.ts +0 -1
- package/types/replacers/error.test.d.ts +0 -1
- package/types/replacers/http-client-request.test.d.ts +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
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
|
|
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
6
|
*/
|
|
7
7
|
/**
|
|
8
8
|
* @typedef {BaseError & { [k: string]: unknown }} NormalisedError
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
export const ErrorReplacer: import("../replacer.js").Replacer<Error, NormalisedError>;
|
|
12
12
|
export type BaseError = {
|
|
13
13
|
/**
|
|
14
|
-
* The error type or name
|
|
14
|
+
* - The error type or name.
|
|
15
15
|
*/
|
|
16
16
|
type: string;
|
|
17
17
|
/**
|
|
18
|
-
* The error message
|
|
18
|
+
* - The error message.
|
|
19
19
|
*/
|
|
20
20
|
message: string;
|
|
21
21
|
/**
|
|
22
|
-
* The stacktrace of the error
|
|
22
|
+
* - The stacktrace of the error.
|
|
23
23
|
*/
|
|
24
24
|
stack: import("../utilities/stacktrace.js").Callsite[];
|
|
25
25
|
};
|
package/types/stdout-write.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Should colours be used in the output
|
|
2
|
+
* Should colours be used in the output.
|
|
3
3
|
* @returns {boolean}
|
|
4
4
|
*/
|
|
5
5
|
export function shouldColour(): boolean;
|
|
6
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
|
|
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
10
|
* @returns {string}
|
|
11
11
|
*/
|
|
12
12
|
export function colourString(string: string, options: ColourOptions): string;
|
|
@@ -15,29 +15,29 @@ export type ColourMode = "bright" | "dim";
|
|
|
15
15
|
export type ColourEffects = keyof typeof effects;
|
|
16
16
|
export type ColourOptions = {
|
|
17
17
|
/**
|
|
18
|
-
* The foreground colour name
|
|
18
|
+
* - The foreground colour name.
|
|
19
19
|
*/
|
|
20
|
-
foreground?:
|
|
20
|
+
foreground?: ColourNames;
|
|
21
21
|
/**
|
|
22
|
-
* The foreground colour mode
|
|
22
|
+
* - The foreground colour mode.
|
|
23
23
|
*/
|
|
24
|
-
foregroundMode?: ColourMode
|
|
24
|
+
foregroundMode?: ColourMode;
|
|
25
25
|
/**
|
|
26
|
-
* The background colour name
|
|
26
|
+
* - The background colour name.
|
|
27
27
|
*/
|
|
28
|
-
background?:
|
|
28
|
+
background?: ColourNames;
|
|
29
29
|
/**
|
|
30
|
-
* The background colour mode
|
|
30
|
+
* - The background colour mode.
|
|
31
31
|
*/
|
|
32
|
-
backgroundMode?: ColourMode
|
|
32
|
+
backgroundMode?: ColourMode;
|
|
33
33
|
/**
|
|
34
|
-
* The string effents
|
|
34
|
+
* - The string effents.
|
|
35
35
|
*/
|
|
36
|
-
effects?:
|
|
36
|
+
effects?: ColourEffects[];
|
|
37
37
|
/**
|
|
38
|
-
* How to handle the string termination
|
|
38
|
+
* - How to handle the string termination.
|
|
39
39
|
*/
|
|
40
|
-
reset?: boolean | Omit<ColourOptions, "reset"
|
|
40
|
+
reset?: boolean | Omit<ColourOptions, "reset">;
|
|
41
41
|
};
|
|
42
42
|
declare const colours: Readonly<{
|
|
43
43
|
black: "0";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Check to see if {loggerLevel} should get logged
|
|
3
|
-
* @param {import('./log-types.js').LogLevel} level The log level to check
|
|
2
|
+
* Check to see if {loggerLevel} should get logged.
|
|
3
|
+
* @param {import('./log-types.js').LogLevel} level - The log level to check.
|
|
4
4
|
* @returns {boolean}
|
|
5
5
|
*/
|
|
6
6
|
export function checkLogLevel(level: import("./log-types.js").LogLevel): boolean;
|
|
7
7
|
/**
|
|
8
|
-
* Check to see if a message with {channel} should get logged
|
|
9
|
-
* @param {string} [channel] The channel to check
|
|
8
|
+
* Check to see if a message with {channel} should get logged.
|
|
9
|
+
* @param {string} [channel] - The channel to check.
|
|
10
10
|
* @returns {boolean}
|
|
11
11
|
*/
|
|
12
12
|
export function checkLogFilters(channel?: string | undefined): boolean;
|
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
export type LogLevels = {
|
|
2
2
|
/**
|
|
3
|
-
* A crucial part of the application is not working
|
|
3
|
+
* - A crucial part of the application is not working.
|
|
4
4
|
*/
|
|
5
5
|
critical: 0;
|
|
6
6
|
/**
|
|
7
|
-
* A non critical operation fails
|
|
7
|
+
* - A non critical operation fails.
|
|
8
8
|
*/
|
|
9
9
|
error: 1;
|
|
10
10
|
/**
|
|
11
|
-
* An operation might fail in the future
|
|
11
|
+
* - An operation might fail in the future.
|
|
12
12
|
*/
|
|
13
13
|
warning: 2;
|
|
14
14
|
/**
|
|
15
|
-
* Information about events that may be unusual
|
|
15
|
+
* - Information about events that may be unusual.
|
|
16
16
|
*/
|
|
17
17
|
notice: 3;
|
|
18
18
|
/**
|
|
19
|
-
* Information about successful operations
|
|
19
|
+
* - Information about successful operations.
|
|
20
20
|
*/
|
|
21
21
|
info: 4;
|
|
22
22
|
/**
|
|
23
|
-
* Information that is unlikely to help in production
|
|
23
|
+
* - Information that is unlikely to help in production.
|
|
24
24
|
*/
|
|
25
25
|
debug: 5;
|
|
26
26
|
/**
|
|
27
|
-
* Information to help resolve complex logic issues
|
|
27
|
+
* - Information to help resolve complex logic issues.
|
|
28
28
|
*/
|
|
29
29
|
silly: 6;
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
32
|
* @typedef {Object} LogLevels
|
|
33
|
-
* @property {0} critical A crucial part of the application is not working
|
|
34
|
-
* @property {1} error A non critical operation fails
|
|
35
|
-
* @property {2} warning An operation might fail in the future
|
|
36
|
-
* @property {3} notice Information about events that may be unusual
|
|
37
|
-
* @property {4} info Information about successful operations
|
|
38
|
-
* @property {5} debug Information that is unlikely to help in production
|
|
39
|
-
* @property {6} silly Information to help resolve complex logic issues
|
|
33
|
+
* @property {0} critical - A crucial part of the application is not working.
|
|
34
|
+
* @property {1} error - A non critical operation fails.
|
|
35
|
+
* @property {2} warning - An operation might fail in the future.
|
|
36
|
+
* @property {3} notice - Information about events that may be unusual.
|
|
37
|
+
* @property {4} info - Information about successful operations.
|
|
38
|
+
* @property {5} debug - Information that is unlikely to help in production.
|
|
39
|
+
* @property {6} silly - Information to help resolve complex logic issues.
|
|
40
40
|
*/
|
|
41
41
|
/** @type {LogLevels} */
|
|
42
42
|
export const LogLevels: LogLevels;
|
|
@@ -49,33 +49,33 @@ export type Callsite = import("./stacktrace.js").Callsite;
|
|
|
49
49
|
export type NormalisedError = import("../replacers/error.js").NormalisedError;
|
|
50
50
|
export type LogInternal = {
|
|
51
51
|
/**
|
|
52
|
-
* A timestamp for the log message
|
|
52
|
+
* - A timestamp for the log message.
|
|
53
53
|
*/
|
|
54
|
-
timestamp?: Date
|
|
54
|
+
timestamp?: Date;
|
|
55
55
|
/**
|
|
56
|
-
* A channel to bind to the log
|
|
56
|
+
* - A channel to bind to the log.
|
|
57
57
|
*/
|
|
58
|
-
channel?: string
|
|
58
|
+
channel?: string;
|
|
59
59
|
/**
|
|
60
|
-
* The log level
|
|
60
|
+
* - The log level.
|
|
61
61
|
*/
|
|
62
|
-
level?: LogLevel
|
|
62
|
+
level?: LogLevel;
|
|
63
63
|
/**
|
|
64
|
-
* A message to use
|
|
64
|
+
* - A message to use.
|
|
65
65
|
*/
|
|
66
|
-
message?: string
|
|
66
|
+
message?: string;
|
|
67
67
|
/**
|
|
68
|
-
* The stack trace bound to the log
|
|
68
|
+
* - The stack trace bound to the log.
|
|
69
69
|
*/
|
|
70
|
-
stack?: string |
|
|
70
|
+
stack?: string | Callsite[];
|
|
71
71
|
/**
|
|
72
|
-
* A child error for the core error
|
|
72
|
+
* - A child error for the core error.
|
|
73
73
|
*/
|
|
74
|
-
cause?:
|
|
74
|
+
cause?: NormalisedError | Error;
|
|
75
75
|
/**
|
|
76
|
-
* The trail id bound to the callsite
|
|
76
|
+
* - The trail id bound to the callsite.
|
|
77
77
|
*/
|
|
78
|
-
trail?: string
|
|
78
|
+
trail?: string;
|
|
79
79
|
};
|
|
80
80
|
export type LogContext = LogInternal & Record<string, unknown>;
|
|
81
81
|
export type LogEntry = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {string} [filter] The filter string
|
|
3
|
-
* @param {RegExp[]} [fallback] Fallback to the following allowed regexp
|
|
2
|
+
* @param {string} [filter] - The filter string.
|
|
3
|
+
* @param {RegExp[]} [fallback] - Fallback to the following allowed regexp.
|
|
4
4
|
* @returns {{ allowed: RegExp[], blocked: RegExp[] }}
|
|
5
5
|
*/
|
|
6
6
|
export function parseFilters(filter?: string | undefined, fallback?: RegExp[] | undefined): {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
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
|
|
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
5
|
* @returns {import('./log-types.js').LogLevel}
|
|
6
6
|
*/
|
|
7
7
|
export function parseLogLevel(input?: string | undefined, node?: string | undefined): import("./log-types.js").LogLevel;
|
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {Object} Callsite
|
|
3
|
-
* @property {string} file The file name for the callsite
|
|
4
|
-
* @property {string} [relativePath] The relative path for the callsite.file
|
|
5
|
-
* @property {string} [absolutePath] The absolute path for the callsite.file
|
|
6
|
-
* @property {string} methodName The methodName from the callsite
|
|
7
|
-
* @property {number} line The line number in the file
|
|
8
|
-
* @property {number} column The column number in the file
|
|
3
|
+
* @property {string} file - The file name for the callsite.
|
|
4
|
+
* @property {string} [relativePath] - The relative path for the callsite.file.
|
|
5
|
+
* @property {string} [absolutePath] - The absolute path for the callsite.file.
|
|
6
|
+
* @property {string} methodName - The methodName from the callsite.
|
|
7
|
+
* @property {number} line - The line number in the file.
|
|
8
|
+
* @property {number} column - The column number in the file.
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
|
-
* Get the callsite that we think is outside the package
|
|
12
|
-
* @param {string} [stack] The stacktrace to parse
|
|
11
|
+
* Get the callsite that we think is outside the package.
|
|
12
|
+
* @param {string} [stack] - The stacktrace to parse.
|
|
13
13
|
* @returns {Callsite[]}
|
|
14
14
|
*/
|
|
15
15
|
export function parseStack(stack?: string | undefined): Callsite[];
|
|
16
16
|
export type Callsite = {
|
|
17
17
|
/**
|
|
18
|
-
* The file name for the callsite
|
|
18
|
+
* - The file name for the callsite.
|
|
19
19
|
*/
|
|
20
20
|
file: string;
|
|
21
21
|
/**
|
|
22
|
-
* The relative path for the callsite.file
|
|
22
|
+
* - The relative path for the callsite.file.
|
|
23
23
|
*/
|
|
24
|
-
relativePath?: string
|
|
24
|
+
relativePath?: string;
|
|
25
25
|
/**
|
|
26
|
-
* The absolute path for the callsite.file
|
|
26
|
+
* - The absolute path for the callsite.file.
|
|
27
27
|
*/
|
|
28
|
-
absolutePath?: string
|
|
28
|
+
absolutePath?: string;
|
|
29
29
|
/**
|
|
30
|
-
* The methodName from the callsite
|
|
30
|
+
* - The methodName from the callsite.
|
|
31
31
|
*/
|
|
32
32
|
methodName: string;
|
|
33
33
|
/**
|
|
34
|
-
* The line number in the file
|
|
34
|
+
* - The line number in the file.
|
|
35
35
|
*/
|
|
36
36
|
line: number;
|
|
37
37
|
/**
|
|
38
|
-
* The column number in the file
|
|
38
|
+
* - The column number in the file.
|
|
39
39
|
*/
|
|
40
40
|
column: number;
|
|
41
41
|
};
|
package/types/logger.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/types/replacer.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|