@decaf-ts/logging 0.24.2 → 0.26.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/logging.cjs +1 -1
- package/dist/logging.cjs.map +1 -1
- package/dist/logging.js +1 -1
- package/dist/logging.js.map +1 -1
- package/lib/cjs/constants.cjs +4 -0
- package/lib/cjs/constants.cjs.map +1 -1
- package/lib/cjs/index.cjs +3 -3
- package/lib/cjs/logParameters.cjs +58 -1
- package/lib/cjs/logParameters.cjs.map +1 -1
- package/lib/cjs/logging.cjs +65 -31
- package/lib/cjs/logging.cjs.map +1 -1
- package/lib/esm/constants.js +4 -0
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/index.js +3 -3
- package/lib/esm/logParameters.js +58 -1
- package/lib/esm/logParameters.js.map +1 -1
- package/lib/esm/logging.js +65 -31
- package/lib/esm/logging.js.map +1 -1
- package/lib/types/index.d.cts +2 -2
- package/lib/types/index.d.mts +2 -2
- package/lib/types/logParameters.d.cts +5 -1
- package/lib/types/logParameters.d.mts +5 -1
- package/lib/types/logging.d.cts +38 -3
- package/lib/types/logging.d.mts +38 -3
- package/lib/types/types.d.cts +11 -0
- package/lib/types/types.d.mts +11 -0
- package/package.json +1 -1
package/lib/types/logging.d.cts
CHANGED
|
@@ -46,14 +46,29 @@ export declare class MiniLogger implements Logger {
|
|
|
46
46
|
/**
|
|
47
47
|
* @description Creates a formatted log string.
|
|
48
48
|
* @summary Generates a log string with timestamp, colored log level, context, and message.
|
|
49
|
-
* @param {LogLevel} level - The log level for this message.
|
|
49
|
+
* @param {LogLevel} [level] - The log level for this message. Omitted (`undefined`) for action entries, which carry no severity level.
|
|
50
50
|
* @param {StringLike | Error} message - The message to log or an Error object.
|
|
51
51
|
* @param {Error} [error] - Optional error to extract stack trace to include in the log.
|
|
52
52
|
* @return {string} A formatted log string with all components.
|
|
53
53
|
*/
|
|
54
|
-
protected createLog(level: LogLevel, message: StringLike | Error, error?: Error, meta?: LogMeta): string;
|
|
54
|
+
protected createLog(level: LogLevel | undefined, message: StringLike | Error, error?: Error, meta?: LogMeta, action?: string, actionCode?: number): string;
|
|
55
55
|
private formatMeta;
|
|
56
56
|
protected normalizePatternSpacing(value: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* @description Resolves the console method used to emit a given log level.
|
|
59
|
+
* @summary Maps each {@link LogLevel} to the console method that should carry it (error levels to `console.error`, warn to `console.warn`, etc).
|
|
60
|
+
* @param {LogLevel} level - The log level to resolve a console method for.
|
|
61
|
+
* @return The console method for that level.
|
|
62
|
+
*/
|
|
63
|
+
protected methodFor(level: LogLevel): (...args: any[]) => void;
|
|
64
|
+
/**
|
|
65
|
+
* @description Emits an already-formatted log line.
|
|
66
|
+
* @summary The single place every logging method funnels through to actually write output, so console access stays in one spot.
|
|
67
|
+
* @param method - The console method to invoke (e.g. `console.log`, `console.error`).
|
|
68
|
+
* @param {string} formatted - The fully formatted log line, as produced by {@link createLog}.
|
|
69
|
+
* @return {void}
|
|
70
|
+
*/
|
|
71
|
+
protected write(method: (...args: any[]) => void, formatted: string): void;
|
|
57
72
|
/**
|
|
58
73
|
* @description Logs a message with the specified log level.
|
|
59
74
|
* @summary Checks if the message should be logged based on the current log level, then uses the appropriate console method to output the formatted log.
|
|
@@ -71,6 +86,16 @@ export declare class MiniLogger implements Logger {
|
|
|
71
86
|
* @return {void}
|
|
72
87
|
*/
|
|
73
88
|
benchmark(msg: StringLike, meta?: LogMeta): void;
|
|
89
|
+
/**
|
|
90
|
+
* @description Logs an action: a discrete, named event carrying its own metadata rather than a severity level or a message.
|
|
91
|
+
* @summary Action entries are a separate, more controlled channel from the rest of the {@link Logger} API - they carry no message, are not tied to any {@link LogLevel}, and always print regardless of the configured minimum level. The action name (plus its optional numeric code) is rendered where the level would otherwise appear, and the structured meta is always rendered too, regardless of the `meta` display setting. An entry's payload is exactly: the action string, an optional code, and meta - nothing else.
|
|
92
|
+
* @param {string} action - The action name/identifier.
|
|
93
|
+
* @param {number} [code] - An optional numeric classification code for the action.
|
|
94
|
+
* @param {LogMeta} [meta] - Optional structured metadata, always rendered regardless of the `meta` display setting.
|
|
95
|
+
* @return {void}
|
|
96
|
+
*/
|
|
97
|
+
action(action: string, meta?: LogMeta): void;
|
|
98
|
+
action(action: string, code: number, meta?: LogMeta): void;
|
|
74
99
|
/**
|
|
75
100
|
* @description Logs a message at the fatal level.
|
|
76
101
|
* @summary Logs a message at the fatal level for unrecoverable failures.
|
|
@@ -306,6 +331,16 @@ export declare class Logging {
|
|
|
306
331
|
* @return {void}
|
|
307
332
|
*/
|
|
308
333
|
static benchmark(msg: StringLike, meta?: LogMeta): void;
|
|
334
|
+
/**
|
|
335
|
+
* @description Logs an action.
|
|
336
|
+
* @summary Delegates the action logging to the global logger instance.
|
|
337
|
+
* @param {string} action - The action name/identifier.
|
|
338
|
+
* @param {number} [code] - An optional numeric classification code for the action.
|
|
339
|
+
* @param {LogMeta} [meta] - Optional structured metadata, always rendered regardless of the `meta` display setting.
|
|
340
|
+
* @return {void}
|
|
341
|
+
*/
|
|
342
|
+
static action(action: string, meta?: LogMeta): void;
|
|
343
|
+
static action(action: string, code: number, meta?: LogMeta): void;
|
|
309
344
|
/**
|
|
310
345
|
* @description Logs a fatal message.
|
|
311
346
|
* @summary Delegates the fatal logging to the global logger instance.
|
|
@@ -403,7 +438,7 @@ export declare class Logging {
|
|
|
403
438
|
* end
|
|
404
439
|
* end
|
|
405
440
|
*/
|
|
406
|
-
static theme(text: string, type: keyof Theme | keyof LogLevel, loggerLevel: LogLevel, template?: Theme): string;
|
|
441
|
+
static theme(text: string, type: keyof Theme | keyof LogLevel, loggerLevel: LogLevel | undefined, template?: Theme): string;
|
|
407
442
|
static register(descriptor: LogParameterDescriptor): import("./logParameters.d.cts").LogParameterRegistry;
|
|
408
443
|
static unregister(key: string): import("./logParameters.d.cts").LogParameterRegistry;
|
|
409
444
|
}
|
package/lib/types/logging.d.mts
CHANGED
|
@@ -46,14 +46,29 @@ export declare class MiniLogger implements Logger {
|
|
|
46
46
|
/**
|
|
47
47
|
* @description Creates a formatted log string.
|
|
48
48
|
* @summary Generates a log string with timestamp, colored log level, context, and message.
|
|
49
|
-
* @param {LogLevel} level - The log level for this message.
|
|
49
|
+
* @param {LogLevel} [level] - The log level for this message. Omitted (`undefined`) for action entries, which carry no severity level.
|
|
50
50
|
* @param {StringLike | Error} message - The message to log or an Error object.
|
|
51
51
|
* @param {Error} [error] - Optional error to extract stack trace to include in the log.
|
|
52
52
|
* @return {string} A formatted log string with all components.
|
|
53
53
|
*/
|
|
54
|
-
protected createLog(level: LogLevel, message: StringLike | Error, error?: Error, meta?: LogMeta): string;
|
|
54
|
+
protected createLog(level: LogLevel | undefined, message: StringLike | Error, error?: Error, meta?: LogMeta, action?: string, actionCode?: number): string;
|
|
55
55
|
private formatMeta;
|
|
56
56
|
protected normalizePatternSpacing(value: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* @description Resolves the console method used to emit a given log level.
|
|
59
|
+
* @summary Maps each {@link LogLevel} to the console method that should carry it (error levels to `console.error`, warn to `console.warn`, etc).
|
|
60
|
+
* @param {LogLevel} level - The log level to resolve a console method for.
|
|
61
|
+
* @return The console method for that level.
|
|
62
|
+
*/
|
|
63
|
+
protected methodFor(level: LogLevel): (...args: any[]) => void;
|
|
64
|
+
/**
|
|
65
|
+
* @description Emits an already-formatted log line.
|
|
66
|
+
* @summary The single place every logging method funnels through to actually write output, so console access stays in one spot.
|
|
67
|
+
* @param method - The console method to invoke (e.g. `console.log`, `console.error`).
|
|
68
|
+
* @param {string} formatted - The fully formatted log line, as produced by {@link createLog}.
|
|
69
|
+
* @return {void}
|
|
70
|
+
*/
|
|
71
|
+
protected write(method: (...args: any[]) => void, formatted: string): void;
|
|
57
72
|
/**
|
|
58
73
|
* @description Logs a message with the specified log level.
|
|
59
74
|
* @summary Checks if the message should be logged based on the current log level, then uses the appropriate console method to output the formatted log.
|
|
@@ -71,6 +86,16 @@ export declare class MiniLogger implements Logger {
|
|
|
71
86
|
* @return {void}
|
|
72
87
|
*/
|
|
73
88
|
benchmark(msg: StringLike, meta?: LogMeta): void;
|
|
89
|
+
/**
|
|
90
|
+
* @description Logs an action: a discrete, named event carrying its own metadata rather than a severity level or a message.
|
|
91
|
+
* @summary Action entries are a separate, more controlled channel from the rest of the {@link Logger} API - they carry no message, are not tied to any {@link LogLevel}, and always print regardless of the configured minimum level. The action name (plus its optional numeric code) is rendered where the level would otherwise appear, and the structured meta is always rendered too, regardless of the `meta` display setting. An entry's payload is exactly: the action string, an optional code, and meta - nothing else.
|
|
92
|
+
* @param {string} action - The action name/identifier.
|
|
93
|
+
* @param {number} [code] - An optional numeric classification code for the action.
|
|
94
|
+
* @param {LogMeta} [meta] - Optional structured metadata, always rendered regardless of the `meta` display setting.
|
|
95
|
+
* @return {void}
|
|
96
|
+
*/
|
|
97
|
+
action(action: string, meta?: LogMeta): void;
|
|
98
|
+
action(action: string, code: number, meta?: LogMeta): void;
|
|
74
99
|
/**
|
|
75
100
|
* @description Logs a message at the fatal level.
|
|
76
101
|
* @summary Logs a message at the fatal level for unrecoverable failures.
|
|
@@ -306,6 +331,16 @@ export declare class Logging {
|
|
|
306
331
|
* @return {void}
|
|
307
332
|
*/
|
|
308
333
|
static benchmark(msg: StringLike, meta?: LogMeta): void;
|
|
334
|
+
/**
|
|
335
|
+
* @description Logs an action.
|
|
336
|
+
* @summary Delegates the action logging to the global logger instance.
|
|
337
|
+
* @param {string} action - The action name/identifier.
|
|
338
|
+
* @param {number} [code] - An optional numeric classification code for the action.
|
|
339
|
+
* @param {LogMeta} [meta] - Optional structured metadata, always rendered regardless of the `meta` display setting.
|
|
340
|
+
* @return {void}
|
|
341
|
+
*/
|
|
342
|
+
static action(action: string, meta?: LogMeta): void;
|
|
343
|
+
static action(action: string, code: number, meta?: LogMeta): void;
|
|
309
344
|
/**
|
|
310
345
|
* @description Logs a fatal message.
|
|
311
346
|
* @summary Delegates the fatal logging to the global logger instance.
|
|
@@ -403,7 +438,7 @@ export declare class Logging {
|
|
|
403
438
|
* end
|
|
404
439
|
* end
|
|
405
440
|
*/
|
|
406
|
-
static theme(text: string, type: keyof Theme | keyof LogLevel, loggerLevel: LogLevel, template?: Theme): string;
|
|
441
|
+
static theme(text: string, type: keyof Theme | keyof LogLevel, loggerLevel: LogLevel | undefined, template?: Theme): string;
|
|
407
442
|
static register(descriptor: LogParameterDescriptor): import("./logParameters.d.mts").LogParameterRegistry;
|
|
408
443
|
static unregister(key: string): import("./logParameters.d.mts").LogParameterRegistry;
|
|
409
444
|
}
|
package/lib/types/types.d.cts
CHANGED
|
@@ -71,6 +71,16 @@ export interface Logger extends Impersonatable<Logger, [
|
|
|
71
71
|
* @return {void}
|
|
72
72
|
*/
|
|
73
73
|
benchmark(msg: StringLike, meta?: LogMeta): void;
|
|
74
|
+
/**
|
|
75
|
+
* @description Logs a named action: a discrete event carrying its own metadata rather than a severity level or a message.
|
|
76
|
+
* @summary Action entries are a separate, more controlled channel from the rest of this interface - they carry no message, are not tied to a {@link LogLevel}, and always print regardless of the configured minimum level. The action name (plus optional numeric code) is rendered where a level would otherwise appear, and `meta` is always rendered too, regardless of the logger's `meta` display setting. An entry's payload is exactly: the action string, an optional code, and meta.
|
|
77
|
+
* @param {string} action - The action name/identifier.
|
|
78
|
+
* @param {number} [code] - An optional numeric classification code for the action.
|
|
79
|
+
* @param {LogMeta} [meta] - Optional structured metadata, always rendered regardless of the `meta` display setting.
|
|
80
|
+
* @return {void}
|
|
81
|
+
*/
|
|
82
|
+
action(action: string, meta?: LogMeta): void;
|
|
83
|
+
action(action: string, code: number, meta?: LogMeta): void;
|
|
74
84
|
/**
|
|
75
85
|
* @description Logs a fatal message.
|
|
76
86
|
* @summary Emits the most severe failure events at the `fatal` log level.
|
|
@@ -286,6 +296,7 @@ export interface Theme {
|
|
|
286
296
|
* @description Styling for the main message text in the output.
|
|
287
297
|
*/
|
|
288
298
|
message: ThemeOption | ThemeOptionByLogLevel;
|
|
299
|
+
action: ThemeOption | ThemeOptionByLogLevel;
|
|
289
300
|
/**
|
|
290
301
|
* @description Styling for method names in the output.
|
|
291
302
|
*/
|
package/lib/types/types.d.mts
CHANGED
|
@@ -71,6 +71,16 @@ export interface Logger extends Impersonatable<Logger, [
|
|
|
71
71
|
* @return {void}
|
|
72
72
|
*/
|
|
73
73
|
benchmark(msg: StringLike, meta?: LogMeta): void;
|
|
74
|
+
/**
|
|
75
|
+
* @description Logs a named action: a discrete event carrying its own metadata rather than a severity level or a message.
|
|
76
|
+
* @summary Action entries are a separate, more controlled channel from the rest of this interface - they carry no message, are not tied to a {@link LogLevel}, and always print regardless of the configured minimum level. The action name (plus optional numeric code) is rendered where a level would otherwise appear, and `meta` is always rendered too, regardless of the logger's `meta` display setting. An entry's payload is exactly: the action string, an optional code, and meta.
|
|
77
|
+
* @param {string} action - The action name/identifier.
|
|
78
|
+
* @param {number} [code] - An optional numeric classification code for the action.
|
|
79
|
+
* @param {LogMeta} [meta] - Optional structured metadata, always rendered regardless of the `meta` display setting.
|
|
80
|
+
* @return {void}
|
|
81
|
+
*/
|
|
82
|
+
action(action: string, meta?: LogMeta): void;
|
|
83
|
+
action(action: string, code: number, meta?: LogMeta): void;
|
|
74
84
|
/**
|
|
75
85
|
* @description Logs a fatal message.
|
|
76
86
|
* @summary Emits the most severe failure events at the `fatal` log level.
|
|
@@ -286,6 +296,7 @@ export interface Theme {
|
|
|
286
296
|
* @description Styling for the main message text in the output.
|
|
287
297
|
*/
|
|
288
298
|
message: ThemeOption | ThemeOptionByLogLevel;
|
|
299
|
+
action: ThemeOption | ThemeOptionByLogLevel;
|
|
289
300
|
/**
|
|
290
301
|
* @description Styling for method names in the output.
|
|
291
302
|
*/
|