@waiaas/core 2.11.0 → 2.12.0-rc.1
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.
|
@@ -9,17 +9,24 @@ export interface ILogger {
|
|
|
9
9
|
warn(message: string, context?: Record<string, unknown>): void;
|
|
10
10
|
error(message: string, context?: Record<string, unknown>): void;
|
|
11
11
|
}
|
|
12
|
+
/** Log level hierarchy: debug < info < warn < error. */
|
|
13
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
12
14
|
/**
|
|
13
15
|
* Default console-based logger implementation.
|
|
14
16
|
* Formats context as JSON suffix when provided.
|
|
17
|
+
* Supports level filtering via `setLevel()` for hot-reload.
|
|
15
18
|
*/
|
|
16
19
|
export declare class ConsoleLogger implements ILogger {
|
|
17
20
|
private readonly prefix?;
|
|
18
|
-
|
|
21
|
+
private _level;
|
|
22
|
+
constructor(prefix?: string | undefined, level?: LogLevel);
|
|
23
|
+
get level(): LogLevel;
|
|
24
|
+
setLevel(level: LogLevel): void;
|
|
19
25
|
debug(message: string, context?: Record<string, unknown>): void;
|
|
20
26
|
info(message: string, context?: Record<string, unknown>): void;
|
|
21
27
|
warn(message: string, context?: Record<string, unknown>): void;
|
|
22
28
|
error(message: string, context?: Record<string, unknown>): void;
|
|
29
|
+
private shouldLog;
|
|
23
30
|
private format;
|
|
24
31
|
}
|
|
25
32
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/interfaces/logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACtB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAChE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM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;IAE/B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAG/D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAG9D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAG9D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI/D,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,MAAM;CAKf"}
|
|
@@ -1,23 +1,41 @@
|
|
|
1
|
+
const LOG_LEVEL_PRIORITY = {
|
|
2
|
+
debug: 0,
|
|
3
|
+
info: 1,
|
|
4
|
+
warn: 2,
|
|
5
|
+
error: 3,
|
|
6
|
+
};
|
|
1
7
|
/**
|
|
2
8
|
* Default console-based logger implementation.
|
|
3
9
|
* Formats context as JSON suffix when provided.
|
|
10
|
+
* Supports level filtering via `setLevel()` for hot-reload.
|
|
4
11
|
*/
|
|
5
12
|
export class ConsoleLogger {
|
|
6
13
|
prefix;
|
|
7
|
-
|
|
14
|
+
_level;
|
|
15
|
+
constructor(prefix, level = 'info') {
|
|
8
16
|
this.prefix = prefix;
|
|
17
|
+
this._level = level;
|
|
9
18
|
}
|
|
19
|
+
get level() { return this._level; }
|
|
20
|
+
setLevel(level) { this._level = level; }
|
|
10
21
|
debug(message, context) {
|
|
11
|
-
|
|
22
|
+
if (this.shouldLog('debug'))
|
|
23
|
+
console.debug(this.format(message, context));
|
|
12
24
|
}
|
|
13
25
|
info(message, context) {
|
|
14
|
-
|
|
26
|
+
if (this.shouldLog('info'))
|
|
27
|
+
console.info(this.format(message, context));
|
|
15
28
|
}
|
|
16
29
|
warn(message, context) {
|
|
17
|
-
|
|
30
|
+
if (this.shouldLog('warn'))
|
|
31
|
+
console.warn(this.format(message, context));
|
|
18
32
|
}
|
|
19
33
|
error(message, context) {
|
|
20
|
-
|
|
34
|
+
if (this.shouldLog('error'))
|
|
35
|
+
console.error(this.format(message, context));
|
|
36
|
+
}
|
|
37
|
+
shouldLog(callLevel) {
|
|
38
|
+
return LOG_LEVEL_PRIORITY[callLevel] >= LOG_LEVEL_PRIORITY[this._level];
|
|
21
39
|
}
|
|
22
40
|
format(message, context) {
|
|
23
41
|
const prefix = this.prefix ? `[${this.prefix}] ` : '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/interfaces/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/interfaces/logger.ts"],"names":[],"mappings":"AAeA,MAAM,kBAAkB,GAA6B;IACnD,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;CACT,CAAC;AAEF;;;;GAIG;AACH,MAAM,OAAO,aAAa;IAGK;IAFrB,MAAM,CAAW;IAEzB,YAA6B,MAAe,EAAE,QAAkB,MAAM;QAAzC,WAAM,GAAN,MAAM,CAAS;QAC1C,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,IAAI,KAAK,KAAe,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7C,QAAQ,CAAC,KAAe,IAAU,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;IAExD,KAAK,CAAC,OAAe,EAAE,OAAiC;QACtD,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5E,CAAC;IACD,IAAI,CAAC,OAAe,EAAE,OAAiC;QACrD,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1E,CAAC;IACD,IAAI,CAAC,OAAe,EAAE,OAAiC;QACrD,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1E,CAAC;IACD,KAAK,CAAC,OAAe,EAAE,OAAiC;QACtD,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5E,CAAC;IAEO,SAAS,CAAC,SAAmB;QACnC,OAAO,kBAAkB,CAAC,SAAS,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1E,CAAC;IAEO,MAAM,CAAC,OAAe,EAAE,OAAiC;QAC/D,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5D,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,CAAC;IACxC,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waiaas/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0-rc.1",
|
|
4
4
|
"description": "WAIaaS core types, schemas, and shared utilities",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@x402/core": "^2.3.1",
|
|
36
36
|
"viem": "^2.21.0",
|
|
37
37
|
"zod": "^3.24.0",
|
|
38
|
-
"@waiaas/shared": "2.
|
|
38
|
+
"@waiaas/shared": "2.12.0-rc.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^25.2.3"
|