@bian-womp/spark-graph 0.3.82 → 0.3.83
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/lib/cjs/index.cjs +201 -20
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/index.d.ts +1 -1
- package/lib/cjs/src/index.d.ts.map +1 -1
- package/lib/cjs/src/misc/utils/LevelLogger.d.ts +85 -1
- package/lib/cjs/src/misc/utils/LevelLogger.d.ts.map +1 -1
- package/lib/cjs/src/runtime/components/NodeExecutor.d.ts.map +1 -1
- package/lib/esm/index.js +201 -20
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/index.d.ts +1 -1
- package/lib/esm/src/index.d.ts.map +1 -1
- package/lib/esm/src/misc/utils/LevelLogger.d.ts +85 -1
- package/lib/esm/src/misc/utils/LevelLogger.d.ts.map +1 -1
- package/lib/esm/src/runtime/components/NodeExecutor.d.ts.map +1 -1
- package/package.json +2 -2
package/lib/cjs/src/index.d.ts
CHANGED
|
@@ -23,5 +23,5 @@ export { installLogging } from "./examples/shared";
|
|
|
23
23
|
export { registerDelayNode, registerProgressNodes, generateId, BaseMathOperation, BaseCompareOperation, BaseLogicOperation, } from "./misc/base";
|
|
24
24
|
export { mergeSnapshots, convertSnapshot, computeGraphCenter, offsetImportedPositions, mergeRuntimeState, buildValueConverter, type ValueConverter, } from "./misc/utils/merge";
|
|
25
25
|
export { parseJsonPath, getValueAtPath, setValueAtPath, setValueAtPathWithCreation, findMatchingPaths, stringifyJson, stringifySceneAndOps, } from "./misc/utils/json";
|
|
26
|
-
export { LevelLogger } from "./misc/utils/LevelLogger";
|
|
26
|
+
export { LevelLogger, type LoggerLevelRule } from "./misc/utils/LevelLogger";
|
|
27
27
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kB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,cAAc,GACpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,aAAa,EACb,cAAc,EACd,cAAc,EACd,0BAA0B,EAC1B,iBAAiB,EACjB,aAAa,EACb,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -1,15 +1,78 @@
|
|
|
1
1
|
import type { LogLevel } from "@bian-womp/spark-protocol";
|
|
2
|
+
type MatchTextRule = {
|
|
3
|
+
equals?: string | string[];
|
|
4
|
+
startsWith?: string | string[];
|
|
5
|
+
contains?: string | string[];
|
|
6
|
+
regex?: string | string[];
|
|
7
|
+
not?: {
|
|
8
|
+
equals?: string | string[];
|
|
9
|
+
startsWith?: string | string[];
|
|
10
|
+
contains?: string | string[];
|
|
11
|
+
regex?: string | string[];
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type LoggerLevelRule = {
|
|
15
|
+
name?: string;
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
setLevel: LogLevel;
|
|
18
|
+
when?: {
|
|
19
|
+
prefix?: MatchTextRule;
|
|
20
|
+
message?: MatchTextRule;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
2
23
|
/**
|
|
3
24
|
* A reusable logger class that supports configurable log levels and prefixes.
|
|
4
25
|
* Can be instantiated with a default log level and optionally override per call.
|
|
26
|
+
*
|
|
27
|
+
* Dynamic log-level rules:
|
|
28
|
+
* - Rules are configured once via `LevelLogger.setDynamicLevelRules(raw)`.
|
|
29
|
+
* - Rules can also be configured per logger instance via `setInstanceDynamicLevelRules(raw)`.
|
|
30
|
+
* - Rules are compiled into a static runtime-friendly structure for fast matching.
|
|
31
|
+
* - On every log call, logger resolves dynamic level by rule match:
|
|
32
|
+
* `overrideLevel` > instance rule > global rule > logger default.
|
|
33
|
+
*
|
|
34
|
+
* Rule format (raw):
|
|
35
|
+
* [
|
|
36
|
+
* {
|
|
37
|
+
* "name": "optional label",
|
|
38
|
+
* "enabled": true,
|
|
39
|
+
* "setLevel": "debug",
|
|
40
|
+
* "when": {
|
|
41
|
+
* "prefix": { "startsWith": ["[node:scene.importAsset"] },
|
|
42
|
+
* "message": { "startsWith": ["computeAssetSyncStatus"] }
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
* ]
|
|
46
|
+
*
|
|
47
|
+
* Matching semantics:
|
|
48
|
+
* - Rules are evaluated in order; first match wins.
|
|
49
|
+
* - `prefix` and `message` conditions are AND-ed when both exist.
|
|
50
|
+
* - Within each operator list (`startsWith`, `contains`, etc.), values are OR-ed.
|
|
51
|
+
* - If multiple operators are defined in one block, all operators must pass.
|
|
52
|
+
* - `not` negates an additional matcher block.
|
|
53
|
+
* - String matching is case-insensitive; regex is used as provided.
|
|
54
|
+
*
|
|
55
|
+
* Priority strategy (fixed):
|
|
56
|
+
* - `overrideLevel` > first matching instance rule > first matching global rule > logger default.
|
|
5
57
|
*/
|
|
6
58
|
export declare class LevelLogger {
|
|
7
59
|
private defaultLevel;
|
|
8
60
|
private prefix;
|
|
61
|
+
private static compiledDynamicLevelRules;
|
|
62
|
+
private compiledInstanceDynamicLevelRules;
|
|
9
63
|
/**
|
|
10
64
|
* Maps log levels to numeric values for comparison
|
|
11
65
|
*/
|
|
12
66
|
static readonly levelValues: Record<LogLevel, number>;
|
|
67
|
+
/**
|
|
68
|
+
* Updates static dynamic level rules from raw settings input.
|
|
69
|
+
* Accepts either:
|
|
70
|
+
* - a JSON string containing an array of rules
|
|
71
|
+
* - an in-memory array of rules
|
|
72
|
+
*
|
|
73
|
+
* Invalid rules are ignored; parse errors clear rules and warn.
|
|
74
|
+
*/
|
|
75
|
+
static setDynamicLevelRules(raw: unknown): void;
|
|
13
76
|
constructor(defaultLevel?: LogLevel, prefix?: string);
|
|
14
77
|
/**
|
|
15
78
|
* Sets the prefix for log messages
|
|
@@ -28,6 +91,22 @@ export declare class LevelLogger {
|
|
|
28
91
|
*/
|
|
29
92
|
getLevel(): LogLevel;
|
|
30
93
|
getLevelValue(): number;
|
|
94
|
+
/**
|
|
95
|
+
* Sets per-instance dynamic rules. These are evaluated along with global rules
|
|
96
|
+
* using the active priority preset.
|
|
97
|
+
*/
|
|
98
|
+
setInstanceDynamicLevelRules(raw: unknown): void;
|
|
99
|
+
private static isRecord;
|
|
100
|
+
private static isLogLevel;
|
|
101
|
+
private static normalizeStringArray;
|
|
102
|
+
private static compileRegexArray;
|
|
103
|
+
private static compileMatchRule;
|
|
104
|
+
private static compileDynamicLevelRules;
|
|
105
|
+
private static compileDynamicLevelRulesFromRaw;
|
|
106
|
+
private static matchesCompiledMatchRule;
|
|
107
|
+
private static resolveDynamicLevelFromRules;
|
|
108
|
+
private static resolveDynamicLevel;
|
|
109
|
+
private resolveEffectiveLevel;
|
|
31
110
|
/**
|
|
32
111
|
* Logs a debug message
|
|
33
112
|
*/
|
|
@@ -44,6 +123,10 @@ export declare class LevelLogger {
|
|
|
44
123
|
* Logs an error message
|
|
45
124
|
*/
|
|
46
125
|
error(message: string, context?: Record<string, unknown>, overrideLevel?: LogLevel): void;
|
|
126
|
+
/**
|
|
127
|
+
* Logs a message at the specified level
|
|
128
|
+
*/
|
|
129
|
+
log(level: LogLevel, message: string, context?: Record<string, unknown>, overrideLevel?: LogLevel): void;
|
|
47
130
|
/**
|
|
48
131
|
* Tries to parse a string as JSON and format it nicely if it's fully JSON
|
|
49
132
|
*/
|
|
@@ -61,6 +144,7 @@ export declare class LevelLogger {
|
|
|
61
144
|
/**
|
|
62
145
|
* Core logging method that respects the log level and applies prefix
|
|
63
146
|
*/
|
|
64
|
-
private
|
|
147
|
+
private _log;
|
|
65
148
|
}
|
|
149
|
+
export {};
|
|
66
150
|
//# sourceMappingURL=LevelLogger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LevelLogger.d.ts","sourceRoot":"","sources":["../../../../../src/misc/utils/LevelLogger.ts"],"names":[],"mappings":"AAAA,OAAO,K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gB;IAqExB;;OAEG;IACH,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,cAAc,GAAG,gBAAgB,GAAG,IAAI;IAsClG;;;OAGG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,MAAM,GAAE,UAAU,GAAG,gBAAmC,GAAG,IAAI;CAwClG"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1436,9 +1436,52 @@ function stringifySceneAndOps(obj) {
|
|
|
1436
1436
|
/**
|
|
1437
1437
|
* A reusable logger class that supports configurable log levels and prefixes.
|
|
1438
1438
|
* Can be instantiated with a default log level and optionally override per call.
|
|
1439
|
+
*
|
|
1440
|
+
* Dynamic log-level rules:
|
|
1441
|
+
* - Rules are configured once via `LevelLogger.setDynamicLevelRules(raw)`.
|
|
1442
|
+
* - Rules can also be configured per logger instance via `setInstanceDynamicLevelRules(raw)`.
|
|
1443
|
+
* - Rules are compiled into a static runtime-friendly structure for fast matching.
|
|
1444
|
+
* - On every log call, logger resolves dynamic level by rule match:
|
|
1445
|
+
* `overrideLevel` > instance rule > global rule > logger default.
|
|
1446
|
+
*
|
|
1447
|
+
* Rule format (raw):
|
|
1448
|
+
* [
|
|
1449
|
+
* {
|
|
1450
|
+
* "name": "optional label",
|
|
1451
|
+
* "enabled": true,
|
|
1452
|
+
* "setLevel": "debug",
|
|
1453
|
+
* "when": {
|
|
1454
|
+
* "prefix": { "startsWith": ["[node:scene.importAsset"] },
|
|
1455
|
+
* "message": { "startsWith": ["computeAssetSyncStatus"] }
|
|
1456
|
+
* }
|
|
1457
|
+
* }
|
|
1458
|
+
* ]
|
|
1459
|
+
*
|
|
1460
|
+
* Matching semantics:
|
|
1461
|
+
* - Rules are evaluated in order; first match wins.
|
|
1462
|
+
* - `prefix` and `message` conditions are AND-ed when both exist.
|
|
1463
|
+
* - Within each operator list (`startsWith`, `contains`, etc.), values are OR-ed.
|
|
1464
|
+
* - If multiple operators are defined in one block, all operators must pass.
|
|
1465
|
+
* - `not` negates an additional matcher block.
|
|
1466
|
+
* - String matching is case-insensitive; regex is used as provided.
|
|
1467
|
+
*
|
|
1468
|
+
* Priority strategy (fixed):
|
|
1469
|
+
* - `overrideLevel` > first matching instance rule > first matching global rule > logger default.
|
|
1439
1470
|
*/
|
|
1440
1471
|
class LevelLogger {
|
|
1472
|
+
/**
|
|
1473
|
+
* Updates static dynamic level rules from raw settings input.
|
|
1474
|
+
* Accepts either:
|
|
1475
|
+
* - a JSON string containing an array of rules
|
|
1476
|
+
* - an in-memory array of rules
|
|
1477
|
+
*
|
|
1478
|
+
* Invalid rules are ignored; parse errors clear rules and warn.
|
|
1479
|
+
*/
|
|
1480
|
+
static setDynamicLevelRules(raw) {
|
|
1481
|
+
LevelLogger.compiledDynamicLevelRules = LevelLogger.compileDynamicLevelRulesFromRaw(raw);
|
|
1482
|
+
}
|
|
1441
1483
|
constructor(defaultLevel = "info", prefix = "") {
|
|
1484
|
+
this.compiledInstanceDynamicLevelRules = [];
|
|
1442
1485
|
this.defaultLevel = defaultLevel;
|
|
1443
1486
|
this.prefix = prefix;
|
|
1444
1487
|
}
|
|
@@ -1469,29 +1512,179 @@ class LevelLogger {
|
|
|
1469
1512
|
getLevelValue() {
|
|
1470
1513
|
return LevelLogger.levelValues[this.defaultLevel];
|
|
1471
1514
|
}
|
|
1515
|
+
/**
|
|
1516
|
+
* Sets per-instance dynamic rules. These are evaluated along with global rules
|
|
1517
|
+
* using the active priority preset.
|
|
1518
|
+
*/
|
|
1519
|
+
setInstanceDynamicLevelRules(raw) {
|
|
1520
|
+
this.compiledInstanceDynamicLevelRules = LevelLogger.compileDynamicLevelRulesFromRaw(raw);
|
|
1521
|
+
}
|
|
1522
|
+
static isRecord(value) {
|
|
1523
|
+
return value !== null && typeof value === "object";
|
|
1524
|
+
}
|
|
1525
|
+
static isLogLevel(value) {
|
|
1526
|
+
return typeof value === "string" && value in LevelLogger.levelValues;
|
|
1527
|
+
}
|
|
1528
|
+
static normalizeStringArray(input) {
|
|
1529
|
+
if (typeof input === "string")
|
|
1530
|
+
return [input];
|
|
1531
|
+
if (!Array.isArray(input))
|
|
1532
|
+
return [];
|
|
1533
|
+
return input.filter((v) => typeof v === "string");
|
|
1534
|
+
}
|
|
1535
|
+
static compileRegexArray(input) {
|
|
1536
|
+
const patterns = LevelLogger.normalizeStringArray(input);
|
|
1537
|
+
const compiled = [];
|
|
1538
|
+
for (const pattern of patterns) {
|
|
1539
|
+
try {
|
|
1540
|
+
compiled.push(new RegExp(pattern));
|
|
1541
|
+
}
|
|
1542
|
+
catch (err) {
|
|
1543
|
+
console.warn(`[LevelLogger] Invalid regex in dynamic level rule: ${pattern}`, err);
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
return compiled;
|
|
1547
|
+
}
|
|
1548
|
+
static compileMatchRule(input) {
|
|
1549
|
+
if (!LevelLogger.isRecord(input))
|
|
1550
|
+
return undefined;
|
|
1551
|
+
const equals = LevelLogger.normalizeStringArray(input.equals).map((v) => v.toLowerCase());
|
|
1552
|
+
const startsWith = LevelLogger.normalizeStringArray(input.startsWith).map((v) => v.toLowerCase());
|
|
1553
|
+
const contains = LevelLogger.normalizeStringArray(input.contains).map((v) => v.toLowerCase());
|
|
1554
|
+
const regex = LevelLogger.compileRegexArray(input.regex);
|
|
1555
|
+
let not;
|
|
1556
|
+
if (LevelLogger.isRecord(input.not)) {
|
|
1557
|
+
not = {
|
|
1558
|
+
equals: LevelLogger.normalizeStringArray(input.not.equals).map((v) => v.toLowerCase()),
|
|
1559
|
+
startsWith: LevelLogger.normalizeStringArray(input.not.startsWith).map((v) => v.toLowerCase()),
|
|
1560
|
+
contains: LevelLogger.normalizeStringArray(input.not.contains).map((v) => v.toLowerCase()),
|
|
1561
|
+
regex: LevelLogger.compileRegexArray(input.not.regex),
|
|
1562
|
+
};
|
|
1563
|
+
}
|
|
1564
|
+
if (!equals.length && !startsWith.length && !contains.length && !regex.length && !not)
|
|
1565
|
+
return undefined;
|
|
1566
|
+
return { equals, startsWith, contains, regex, not };
|
|
1567
|
+
}
|
|
1568
|
+
static compileDynamicLevelRules(raw) {
|
|
1569
|
+
if (!Array.isArray(raw)) {
|
|
1570
|
+
console.warn("[LevelLogger] Dynamic level rules must be an array. Ignoring value.");
|
|
1571
|
+
return [];
|
|
1572
|
+
}
|
|
1573
|
+
const compiled = [];
|
|
1574
|
+
for (const item of raw) {
|
|
1575
|
+
if (!LevelLogger.isRecord(item))
|
|
1576
|
+
continue;
|
|
1577
|
+
if (item.enabled === false)
|
|
1578
|
+
continue;
|
|
1579
|
+
if (!LevelLogger.isLogLevel(item.setLevel))
|
|
1580
|
+
continue;
|
|
1581
|
+
let when;
|
|
1582
|
+
if (LevelLogger.isRecord(item.when)) {
|
|
1583
|
+
const prefix = LevelLogger.compileMatchRule(item.when.prefix);
|
|
1584
|
+
const message = LevelLogger.compileMatchRule(item.when.message);
|
|
1585
|
+
if (prefix || message)
|
|
1586
|
+
when = { prefix, message };
|
|
1587
|
+
}
|
|
1588
|
+
compiled.push({
|
|
1589
|
+
name: typeof item.name === "string" ? item.name : undefined,
|
|
1590
|
+
setLevel: item.setLevel,
|
|
1591
|
+
when,
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
1594
|
+
return compiled;
|
|
1595
|
+
}
|
|
1596
|
+
static compileDynamicLevelRulesFromRaw(raw) {
|
|
1597
|
+
if (raw === undefined || raw === null || raw === "")
|
|
1598
|
+
return [];
|
|
1599
|
+
let parsed = raw;
|
|
1600
|
+
if (typeof raw === "string") {
|
|
1601
|
+
try {
|
|
1602
|
+
parsed = JSON.parse(raw);
|
|
1603
|
+
}
|
|
1604
|
+
catch (err) {
|
|
1605
|
+
console.warn("[LevelLogger] Failed to parse dynamic level rules JSON:", err);
|
|
1606
|
+
return [];
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
return LevelLogger.compileDynamicLevelRules(parsed);
|
|
1610
|
+
}
|
|
1611
|
+
static matchesCompiledMatchRule(rule, value, valueLower) {
|
|
1612
|
+
if (!rule)
|
|
1613
|
+
return true;
|
|
1614
|
+
const lower = valueLower ?? value.toLowerCase();
|
|
1615
|
+
if (rule.equals.length > 0 && !rule.equals.some((candidate) => lower === candidate))
|
|
1616
|
+
return false;
|
|
1617
|
+
if (rule.startsWith.length > 0 && !rule.startsWith.some((candidate) => lower.startsWith(candidate)))
|
|
1618
|
+
return false;
|
|
1619
|
+
if (rule.contains.length > 0 && !rule.contains.some((candidate) => lower.includes(candidate)))
|
|
1620
|
+
return false;
|
|
1621
|
+
if (rule.regex.length > 0 && !rule.regex.some((re) => re.test(value)))
|
|
1622
|
+
return false;
|
|
1623
|
+
if (rule.not) {
|
|
1624
|
+
const notMatches = (rule.not.equals.length > 0 && rule.not.equals.some((candidate) => lower === candidate)) ||
|
|
1625
|
+
(rule.not.startsWith.length > 0 && rule.not.startsWith.some((candidate) => lower.startsWith(candidate))) ||
|
|
1626
|
+
(rule.not.contains.length > 0 && rule.not.contains.some((candidate) => lower.includes(candidate))) ||
|
|
1627
|
+
(rule.not.regex.length > 0 && rule.not.regex.some((re) => re.test(value)));
|
|
1628
|
+
if (notMatches)
|
|
1629
|
+
return false;
|
|
1630
|
+
}
|
|
1631
|
+
return true;
|
|
1632
|
+
}
|
|
1633
|
+
static resolveDynamicLevelFromRules(prefix, message, rules) {
|
|
1634
|
+
const prefixLower = prefix.toLowerCase();
|
|
1635
|
+
const messageLower = message.toLowerCase();
|
|
1636
|
+
for (const rule of rules) {
|
|
1637
|
+
const prefixMatch = LevelLogger.matchesCompiledMatchRule(rule.when?.prefix, prefix, prefixLower);
|
|
1638
|
+
if (!prefixMatch)
|
|
1639
|
+
continue;
|
|
1640
|
+
const messageMatch = LevelLogger.matchesCompiledMatchRule(rule.when?.message, message, messageLower);
|
|
1641
|
+
if (!messageMatch)
|
|
1642
|
+
continue;
|
|
1643
|
+
return rule.setLevel;
|
|
1644
|
+
}
|
|
1645
|
+
return undefined;
|
|
1646
|
+
}
|
|
1647
|
+
static resolveDynamicLevel(prefix, message) {
|
|
1648
|
+
return LevelLogger.resolveDynamicLevelFromRules(prefix, message, LevelLogger.compiledDynamicLevelRules);
|
|
1649
|
+
}
|
|
1650
|
+
resolveEffectiveLevel(message, overrideLevel) {
|
|
1651
|
+
if (overrideLevel)
|
|
1652
|
+
return overrideLevel;
|
|
1653
|
+
const instanceDynamic = LevelLogger.resolveDynamicLevelFromRules(this.prefix, message, this.compiledInstanceDynamicLevelRules);
|
|
1654
|
+
const globalDynamic = LevelLogger.resolveDynamicLevel(this.prefix, message);
|
|
1655
|
+
return instanceDynamic ?? globalDynamic ?? this.defaultLevel;
|
|
1656
|
+
}
|
|
1472
1657
|
/**
|
|
1473
1658
|
* Logs a debug message
|
|
1474
1659
|
*/
|
|
1475
1660
|
debug(message, context, overrideLevel) {
|
|
1476
|
-
this.
|
|
1661
|
+
this._log("debug", message, context, overrideLevel);
|
|
1477
1662
|
}
|
|
1478
1663
|
/**
|
|
1479
1664
|
* Logs an info message
|
|
1480
1665
|
*/
|
|
1481
1666
|
info(message, context, overrideLevel) {
|
|
1482
|
-
this.
|
|
1667
|
+
this._log("info", message, context, overrideLevel);
|
|
1483
1668
|
}
|
|
1484
1669
|
/**
|
|
1485
1670
|
* Logs a warning message
|
|
1486
1671
|
*/
|
|
1487
1672
|
warn(message, context, overrideLevel) {
|
|
1488
|
-
this.
|
|
1673
|
+
this._log("warn", message, context, overrideLevel);
|
|
1489
1674
|
}
|
|
1490
1675
|
/**
|
|
1491
1676
|
* Logs an error message
|
|
1492
1677
|
*/
|
|
1493
1678
|
error(message, context, overrideLevel) {
|
|
1494
|
-
this.
|
|
1679
|
+
this._log("error", message, context, overrideLevel);
|
|
1680
|
+
}
|
|
1681
|
+
/**
|
|
1682
|
+
* Logs a message at the specified level
|
|
1683
|
+
*/
|
|
1684
|
+
log(level, message, context, overrideLevel) {
|
|
1685
|
+
if (level === "silent")
|
|
1686
|
+
return;
|
|
1687
|
+
this._log(level, message, context, overrideLevel);
|
|
1495
1688
|
}
|
|
1496
1689
|
/**
|
|
1497
1690
|
* Tries to parse a string as JSON and format it nicely if it's fully JSON
|
|
@@ -1558,8 +1751,8 @@ class LevelLogger {
|
|
|
1558
1751
|
/**
|
|
1559
1752
|
* Core logging method that respects the log level and applies prefix
|
|
1560
1753
|
*/
|
|
1561
|
-
|
|
1562
|
-
const effectiveLevel =
|
|
1754
|
+
_log(requestedLevel, message, context, overrideLevel) {
|
|
1755
|
+
const effectiveLevel = this.resolveEffectiveLevel(message, overrideLevel);
|
|
1563
1756
|
// Silent level suppresses all logs
|
|
1564
1757
|
if (effectiveLevel === "silent") {
|
|
1565
1758
|
return;
|
|
@@ -1652,6 +1845,7 @@ class LevelLogger {
|
|
|
1652
1845
|
}
|
|
1653
1846
|
}
|
|
1654
1847
|
}
|
|
1848
|
+
LevelLogger.compiledDynamicLevelRules = [];
|
|
1655
1849
|
/**
|
|
1656
1850
|
* Maps log levels to numeric values for comparison
|
|
1657
1851
|
*/
|
|
@@ -2999,20 +3193,7 @@ class NodeExecutor {
|
|
|
2999
3193
|
const nodeLogLevel = node?.logLevel ?? "info";
|
|
3000
3194
|
const logger = new LevelLogger(nodeLogLevel, `[node:${formatNodeRef(this.graph, nodeId)}:${runId}]`);
|
|
3001
3195
|
const log = (level, message, context) => {
|
|
3002
|
-
|
|
3003
|
-
case "debug":
|
|
3004
|
-
logger.debug(message, context);
|
|
3005
|
-
break;
|
|
3006
|
-
case "info":
|
|
3007
|
-
logger.info(message, context);
|
|
3008
|
-
break;
|
|
3009
|
-
case "warn":
|
|
3010
|
-
logger.warn(message, context);
|
|
3011
|
-
break;
|
|
3012
|
-
case "error":
|
|
3013
|
-
logger.error(message, context);
|
|
3014
|
-
break;
|
|
3015
|
-
}
|
|
3196
|
+
logger.log(level, message, context);
|
|
3016
3197
|
};
|
|
3017
3198
|
return {
|
|
3018
3199
|
nodeId,
|