@putkoff/abstract-logger 0.0.35 โ 0.0.38
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/dist/cjs/index.js +389 -269
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/config.d.ts +4 -0
- package/dist/cjs/types/imports/constants.d.ts +8 -0
- package/dist/cjs/types/imports/functions.d.ts +16 -0
- package/dist/cjs/types/imports/index.d.ts +5 -0
- package/dist/cjs/types/imports/init_imports.d.ts +1 -0
- package/dist/cjs/types/imports/nodeLogger.d.ts +3 -0
- package/dist/cjs/types/imports/utils/detect.d.ts +10 -0
- package/dist/cjs/types/imports/utils/index.d.ts +2 -0
- package/dist/cjs/types/imports/utils/utils.d.ts +8 -0
- package/dist/cjs/types/index.d.ts +1 -1
- package/dist/cjs/types/logger/blocker.d.ts +4 -0
- package/dist/cjs/types/logger/logger.d.ts +1 -18
- package/dist/cjs/types/types/index.d.ts +1 -0
- package/dist/cjs/types/types/types.d.ts +10 -0
- package/dist/esm/index.js +377 -270
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/config.d.ts +4 -0
- package/dist/esm/types/imports/constants.d.ts +8 -0
- package/dist/esm/types/imports/functions.d.ts +16 -0
- package/dist/esm/types/imports/index.d.ts +5 -0
- package/dist/esm/types/imports/init_imports.d.ts +1 -0
- package/dist/esm/types/imports/nodeLogger.d.ts +3 -0
- package/dist/esm/types/imports/utils/detect.d.ts +10 -0
- package/dist/esm/types/imports/utils/index.d.ts +2 -0
- package/dist/esm/types/imports/utils/utils.d.ts +8 -0
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/types/logger/blocker.d.ts +4 -0
- package/dist/esm/types/logger/logger.d.ts +1 -18
- package/dist/esm/types/types/index.d.ts +1 -0
- package/dist/esm/types/types/types.d.ts +10 -0
- package/dist/types/config.d.ts +4 -0
- package/dist/types/imports/constants.d.ts +8 -0
- package/dist/types/imports/functions.d.ts +16 -0
- package/dist/types/imports/index.d.ts +5 -0
- package/dist/types/imports/init_imports.d.ts +1 -0
- package/dist/types/imports/nodeLogger.d.ts +3 -0
- package/dist/types/imports/utils/detect.d.ts +10 -0
- package/dist/types/imports/utils/index.d.ts +2 -0
- package/dist/types/imports/utils/utils.d.ts +8 -0
- package/dist/types/index.d.ts +51 -11
- package/dist/types/logger/blocker.d.ts +4 -0
- package/dist/types/logger/logger.d.ts +1 -18
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/types.d.ts +10 -0
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -10,7 +10,210 @@ import require$$1 from 'tty';
|
|
|
10
10
|
import require$$1$1 from 'string_decoder';
|
|
11
11
|
import require$$0$7 from 'http';
|
|
12
12
|
import require$$1$3 from 'https';
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
/* ------------------------------------------------------------------ */
|
|
15
|
+
/* Stack inspection */
|
|
16
|
+
/* ------------------------------------------------------------------ */
|
|
17
|
+
function padRight(str, width) {
|
|
18
|
+
return str.length >= width ? str : str + " ".repeat(width - str.length);
|
|
19
|
+
}
|
|
20
|
+
function padLeft(str, width) {
|
|
21
|
+
return str.length >= width ? str : " ".repeat(width - str.length) + str;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Normalizes inputs by treating "unknown" and empty values as null.
|
|
25
|
+
* Returns "unknown" ONLY if all inputs are invalid.
|
|
26
|
+
*/
|
|
27
|
+
function resolveValue(...values) {
|
|
28
|
+
let sawInput = false;
|
|
29
|
+
for (const value of values) {
|
|
30
|
+
if (value === undefined || value === null)
|
|
31
|
+
continue;
|
|
32
|
+
sawInput = true;
|
|
33
|
+
if (typeof value === "string") {
|
|
34
|
+
const v = value.trim();
|
|
35
|
+
if (!v || v.toLowerCase() === "unknown")
|
|
36
|
+
continue;
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
return sawInput ? "unknown" : "unknown";
|
|
42
|
+
}
|
|
43
|
+
function parseList(value) {
|
|
44
|
+
return value
|
|
45
|
+
? value.split(",").map(s => s.trim()).filter(Boolean)
|
|
46
|
+
: [];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** ---------------------------------------------------------
|
|
50
|
+
* Detect Environment
|
|
51
|
+
* --------------------------------------------------------- */
|
|
52
|
+
const IS_BROWSER = typeof window !== "undefined" &&
|
|
53
|
+
typeof window.document !== "undefined";
|
|
54
|
+
const IS_NODE = typeof process !== "undefined" &&
|
|
55
|
+
process.release?.name === "node";
|
|
56
|
+
/* ------------------------------------------------------------------ */
|
|
57
|
+
/* Stack inspection */
|
|
58
|
+
/* ------------------------------------------------------------------ */
|
|
59
|
+
function extractFile(frame) {
|
|
60
|
+
// file:///path/to/file.ts:line:col
|
|
61
|
+
const esmMatch = frame.match(/file:\/\/(.+?):\d+:\d+/);
|
|
62
|
+
if (esmMatch)
|
|
63
|
+
return esmMatch[1];
|
|
64
|
+
// (path/to/file.ts:line:col)
|
|
65
|
+
const cjsMatch = frame.match(/\((.+?):\d+:\d+\)/);
|
|
66
|
+
if (cjsMatch)
|
|
67
|
+
return cjsMatch[1];
|
|
68
|
+
// at path/to/file.ts:line:col
|
|
69
|
+
const bareMatch = frame.match(/at\s+(.+?):\d+:\d+/);
|
|
70
|
+
if (bareMatch)
|
|
71
|
+
return bareMatch[1];
|
|
72
|
+
return "unknown";
|
|
73
|
+
}
|
|
74
|
+
function getCallerInfo(func) {
|
|
75
|
+
if (!IS_NODE) {
|
|
76
|
+
return { functionName: "browser", file: "browser" };
|
|
77
|
+
}
|
|
78
|
+
const obj = {};
|
|
79
|
+
Error.captureStackTrace(obj, func);
|
|
80
|
+
const stack = obj.stack?.split("\n") ?? [];
|
|
81
|
+
const frame = stack
|
|
82
|
+
.slice(1)
|
|
83
|
+
.find((line) => !line.includes("node:internal") &&
|
|
84
|
+
!line.includes("processTicksAndRejections"));
|
|
85
|
+
if (!frame) {
|
|
86
|
+
return { functionName: "unknown", file: "unknown" };
|
|
87
|
+
}
|
|
88
|
+
const fnMatch = frame.match(/at\s+async\s+([^\s(]+)/) ||
|
|
89
|
+
frame.match(/at\s+([^\s(]+)/);
|
|
90
|
+
return {
|
|
91
|
+
functionName: fnMatch?.[1] && fnMatch[1] !== "Object.<anonymous>"
|
|
92
|
+
? fnMatch[1]
|
|
93
|
+
: "unknown",
|
|
94
|
+
file: extractFile(frame),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const activityEmojiMap = {
|
|
99
|
+
emitting: "๐ค",
|
|
100
|
+
ingesting: "๐ฅ",
|
|
101
|
+
streaming: "๐",
|
|
102
|
+
forwarding: "โก๏ธ",
|
|
103
|
+
receiving: "๐ก",
|
|
104
|
+
relaying: "๐",
|
|
105
|
+
syncing: "๐",
|
|
106
|
+
buffering: "โณ",
|
|
107
|
+
batching: "๐ฆ",
|
|
108
|
+
dispatching: "๐",
|
|
109
|
+
settings: "โ๏ธ",
|
|
110
|
+
computing: "๐ง ",
|
|
111
|
+
running: "๐",
|
|
112
|
+
working: "๐ง",
|
|
113
|
+
building: "๐๏ธ",
|
|
114
|
+
compiling: "๐งฉ",
|
|
115
|
+
crunching: "๐งฎ",
|
|
116
|
+
optimizing: "๐",
|
|
117
|
+
queued: "๐",
|
|
118
|
+
waiting: "โณ",
|
|
119
|
+
active: "โถ๏ธ",
|
|
120
|
+
paused: "โธ๏ธ",
|
|
121
|
+
sleeping: "๐ค",
|
|
122
|
+
resumed: "๐",
|
|
123
|
+
completed: "โ
",
|
|
124
|
+
cancelled: "โ",
|
|
125
|
+
expired: "โ",
|
|
126
|
+
warning: "โ ๏ธ",
|
|
127
|
+
error: "โ",
|
|
128
|
+
critical: "๐จ",
|
|
129
|
+
retrying: "๐",
|
|
130
|
+
skipped: "โญ๏ธ",
|
|
131
|
+
fallback: "๐",
|
|
132
|
+
degraded: "๐",
|
|
133
|
+
saved: "๐พ",
|
|
134
|
+
loading: "๐",
|
|
135
|
+
exporting: "๐ค",
|
|
136
|
+
importing: "๐ฅ",
|
|
137
|
+
archived: "๐๏ธ",
|
|
138
|
+
deleted: "๐๏ธ",
|
|
139
|
+
cached: "๐ง",
|
|
140
|
+
persisted: "๐",
|
|
141
|
+
locked: "๐",
|
|
142
|
+
unlocked: "๐",
|
|
143
|
+
secure: "๐ก๏ธ",
|
|
144
|
+
insecure: "โ ๏ธ",
|
|
145
|
+
verified: "โ๏ธ",
|
|
146
|
+
blocked: "โ",
|
|
147
|
+
allowed: "๐ข",
|
|
148
|
+
connected: "๐",
|
|
149
|
+
disconnected: "โ",
|
|
150
|
+
online: "๐ข",
|
|
151
|
+
offline: "๐ด",
|
|
152
|
+
latency: "๐ถ",
|
|
153
|
+
proxying: "๐งญ",
|
|
154
|
+
broadcasting: "๐ฃ",
|
|
155
|
+
thinking: "๐ค",
|
|
156
|
+
learning: "๐ง ",
|
|
157
|
+
predicting: "๐ฎ",
|
|
158
|
+
scanning: "๐",
|
|
159
|
+
crawling: "๐ท๏ธ",
|
|
160
|
+
responding: "๐ฌ",
|
|
161
|
+
generating: "โจ",
|
|
162
|
+
debug: "๐",
|
|
163
|
+
trace: "๐งต",
|
|
164
|
+
inspect: "๐",
|
|
165
|
+
test: "๐งช",
|
|
166
|
+
mock: "๐ญ",
|
|
167
|
+
sandbox: "๐๏ธ",
|
|
168
|
+
experiment: "โ๏ธ",
|
|
169
|
+
success: "โ
",
|
|
170
|
+
processing: "๐",
|
|
171
|
+
listening: "๐ก",
|
|
172
|
+
prune: "๐งน",
|
|
173
|
+
connect: "๐",
|
|
174
|
+
info: "โน๏ธ",
|
|
175
|
+
warn: "โ ๏ธ"
|
|
176
|
+
};
|
|
177
|
+
const COLS = {
|
|
178
|
+
emoji: 2,
|
|
179
|
+
timestamp: 24,
|
|
180
|
+
function: 28,
|
|
181
|
+
message: 0, // flexible
|
|
182
|
+
file: 16,
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/* ------------------------------------------------------------------ */
|
|
186
|
+
/* Winston logger (Node only) */
|
|
187
|
+
/* ------------------------------------------------------------------ */
|
|
188
|
+
console.log("ENV CHECK:", {
|
|
189
|
+
LOG_SHOW_DETAILS: process.env.LOG_SHOW_DETAILS,
|
|
190
|
+
LOG_DETAILS_ALLOWLIST: process.env.LOG_DETAILS_ALLOWLIST,
|
|
191
|
+
});
|
|
192
|
+
function getLogConfig() {
|
|
193
|
+
return {
|
|
194
|
+
condensed: process.env.LOG_CONDENSED !== "false",
|
|
195
|
+
expandOnDebug: process.env.LOG_EXPAND_DEBUG !== "false",
|
|
196
|
+
showDetails: process.env.LOG_SHOW_DETAILS !== "false",
|
|
197
|
+
maxDetailsLength: Number(process.env.LOG_DETAILS_MAX ?? 500),
|
|
198
|
+
activityBlocklist: parse$1(process.env.LOG_ACTIVITY_BLOCKLIST),
|
|
199
|
+
logTypeBlocklist: parse$1(process.env.LOG_TYPE_BLOCKLIST),
|
|
200
|
+
sampleRate: Number(process.env.LOG_SAMPLE_RATE ?? 1), // 0โ1
|
|
201
|
+
// ๐ NEW
|
|
202
|
+
prettyDetails: process.env.LOG_PRETTY_DETAILS === "true",
|
|
203
|
+
showDetailslist: process.env.LOG_DETAILS_ALLOWLIST
|
|
204
|
+
? process.env.LOG_DETAILS_ALLOWLIST.split(",").map(s => s.trim())
|
|
205
|
+
: [],
|
|
206
|
+
functionAllowlist: process.env.LOG_FUNCTION_ALLOWLIST
|
|
207
|
+
? process.env.LOG_FUNCTION_ALLOWLIST.split(",").map(s => s.trim())
|
|
208
|
+
: [],
|
|
209
|
+
functionBlocklist: process.env.LOG_FUNCTION_BLOCKLIST
|
|
210
|
+
? process.env.LOG_FUNCTION_BLOCKLIST.split(",").map(s => s.trim())
|
|
211
|
+
: [],
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function parse$1(v) {
|
|
215
|
+
return v ? v.split(",").map(s => s.trim()) : [];
|
|
216
|
+
}
|
|
14
217
|
|
|
15
218
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
16
219
|
|
|
@@ -3219,14 +3422,14 @@ var fecha = {
|
|
|
3219
3422
|
};
|
|
3220
3423
|
|
|
3221
3424
|
var fecha$1 = /*#__PURE__*/Object.freeze({
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3425
|
+
__proto__: null,
|
|
3426
|
+
assign: assign,
|
|
3427
|
+
default: fecha,
|
|
3428
|
+
defaultI18n: defaultI18n,
|
|
3429
|
+
format: format$1,
|
|
3430
|
+
parse: parse,
|
|
3431
|
+
setGlobalDateI18n: setGlobalDateI18n,
|
|
3432
|
+
setGlobalDateMasks: setGlobalDateMasks
|
|
3230
3433
|
});
|
|
3231
3434
|
|
|
3232
3435
|
var require$$0 = /*@__PURE__*/getAugmentedNamespace(fecha$1);
|
|
@@ -14460,137 +14663,70 @@ var container = class Container {
|
|
|
14460
14663
|
warn.forProperties(exports$1, 'deprecated', ['emitErrs', 'levelLength']);
|
|
14461
14664
|
} (winston));
|
|
14462
14665
|
|
|
14463
|
-
|
|
14464
|
-
|
|
14465
|
-
|
|
14466
|
-
const IS_BROWSER = typeof window !== "undefined" &&
|
|
14467
|
-
typeof window.document !== "undefined";
|
|
14468
|
-
const IS_NODE = typeof process !== "undefined" &&
|
|
14469
|
-
process.release?.name === "node";
|
|
14470
|
-
|
|
14471
|
-
function getLogConfig() {
|
|
14472
|
-
return {
|
|
14473
|
-
condensed: process.env.LOG_CONDENSED !== "false",
|
|
14474
|
-
expandOnDebug: process.env.LOG_EXPAND_DEBUG !== "false",
|
|
14475
|
-
showDetails: process.env.LOG_SHOW_DETAILS !== "false",
|
|
14476
|
-
maxDetailsLength: Number(process.env.LOG_DETAILS_MAX ?? 500),
|
|
14477
|
-
showDetailslist: process.env.LOG_DETAILS_ALLOWLIST
|
|
14478
|
-
? process.env.LOG_DETAILS_ALLOWLIST.split(",").map(s => s.trim())
|
|
14479
|
-
: [],
|
|
14480
|
-
functionAllowlist: process.env.LOG_FUNCTION_ALLOWLIST
|
|
14481
|
-
? process.env.LOG_FUNCTION_ALLOWLIST.split(",").map(s => s.trim())
|
|
14482
|
-
: [],
|
|
14483
|
-
functionBlocklist: process.env.LOG_FUNCTION_BLOCKLIST
|
|
14484
|
-
? process.env.LOG_FUNCTION_BLOCKLIST.split(",").map(s => s.trim())
|
|
14485
|
-
: [],
|
|
14486
|
-
};
|
|
14487
|
-
}
|
|
14488
|
-
|
|
14666
|
+
/* ------------------------------------------------------------------ */
|
|
14667
|
+
/* Winston logger (Node only) */
|
|
14668
|
+
/* ------------------------------------------------------------------ */
|
|
14489
14669
|
console.log("ENV CHECK:", {
|
|
14490
14670
|
LOG_SHOW_DETAILS: process.env.LOG_SHOW_DETAILS,
|
|
14491
14671
|
LOG_DETAILS_ALLOWLIST: process.env.LOG_DETAILS_ALLOWLIST,
|
|
14492
14672
|
});
|
|
14493
|
-
|
|
14494
|
-
|
|
14495
|
-
|
|
14496
|
-
|
|
14497
|
-
|
|
14498
|
-
|
|
14499
|
-
|
|
14500
|
-
|
|
14501
|
-
|
|
14502
|
-
|
|
14503
|
-
|
|
14504
|
-
|
|
14505
|
-
|
|
14506
|
-
}
|
|
14507
|
-
function shouldCondense(logType) {
|
|
14508
|
-
const LOG_CONFIG = getLogConfig();
|
|
14509
|
-
if (LOG_CONFIG.expandOnDebug && logType === "debug") {
|
|
14510
|
-
return false;
|
|
14673
|
+
function getNodeLogger() {
|
|
14674
|
+
let nodeLogger = null;
|
|
14675
|
+
if (IS_NODE) {
|
|
14676
|
+
nodeLogger = winston.createLogger({
|
|
14677
|
+
level: "info",
|
|
14678
|
+
format: winston.format.combine(winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), winston.format.errors({ stack: true }), winston.format.printf(({ timestamp, level, message, stack }) => {
|
|
14679
|
+
return `${timestamp} [${level}] ${message}${stack ? "\n" + stack : ""}`;
|
|
14680
|
+
})),
|
|
14681
|
+
transports: [
|
|
14682
|
+
new winston.transports.Console(),
|
|
14683
|
+
new winston.transports.File({ filename: "logs/error.log", level: "error" }),
|
|
14684
|
+
new winston.transports.File({ filename: "logs/combined.log" }),
|
|
14685
|
+
],
|
|
14686
|
+
});
|
|
14511
14687
|
}
|
|
14512
|
-
return
|
|
14688
|
+
return nodeLogger;
|
|
14513
14689
|
}
|
|
14514
|
-
|
|
14515
|
-
|
|
14516
|
-
|
|
14517
|
-
|
|
14690
|
+
const logger = getNodeLogger();
|
|
14691
|
+
function getFinalLine(line, finalLogType, resolvedLoggerInput) {
|
|
14692
|
+
// ---------------- Browser ----------------
|
|
14693
|
+
if (IS_BROWSER) {
|
|
14694
|
+
console[finalLogType === "error"
|
|
14695
|
+
? "error"
|
|
14696
|
+
: finalLogType === "warn"
|
|
14697
|
+
? "warn"
|
|
14698
|
+
: finalLogType === "debug"
|
|
14699
|
+
? "debug"
|
|
14700
|
+
: "log"](line);
|
|
14701
|
+
return line;
|
|
14518
14702
|
}
|
|
14519
|
-
|
|
14520
|
-
|
|
14521
|
-
|
|
14522
|
-
|
|
14523
|
-
|
|
14524
|
-
* Normalizes inputs by treating "unknown" and empty values as null.
|
|
14525
|
-
* Returns "unknown" ONLY if all inputs are invalid.
|
|
14526
|
-
*/
|
|
14527
|
-
function resolveValue(...values) {
|
|
14528
|
-
let sawInput = false;
|
|
14529
|
-
for (const value of values) {
|
|
14530
|
-
if (value === undefined || value === null)
|
|
14531
|
-
continue;
|
|
14532
|
-
sawInput = true;
|
|
14533
|
-
if (typeof value === "string") {
|
|
14534
|
-
const v = value.trim();
|
|
14535
|
-
if (!v || v.toLowerCase() === "unknown")
|
|
14536
|
-
continue;
|
|
14537
|
-
return value;
|
|
14538
|
-
}
|
|
14539
|
-
return value;
|
|
14703
|
+
// ---------------- Node ----------------
|
|
14704
|
+
const activeLogger = resolveLogger(resolvedLoggerInput);
|
|
14705
|
+
if (!activeLogger) {
|
|
14706
|
+
console.log(line);
|
|
14707
|
+
return line;
|
|
14540
14708
|
}
|
|
14541
|
-
|
|
14542
|
-
|
|
14543
|
-
|
|
14544
|
-
|
|
14545
|
-
|
|
14546
|
-
|
|
14547
|
-
|
|
14548
|
-
|
|
14549
|
-
|
|
14550
|
-
|
|
14551
|
-
|
|
14552
|
-
|
|
14553
|
-
|
|
14554
|
-
|
|
14555
|
-
/* ------------------------------------------------------------------ */
|
|
14556
|
-
function extractFile(frame) {
|
|
14557
|
-
// file:///path/to/file.ts:line:col
|
|
14558
|
-
const esmMatch = frame.match(/file:\/\/(.+?):\d+:\d+/);
|
|
14559
|
-
if (esmMatch)
|
|
14560
|
-
return esmMatch[1];
|
|
14561
|
-
// (path/to/file.ts:line:col)
|
|
14562
|
-
const cjsMatch = frame.match(/\((.+?):\d+:\d+\)/);
|
|
14563
|
-
if (cjsMatch)
|
|
14564
|
-
return cjsMatch[1];
|
|
14565
|
-
// at path/to/file.ts:line:col
|
|
14566
|
-
const bareMatch = frame.match(/at\s+(.+?):\d+:\d+/);
|
|
14567
|
-
if (bareMatch)
|
|
14568
|
-
return bareMatch[1];
|
|
14569
|
-
return "unknown";
|
|
14570
|
-
}
|
|
14571
|
-
function getCallerInfo() {
|
|
14572
|
-
if (!IS_NODE) {
|
|
14573
|
-
return { functionName: "browser", file: "browser" };
|
|
14709
|
+
try {
|
|
14710
|
+
switch (finalLogType) {
|
|
14711
|
+
case "error":
|
|
14712
|
+
activeLogger.error(line);
|
|
14713
|
+
break;
|
|
14714
|
+
case "warn":
|
|
14715
|
+
activeLogger.warn(line);
|
|
14716
|
+
break;
|
|
14717
|
+
case "debug":
|
|
14718
|
+
activeLogger.debug(line);
|
|
14719
|
+
break;
|
|
14720
|
+
default:
|
|
14721
|
+
activeLogger.info(line);
|
|
14722
|
+
}
|
|
14574
14723
|
}
|
|
14575
|
-
|
|
14576
|
-
|
|
14577
|
-
const stack = obj.stack?.split("\n") ?? [];
|
|
14578
|
-
const frame = stack
|
|
14579
|
-
.slice(1)
|
|
14580
|
-
.find((line) => !line.includes("node:internal") &&
|
|
14581
|
-
!line.includes("processTicksAndRejections"));
|
|
14582
|
-
if (!frame) {
|
|
14583
|
-
return { functionName: "unknown", file: "unknown" };
|
|
14724
|
+
catch {
|
|
14725
|
+
console.log(line);
|
|
14584
14726
|
}
|
|
14585
|
-
|
|
14586
|
-
frame.match(/at\s+([^\s(]+)/);
|
|
14587
|
-
return {
|
|
14588
|
-
functionName: fnMatch?.[1] && fnMatch[1] !== "Object.<anonymous>"
|
|
14589
|
-
? fnMatch[1]
|
|
14590
|
-
: "unknown",
|
|
14591
|
-
file: extractFile(frame),
|
|
14592
|
-
};
|
|
14727
|
+
return line;
|
|
14593
14728
|
}
|
|
14729
|
+
|
|
14594
14730
|
/* ------------------------------------------------------------------ */
|
|
14595
14731
|
/* Safe logger resolver */
|
|
14596
14732
|
/* ------------------------------------------------------------------ */
|
|
@@ -14607,7 +14743,22 @@ function resolveLogger(candidate) {
|
|
|
14607
14743
|
}
|
|
14608
14744
|
return null;
|
|
14609
14745
|
}
|
|
14610
|
-
function
|
|
14746
|
+
function shouldCondense(logType) {
|
|
14747
|
+
const LOG_CONFIG = getLogConfig();
|
|
14748
|
+
if (LOG_CONFIG.expandOnDebug && logType === "debug") {
|
|
14749
|
+
return false;
|
|
14750
|
+
}
|
|
14751
|
+
return LOG_CONFIG.condensed;
|
|
14752
|
+
}
|
|
14753
|
+
function shouldShowDetails(logType) {
|
|
14754
|
+
const cfg = getLogConfig();
|
|
14755
|
+
if (cfg.showDetailslist.length > 0) {
|
|
14756
|
+
return cfg.showDetailslist.includes(logType);
|
|
14757
|
+
}
|
|
14758
|
+
return cfg.showDetails;
|
|
14759
|
+
}
|
|
14760
|
+
function serializeDetails(value, condensed, maxLength, pretty // ๐ new
|
|
14761
|
+
) {
|
|
14611
14762
|
try {
|
|
14612
14763
|
const seen = new WeakSet();
|
|
14613
14764
|
const json = JSON.stringify(value, (key, val) => {
|
|
@@ -14621,7 +14772,8 @@ function serializeDetails(value, condensed, maxLength) {
|
|
|
14621
14772
|
seen.add(val);
|
|
14622
14773
|
}
|
|
14623
14774
|
return val;
|
|
14624
|
-
}, condensed ?
|
|
14775
|
+
}, pretty && !condensed ? 2 : 0 // ๐ HERE
|
|
14776
|
+
);
|
|
14625
14777
|
if (condensed && json.length > maxLength) {
|
|
14626
14778
|
return json.slice(0, maxLength) + "โฆ";
|
|
14627
14779
|
}
|
|
@@ -14631,6 +14783,71 @@ function serializeDetails(value, condensed, maxLength) {
|
|
|
14631
14783
|
return "[unserializable details]";
|
|
14632
14784
|
}
|
|
14633
14785
|
}
|
|
14786
|
+
function formatLogLine({ emoji, timestamp, functionName, message, details, file, condense, maxDetailsLength, pretty }) {
|
|
14787
|
+
let line = `${padRight(emoji, 3)}` +
|
|
14788
|
+
`[${padRight(timestamp, COLS.timestamp)}] ` +
|
|
14789
|
+
`[${functionName}] ` +
|
|
14790
|
+
`${message}`;
|
|
14791
|
+
if (details !== undefined) {
|
|
14792
|
+
const serialized = serializeDetails(details, condense, maxDetailsLength, pretty);
|
|
14793
|
+
line += ` | ${serialized}`;
|
|
14794
|
+
}
|
|
14795
|
+
line += ` | ${padRight(file, COLS.file)}`;
|
|
14796
|
+
return line;
|
|
14797
|
+
}
|
|
14798
|
+
|
|
14799
|
+
const seen = new Map();
|
|
14800
|
+
function hash(str) {
|
|
14801
|
+
let h = 0;
|
|
14802
|
+
for (let i = 0; i < str.length; i++) {
|
|
14803
|
+
h = (h << 5) - h + str.charCodeAt(i);
|
|
14804
|
+
h |= 0;
|
|
14805
|
+
}
|
|
14806
|
+
return Math.abs(h);
|
|
14807
|
+
}
|
|
14808
|
+
function shouldLog(opts, caller) {
|
|
14809
|
+
const cfg = getLogConfig();
|
|
14810
|
+
const fn = caller.functionName;
|
|
14811
|
+
const type = opts.logType ?? "info";
|
|
14812
|
+
const activity = opts.activity;
|
|
14813
|
+
const message = opts.message;
|
|
14814
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
14815
|
+
// 1๏ธโฃ Hard allowlist (strongest gate)
|
|
14816
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
14817
|
+
if (cfg.functionAllowlist.length > 0) {
|
|
14818
|
+
if (!cfg.functionAllowlist.includes(fn))
|
|
14819
|
+
return false;
|
|
14820
|
+
}
|
|
14821
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
14822
|
+
// 2๏ธโฃ Hard blocklists
|
|
14823
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
14824
|
+
if (cfg.functionBlocklist.includes(fn))
|
|
14825
|
+
return false;
|
|
14826
|
+
if (activity && cfg.activityBlocklist.includes(activity))
|
|
14827
|
+
return false;
|
|
14828
|
+
if (cfg.logTypeBlocklist.includes(type))
|
|
14829
|
+
return false;
|
|
14830
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
14831
|
+
// 3๏ธโฃ Burst protection (debug spam)
|
|
14832
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
14833
|
+
if (type === "debug") {
|
|
14834
|
+
const key = fn + ":" + message;
|
|
14835
|
+
const count = (seen.get(key) ?? 0) + 1;
|
|
14836
|
+
seen.set(key, count);
|
|
14837
|
+
if (count > 5)
|
|
14838
|
+
return false; // drop after 5 identical logs
|
|
14839
|
+
}
|
|
14840
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
14841
|
+
// 4๏ธโฃ Deterministic sampling
|
|
14842
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
14843
|
+
if (cfg.sampleRate < 1) {
|
|
14844
|
+
const pct = (hash(fn) % 100) / 100;
|
|
14845
|
+
if (pct > cfg.sampleRate)
|
|
14846
|
+
return false;
|
|
14847
|
+
}
|
|
14848
|
+
return true;
|
|
14849
|
+
}
|
|
14850
|
+
|
|
14634
14851
|
/* ------------------------------------------------------------------ */
|
|
14635
14852
|
/* IMPLEMENTATION */
|
|
14636
14853
|
/* ------------------------------------------------------------------ */
|
|
@@ -14654,154 +14871,44 @@ function getLogString(messageOrOptions, logType = null, details = null, function
|
|
|
14654
14871
|
}
|
|
14655
14872
|
let { message, logType: resolvedLogType, details: resolvedDetails, function_name: resolvedFunctionName, file_location: resolvedFileLocation, consumerLogger: resolvedLoggerInput, } = opts;
|
|
14656
14873
|
// ---------------- Resolve caller info ----------------
|
|
14657
|
-
const
|
|
14658
|
-
|
|
14659
|
-
|
|
14660
|
-
const { functionName } = getCallerInfo();
|
|
14661
|
-
resolvedFunctionName = resolveValue(functionName, resolvedFunctionName);
|
|
14662
|
-
}
|
|
14663
|
-
if (!resolvedFileLocation || resolvedFileLocation === "unknown") {
|
|
14664
|
-
const { file } = getCallerInfo();
|
|
14665
|
-
resolvedFileLocation = resolveValue(file, resolvedFileLocation);
|
|
14874
|
+
const caller = getCallerInfo(getLogString);
|
|
14875
|
+
if (!shouldLog(opts, caller)) {
|
|
14876
|
+
return ""; // ๐ blocked โ nothing emitted
|
|
14666
14877
|
}
|
|
14667
|
-
|
|
14668
|
-
|
|
14669
|
-
|
|
14670
|
-
streaming: "๐",
|
|
14671
|
-
forwarding: "โก๏ธ",
|
|
14672
|
-
receiving: "๐ก",
|
|
14673
|
-
relaying: "๐",
|
|
14674
|
-
syncing: "๐",
|
|
14675
|
-
buffering: "โณ",
|
|
14676
|
-
batching: "๐ฆ",
|
|
14677
|
-
dispatching: "๐",
|
|
14678
|
-
settings: "โ๏ธ",
|
|
14679
|
-
computing: "๐ง ",
|
|
14680
|
-
running: "๐",
|
|
14681
|
-
working: "๐ง",
|
|
14682
|
-
building: "๐๏ธ",
|
|
14683
|
-
compiling: "๐งฉ",
|
|
14684
|
-
crunching: "๐งฎ",
|
|
14685
|
-
optimizing: "๐",
|
|
14686
|
-
queued: "๐",
|
|
14687
|
-
waiting: "โณ",
|
|
14688
|
-
active: "โถ๏ธ",
|
|
14689
|
-
paused: "โธ๏ธ",
|
|
14690
|
-
sleeping: "๐ค",
|
|
14691
|
-
resumed: "๐",
|
|
14692
|
-
completed: "โ
",
|
|
14693
|
-
cancelled: "โ",
|
|
14694
|
-
expired: "โ",
|
|
14695
|
-
warning: "โ ๏ธ",
|
|
14696
|
-
error: "โ",
|
|
14697
|
-
critical: "๐จ",
|
|
14698
|
-
retrying: "๐",
|
|
14699
|
-
skipped: "โญ๏ธ",
|
|
14700
|
-
fallback: "๐",
|
|
14701
|
-
degraded: "๐",
|
|
14702
|
-
saved: "๐พ",
|
|
14703
|
-
loading: "๐",
|
|
14704
|
-
exporting: "๐ค",
|
|
14705
|
-
importing: "๐ฅ",
|
|
14706
|
-
archived: "๐๏ธ",
|
|
14707
|
-
deleted: "๐๏ธ",
|
|
14708
|
-
cached: "๐ง",
|
|
14709
|
-
persisted: "๐",
|
|
14710
|
-
locked: "๐",
|
|
14711
|
-
unlocked: "๐",
|
|
14712
|
-
secure: "๐ก๏ธ",
|
|
14713
|
-
insecure: "โ ๏ธ",
|
|
14714
|
-
verified: "โ๏ธ",
|
|
14715
|
-
blocked: "โ",
|
|
14716
|
-
allowed: "๐ข",
|
|
14717
|
-
connected: "๐",
|
|
14718
|
-
disconnected: "โ",
|
|
14719
|
-
online: "๐ข",
|
|
14720
|
-
offline: "๐ด",
|
|
14721
|
-
latency: "๐ถ",
|
|
14722
|
-
proxying: "๐งญ",
|
|
14723
|
-
broadcasting: "๐ฃ",
|
|
14724
|
-
thinking: "๐ค",
|
|
14725
|
-
learning: "๐ง ",
|
|
14726
|
-
predicting: "๐ฎ",
|
|
14727
|
-
scanning: "๐",
|
|
14728
|
-
crawling: "๐ท๏ธ",
|
|
14729
|
-
responding: "๐ฌ",
|
|
14730
|
-
generating: "โจ",
|
|
14731
|
-
debug: "๐",
|
|
14732
|
-
trace: "๐งต",
|
|
14733
|
-
inspect: "๐",
|
|
14734
|
-
test: "๐งช",
|
|
14735
|
-
mock: "๐ญ",
|
|
14736
|
-
sandbox: "๐๏ธ",
|
|
14737
|
-
experiment: "โ๏ธ",
|
|
14738
|
-
success: "โ
",
|
|
14739
|
-
processing: "๐",
|
|
14740
|
-
listening: "๐ก",
|
|
14741
|
-
prune: "๐งน",
|
|
14742
|
-
connect: "๐",
|
|
14743
|
-
info: "โน๏ธ",
|
|
14744
|
-
warn: "โ ๏ธ"
|
|
14745
|
-
};
|
|
14878
|
+
// ---------------- Resolve caller info ----------------
|
|
14879
|
+
resolvedFunctionName = resolveValue(resolvedFunctionName, caller.functionName);
|
|
14880
|
+
resolvedFileLocation = resolveValue(resolvedFileLocation, caller.file);
|
|
14746
14881
|
const finalLogType = resolvedLogType ?? "info";
|
|
14747
|
-
const emoji =
|
|
14748
|
-
|
|
14882
|
+
const emoji = activityEmojiMap[opts.activity ?? ""] ??
|
|
14883
|
+
"โน๏ธ";
|
|
14884
|
+
const LOG_CONFIG = getLogConfig();
|
|
14749
14885
|
const condense = shouldCondense(finalLogType);
|
|
14750
14886
|
const showDetails = shouldShowDetails(finalLogType);
|
|
14887
|
+
// ๐ ADD THIS
|
|
14888
|
+
const pretty = LOG_CONFIG.prettyDetails &&
|
|
14889
|
+
!condense;
|
|
14890
|
+
const timestamp = new Date().toISOString();
|
|
14751
14891
|
if (condense) {
|
|
14752
14892
|
resolvedFileLocation = resolvedFileLocation.split("/").pop();
|
|
14753
14893
|
}
|
|
14754
|
-
|
|
14755
|
-
|
|
14756
|
-
|
|
14757
|
-
const fileName = padRight(resolvedFileLocation.trim(), COLS.file);
|
|
14758
|
-
let line = `${emojiCol}` +
|
|
14759
|
-
`[${ts}] ` +
|
|
14760
|
-
`[${fn}] ` +
|
|
14761
|
-
`${message}`;
|
|
14894
|
+
padRight(emoji, 3);
|
|
14895
|
+
padRight(timestamp, COLS.timestamp);
|
|
14896
|
+
padRight(resolvedFileLocation.trim(), COLS.file);
|
|
14762
14897
|
if (showDetails && resolvedDetails !== null && resolvedDetails !== undefined) {
|
|
14763
|
-
|
|
14764
|
-
const serialized = serializeDetails(resolvedDetails, condense, LOG_CONFIG.maxDetailsLength);
|
|
14765
|
-
line += ` | ${serialized}`;
|
|
14898
|
+
serializeDetails(resolvedDetails, condense, LOG_CONFIG.maxDetailsLength, pretty);
|
|
14766
14899
|
}
|
|
14767
|
-
|
|
14768
|
-
|
|
14769
|
-
|
|
14770
|
-
|
|
14771
|
-
|
|
14772
|
-
|
|
14773
|
-
|
|
14774
|
-
|
|
14775
|
-
|
|
14776
|
-
|
|
14777
|
-
|
|
14778
|
-
}
|
|
14779
|
-
// ---------------- Node ----------------
|
|
14780
|
-
const activeLogger = resolveLogger(resolvedLoggerInput);
|
|
14781
|
-
if (!activeLogger) {
|
|
14782
|
-
console.log(line);
|
|
14783
|
-
return line;
|
|
14784
|
-
}
|
|
14785
|
-
try {
|
|
14786
|
-
switch (finalLogType) {
|
|
14787
|
-
case "error":
|
|
14788
|
-
activeLogger.error(line);
|
|
14789
|
-
break;
|
|
14790
|
-
case "warn":
|
|
14791
|
-
activeLogger.warn(line);
|
|
14792
|
-
break;
|
|
14793
|
-
case "debug":
|
|
14794
|
-
activeLogger.debug(line);
|
|
14795
|
-
break;
|
|
14796
|
-
default:
|
|
14797
|
-
activeLogger.info(line);
|
|
14798
|
-
}
|
|
14799
|
-
}
|
|
14800
|
-
catch {
|
|
14801
|
-
console.log(line);
|
|
14802
|
-
}
|
|
14803
|
-
return line;
|
|
14900
|
+
return getFinalLine(formatLogLine({
|
|
14901
|
+
emoji,
|
|
14902
|
+
timestamp,
|
|
14903
|
+
functionName: resolvedFunctionName,
|
|
14904
|
+
message,
|
|
14905
|
+
details: showDetails ? resolvedDetails : undefined,
|
|
14906
|
+
file: resolvedFileLocation,
|
|
14907
|
+
condense,
|
|
14908
|
+
maxDetailsLength: LOG_CONFIG.maxDetailsLength,
|
|
14909
|
+
pretty, // ๐ THIS IS THE MISSING WIRE
|
|
14910
|
+
}), finalLogType, resolvedLoggerInput);
|
|
14804
14911
|
}
|
|
14805
14912
|
|
|
14806
|
-
export { IS_BROWSER, IS_NODE, getLogConfig, getLogString, logger, resolveValue, serializeDetails };
|
|
14913
|
+
export { COLS, IS_BROWSER, IS_NODE, activityEmojiMap, extractFile, formatLogLine, getCallerInfo, getFinalLine, getLogConfig, getLogString, getNodeLogger, logger, padLeft, padRight, parseList, resolveLogger, resolveValue, serializeDetails, shouldCondense, shouldShowDetails };
|
|
14807
14914
|
//# sourceMappingURL=index.js.map
|