@eventuras/logger 0.7.0
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 +309 -0
- package/dist/Logger.d.ts +105 -0
- package/dist/Logger.d.ts.map +1 -0
- package/dist/__vite-browser-external-pQ4XsTOI.js +7 -0
- package/dist/chunk-NnHqS4_Y.js +20 -0
- package/dist/esm-B1-Y8LUx.js +1580 -0
- package/dist/esm-wJpbN37y.js +528 -0
- package/dist/httpLogger.d.ts +18 -0
- package/dist/httpLogger.d.ts.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +607 -0
- package/dist/node.d.ts +12 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +2 -0
- package/dist/opentelemetry.d.ts +136 -0
- package/dist/opentelemetry.d.ts.map +1 -0
- package/dist/opentelemetry.js +44 -0
- package/dist/pretty-BTJ0fKhV.js +114 -0
- package/dist/src-V4zpQbfq.js +406 -0
- package/dist/transports/console.d.ts +11 -0
- package/dist/transports/console.d.ts.map +1 -0
- package/dist/transports/pino.d.ts +24 -0
- package/dist/transports/pino.d.ts.map +1 -0
- package/dist/transports/pretty.d.ts +20 -0
- package/dist/transports/pretty.d.ts.map +1 -0
- package/dist/types.d.ts +62 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +84 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
import { a as e, t } from "./chunk-NnHqS4_Y.js";
|
|
2
|
+
import { t as n } from "./pretty-BTJ0fKhV.js";
|
|
3
|
+
//#region ../../node_modules/.pnpm/quick-format-unescaped@4.0.4/node_modules/quick-format-unescaped/index.js
|
|
4
|
+
var r = /* @__PURE__ */ t(((e, t) => {
|
|
5
|
+
function n(e) {
|
|
6
|
+
try {
|
|
7
|
+
return JSON.stringify(e);
|
|
8
|
+
} catch {
|
|
9
|
+
return "\"[Circular]\"";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
t.exports = r;
|
|
13
|
+
function r(e, t, r) {
|
|
14
|
+
var i = r && r.stringify || n, a = 1;
|
|
15
|
+
if (typeof e == "object" && e) {
|
|
16
|
+
var o = t.length + a;
|
|
17
|
+
if (o === 1) return e;
|
|
18
|
+
var s = Array(o);
|
|
19
|
+
s[0] = i(e);
|
|
20
|
+
for (var c = 1; c < o; c++) s[c] = i(t[c]);
|
|
21
|
+
return s.join(" ");
|
|
22
|
+
}
|
|
23
|
+
if (typeof e != "string") return e;
|
|
24
|
+
var l = t.length;
|
|
25
|
+
if (l === 0) return e;
|
|
26
|
+
for (var u = "", d = 1 - a, f = -1, p = e && e.length || 0, m = 0; m < p;) {
|
|
27
|
+
if (e.charCodeAt(m) === 37 && m + 1 < p) {
|
|
28
|
+
switch (f = f > -1 ? f : 0, e.charCodeAt(m + 1)) {
|
|
29
|
+
case 100:
|
|
30
|
+
case 102:
|
|
31
|
+
if (d >= l || t[d] == null) break;
|
|
32
|
+
f < m && (u += e.slice(f, m)), u += Number(t[d]), f = m + 2, m++;
|
|
33
|
+
break;
|
|
34
|
+
case 105:
|
|
35
|
+
if (d >= l || t[d] == null) break;
|
|
36
|
+
f < m && (u += e.slice(f, m)), u += Math.floor(Number(t[d])), f = m + 2, m++;
|
|
37
|
+
break;
|
|
38
|
+
case 79:
|
|
39
|
+
case 111:
|
|
40
|
+
case 106:
|
|
41
|
+
if (d >= l || t[d] === void 0) break;
|
|
42
|
+
f < m && (u += e.slice(f, m));
|
|
43
|
+
var h = typeof t[d];
|
|
44
|
+
if (h === "string") {
|
|
45
|
+
u += "'" + t[d] + "'", f = m + 2, m++;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
if (h === "function") {
|
|
49
|
+
u += t[d].name || "<anonymous>", f = m + 2, m++;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
u += i(t[d]), f = m + 2, m++;
|
|
53
|
+
break;
|
|
54
|
+
case 115:
|
|
55
|
+
if (d >= l) break;
|
|
56
|
+
f < m && (u += e.slice(f, m)), u += String(t[d]), f = m + 2, m++;
|
|
57
|
+
break;
|
|
58
|
+
case 37:
|
|
59
|
+
f < m && (u += e.slice(f, m)), u += "%", f = m + 2, m++, d--;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
++d;
|
|
63
|
+
}
|
|
64
|
+
++m;
|
|
65
|
+
}
|
|
66
|
+
return f === -1 ? e : (f < p && (u += e.slice(f)), u);
|
|
67
|
+
}
|
|
68
|
+
})), i = /* @__PURE__ */ e((/* @__PURE__ */ t(((e, t) => {
|
|
69
|
+
var n = r();
|
|
70
|
+
t.exports = p;
|
|
71
|
+
var i = N().console || {}, a = {
|
|
72
|
+
mapHttpRequest: E,
|
|
73
|
+
mapHttpResponse: E,
|
|
74
|
+
wrapRequestSerializer: D,
|
|
75
|
+
wrapResponseSerializer: D,
|
|
76
|
+
wrapErrorSerializer: D,
|
|
77
|
+
req: E,
|
|
78
|
+
res: E,
|
|
79
|
+
err: w,
|
|
80
|
+
errWithCause: w
|
|
81
|
+
};
|
|
82
|
+
function o(e, t) {
|
|
83
|
+
return e === "silent" ? Infinity : t.levels.values[e];
|
|
84
|
+
}
|
|
85
|
+
var s = Symbol("pino.logFuncs"), c = Symbol("pino.hierarchy"), l = {
|
|
86
|
+
error: "log",
|
|
87
|
+
fatal: "error",
|
|
88
|
+
warn: "error",
|
|
89
|
+
info: "log",
|
|
90
|
+
debug: "log",
|
|
91
|
+
trace: "log"
|
|
92
|
+
};
|
|
93
|
+
function u(e, t) {
|
|
94
|
+
t[c] = {
|
|
95
|
+
logger: t,
|
|
96
|
+
parent: e[c]
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function d(e, t, n) {
|
|
100
|
+
let r = {};
|
|
101
|
+
t.forEach((e) => {
|
|
102
|
+
r[e] = n[e] ? n[e] : i[e] || i[l[e] || "log"] || O;
|
|
103
|
+
}), e[s] = r;
|
|
104
|
+
}
|
|
105
|
+
function f(e, t) {
|
|
106
|
+
return Array.isArray(e) ? e.filter(function(e) {
|
|
107
|
+
return e !== "!stdSerializers.err";
|
|
108
|
+
}) : e === !0 ? Object.keys(t) : !1;
|
|
109
|
+
}
|
|
110
|
+
function p(e) {
|
|
111
|
+
e ||= {}, e.browser = e.browser || {};
|
|
112
|
+
let t = e.browser.transmit;
|
|
113
|
+
if (t && typeof t.send != "function") throw Error("pino: transmit option must have a send function");
|
|
114
|
+
let n = e.browser.write || i;
|
|
115
|
+
e.browser.write && (e.browser.asObject = !0);
|
|
116
|
+
let r = e.serializers || {}, a = f(e.browser.serialize, r), s = e.browser.serialize;
|
|
117
|
+
Array.isArray(e.browser.serialize) && e.browser.serialize.indexOf("!stdSerializers.err") > -1 && (s = !1);
|
|
118
|
+
let c = Object.keys(e.customLevels || {}), l = [
|
|
119
|
+
"error",
|
|
120
|
+
"fatal",
|
|
121
|
+
"warn",
|
|
122
|
+
"info",
|
|
123
|
+
"debug",
|
|
124
|
+
"trace"
|
|
125
|
+
].concat(c);
|
|
126
|
+
typeof n == "function" && l.forEach(function(e) {
|
|
127
|
+
n[e] = n;
|
|
128
|
+
}), (e.enabled === !1 || e.browser.disabled) && (e.level = "silent");
|
|
129
|
+
let p = e.level || "info", h = Object.create(n);
|
|
130
|
+
h.log ||= O, d(h, l, n), u({}, h), Object.defineProperty(h, "levelVal", { get: v }), Object.defineProperty(h, "level", {
|
|
131
|
+
get: y,
|
|
132
|
+
set: b
|
|
133
|
+
});
|
|
134
|
+
let g = {
|
|
135
|
+
transmit: t,
|
|
136
|
+
serialize: a,
|
|
137
|
+
asObject: e.browser.asObject,
|
|
138
|
+
asObjectBindingsOnly: e.browser.asObjectBindingsOnly,
|
|
139
|
+
formatters: e.browser.formatters,
|
|
140
|
+
reportCaller: e.browser.reportCaller,
|
|
141
|
+
levels: l,
|
|
142
|
+
timestamp: T(e),
|
|
143
|
+
messageKey: e.messageKey || "msg",
|
|
144
|
+
onChild: e.onChild || O
|
|
145
|
+
};
|
|
146
|
+
h.levels = m(e), h.level = p, h.isLevelEnabled = function(e) {
|
|
147
|
+
return this.levels.values[e] ? this.levels.values[e] >= this.levels.values[this.level] : !1;
|
|
148
|
+
}, h.setMaxListeners = h.getMaxListeners = h.emit = h.addListener = h.on = h.prependListener = h.once = h.prependOnceListener = h.removeListener = h.removeAllListeners = h.listeners = h.listenerCount = h.eventNames = h.write = h.flush = O, h.serializers = r, h._serialize = a, h._stdErrSerialize = s, h.child = function(...e) {
|
|
149
|
+
return S.call(this, g, ...e);
|
|
150
|
+
}, t && (h._logEvent = C());
|
|
151
|
+
function v() {
|
|
152
|
+
return o(this.level, this);
|
|
153
|
+
}
|
|
154
|
+
function y() {
|
|
155
|
+
return this._level;
|
|
156
|
+
}
|
|
157
|
+
function b(e) {
|
|
158
|
+
if (e !== "silent" && !this.levels.values[e]) throw Error("unknown level " + e);
|
|
159
|
+
this._level = e, _(this, g, h, "error"), _(this, g, h, "fatal"), _(this, g, h, "warn"), _(this, g, h, "info"), _(this, g, h, "debug"), _(this, g, h, "trace"), c.forEach((e) => {
|
|
160
|
+
_(this, g, h, e);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function S(n, i, o) {
|
|
164
|
+
if (!i) throw Error("missing bindings for child Pino");
|
|
165
|
+
o ||= {}, a && i.serializers && (o.serializers = i.serializers);
|
|
166
|
+
let s = o.serializers;
|
|
167
|
+
if (a && s) {
|
|
168
|
+
var c = Object.assign({}, r, s), l = e.browser.serialize === !0 ? Object.keys(c) : a;
|
|
169
|
+
delete i.serializers, x([i], l, c, this._stdErrSerialize);
|
|
170
|
+
}
|
|
171
|
+
function d(e) {
|
|
172
|
+
this._childLevel = (e._childLevel | 0) + 1, this.bindings = i, c && (this.serializers = c, this._serialize = l), t && (this._logEvent = C([].concat(e._logEvent.bindings, i)));
|
|
173
|
+
}
|
|
174
|
+
d.prototype = this;
|
|
175
|
+
let f = new d(this);
|
|
176
|
+
return u(this, f), f.child = function(...e) {
|
|
177
|
+
return S.call(this, n, ...e);
|
|
178
|
+
}, f.level = o.level || this.level, n.onChild(f), f;
|
|
179
|
+
}
|
|
180
|
+
return h;
|
|
181
|
+
}
|
|
182
|
+
function m(e) {
|
|
183
|
+
let t = e.customLevels || {};
|
|
184
|
+
return {
|
|
185
|
+
values: Object.assign({}, p.levels.values, t),
|
|
186
|
+
labels: Object.assign({}, p.levels.labels, h(t))
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function h(e) {
|
|
190
|
+
let t = {};
|
|
191
|
+
return Object.keys(e).forEach(function(n) {
|
|
192
|
+
t[e[n]] = n;
|
|
193
|
+
}), t;
|
|
194
|
+
}
|
|
195
|
+
p.levels = {
|
|
196
|
+
values: {
|
|
197
|
+
fatal: 60,
|
|
198
|
+
error: 50,
|
|
199
|
+
warn: 40,
|
|
200
|
+
info: 30,
|
|
201
|
+
debug: 20,
|
|
202
|
+
trace: 10
|
|
203
|
+
},
|
|
204
|
+
labels: {
|
|
205
|
+
10: "trace",
|
|
206
|
+
20: "debug",
|
|
207
|
+
30: "info",
|
|
208
|
+
40: "warn",
|
|
209
|
+
50: "error",
|
|
210
|
+
60: "fatal"
|
|
211
|
+
}
|
|
212
|
+
}, p.stdSerializers = a, p.stdTimeFunctions = Object.assign({}, {
|
|
213
|
+
nullTime: k,
|
|
214
|
+
epochTime: A,
|
|
215
|
+
unixTime: j,
|
|
216
|
+
isoTime: M
|
|
217
|
+
});
|
|
218
|
+
function g(e) {
|
|
219
|
+
let t = [];
|
|
220
|
+
e.bindings && t.push(e.bindings);
|
|
221
|
+
let n = e[c];
|
|
222
|
+
for (; n.parent;) n = n.parent, n.logger.bindings && t.push(n.logger.bindings);
|
|
223
|
+
return t.reverse();
|
|
224
|
+
}
|
|
225
|
+
function _(e, t, n, r) {
|
|
226
|
+
if (Object.defineProperty(e, r, {
|
|
227
|
+
value: o(e.level, n) > o(r, n) ? O : n[s][r],
|
|
228
|
+
writable: !0,
|
|
229
|
+
enumerable: !0,
|
|
230
|
+
configurable: !0
|
|
231
|
+
}), e[r] === O) {
|
|
232
|
+
if (!t.transmit) return;
|
|
233
|
+
let i = o(t.transmit.level || e.level, n);
|
|
234
|
+
if (o(r, n) < i) return;
|
|
235
|
+
}
|
|
236
|
+
e[r] = y(e, t, n, r);
|
|
237
|
+
let i = g(e);
|
|
238
|
+
i.length !== 0 && (e[r] = v(i, e[r]));
|
|
239
|
+
}
|
|
240
|
+
function v(e, t) {
|
|
241
|
+
return function() {
|
|
242
|
+
return t.apply(this, [...e, ...arguments]);
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function y(e, t, n, r) {
|
|
246
|
+
return (function(a) {
|
|
247
|
+
return function() {
|
|
248
|
+
let s = t.timestamp(), c = Array(arguments.length), l = Object.getPrototypeOf && Object.getPrototypeOf(this) === i ? i : this;
|
|
249
|
+
for (var u = 0; u < c.length; u++) c[u] = arguments[u];
|
|
250
|
+
var d = !1;
|
|
251
|
+
if (t.serialize && (x(c, this._serialize, this.serializers, this._stdErrSerialize), d = !0), t.asObject || t.formatters) {
|
|
252
|
+
let e = b(this, r, c, s, t);
|
|
253
|
+
if (t.reportCaller && e && e.length > 0 && e[0] && typeof e[0] == "object") try {
|
|
254
|
+
let t = P();
|
|
255
|
+
t && (e[0].caller = t);
|
|
256
|
+
} catch {}
|
|
257
|
+
a.call(l, ...e);
|
|
258
|
+
} else {
|
|
259
|
+
if (t.reportCaller) try {
|
|
260
|
+
let e = P();
|
|
261
|
+
e && c.push(e);
|
|
262
|
+
} catch {}
|
|
263
|
+
a.apply(l, c);
|
|
264
|
+
}
|
|
265
|
+
if (t.transmit) {
|
|
266
|
+
let i = t.transmit.level || e._level, a = o(i, n), l = o(r, n);
|
|
267
|
+
if (l < a) return;
|
|
268
|
+
S(this, {
|
|
269
|
+
ts: s,
|
|
270
|
+
methodLevel: r,
|
|
271
|
+
methodValue: l,
|
|
272
|
+
transmitLevel: i,
|
|
273
|
+
transmitValue: n.levels.values[t.transmit.level || e._level],
|
|
274
|
+
send: t.transmit.send,
|
|
275
|
+
val: o(e._level, n)
|
|
276
|
+
}, c, d);
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
})(e[s][r]);
|
|
280
|
+
}
|
|
281
|
+
function b(e, t, r, i, a) {
|
|
282
|
+
let { level: o, log: s = (e) => e } = a.formatters || {}, c = r.slice(), l = c[0], u = {}, d = (e._childLevel | 0) + 1;
|
|
283
|
+
if (d < 1 && (d = 1), i && (u.time = i), o) {
|
|
284
|
+
let n = o(t, e.levels.values[t]);
|
|
285
|
+
Object.assign(u, n);
|
|
286
|
+
} else u.level = e.levels.values[t];
|
|
287
|
+
if (a.asObjectBindingsOnly) {
|
|
288
|
+
if (typeof l == "object" && l) for (; d-- && typeof c[0] == "object";) Object.assign(u, c.shift());
|
|
289
|
+
return [s(u), ...c];
|
|
290
|
+
} else {
|
|
291
|
+
if (typeof l == "object" && l) {
|
|
292
|
+
for (; d-- && typeof c[0] == "object";) Object.assign(u, c.shift());
|
|
293
|
+
l = c.length ? n(c.shift(), c) : void 0;
|
|
294
|
+
} else typeof l == "string" && (l = n(c.shift(), c));
|
|
295
|
+
return l !== void 0 && (u[a.messageKey] = l), [s(u)];
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function x(e, t, n, r) {
|
|
299
|
+
for (let i in e) if (r && e[i] instanceof Error) e[i] = p.stdSerializers.err(e[i]);
|
|
300
|
+
else if (typeof e[i] == "object" && !Array.isArray(e[i]) && t) for (let r in e[i]) t.indexOf(r) > -1 && r in n && (e[i][r] = n[r](e[i][r]));
|
|
301
|
+
}
|
|
302
|
+
function S(e, t, n, r = !1) {
|
|
303
|
+
let i = t.send, a = t.ts, o = t.methodLevel, s = t.methodValue, c = t.val, l = e._logEvent.bindings;
|
|
304
|
+
r || x(n, e._serialize || Object.keys(e.serializers), e.serializers, e._stdErrSerialize === void 0 ? !0 : e._stdErrSerialize), e._logEvent.ts = a, e._logEvent.messages = n.filter(function(e) {
|
|
305
|
+
return l.indexOf(e) === -1;
|
|
306
|
+
}), e._logEvent.level.label = o, e._logEvent.level.value = s, i(o, e._logEvent, c), e._logEvent = C(l);
|
|
307
|
+
}
|
|
308
|
+
function C(e) {
|
|
309
|
+
return {
|
|
310
|
+
ts: 0,
|
|
311
|
+
messages: [],
|
|
312
|
+
bindings: e || [],
|
|
313
|
+
level: {
|
|
314
|
+
label: "",
|
|
315
|
+
value: 0
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function w(e) {
|
|
320
|
+
let t = {
|
|
321
|
+
type: e.constructor.name,
|
|
322
|
+
msg: e.message,
|
|
323
|
+
stack: e.stack
|
|
324
|
+
};
|
|
325
|
+
for (let n in e) t[n] === void 0 && (t[n] = e[n]);
|
|
326
|
+
return t;
|
|
327
|
+
}
|
|
328
|
+
function T(e) {
|
|
329
|
+
return typeof e.timestamp == "function" ? e.timestamp : e.timestamp === !1 ? k : A;
|
|
330
|
+
}
|
|
331
|
+
function E() {
|
|
332
|
+
return {};
|
|
333
|
+
}
|
|
334
|
+
function D(e) {
|
|
335
|
+
return e;
|
|
336
|
+
}
|
|
337
|
+
function O() {}
|
|
338
|
+
function k() {
|
|
339
|
+
return !1;
|
|
340
|
+
}
|
|
341
|
+
function A() {
|
|
342
|
+
return Date.now();
|
|
343
|
+
}
|
|
344
|
+
function j() {
|
|
345
|
+
return Math.round(Date.now() / 1e3);
|
|
346
|
+
}
|
|
347
|
+
function M() {
|
|
348
|
+
return new Date(Date.now()).toISOString();
|
|
349
|
+
}
|
|
350
|
+
/* istanbul ignore next */
|
|
351
|
+
function N() {
|
|
352
|
+
function e(e) {
|
|
353
|
+
return e !== void 0 && e;
|
|
354
|
+
}
|
|
355
|
+
try {
|
|
356
|
+
return typeof globalThis < "u" || Object.defineProperty(Object.prototype, "globalThis", {
|
|
357
|
+
get: function() {
|
|
358
|
+
return delete Object.prototype.globalThis, this.globalThis = this;
|
|
359
|
+
},
|
|
360
|
+
configurable: !0
|
|
361
|
+
}), globalThis;
|
|
362
|
+
} catch {
|
|
363
|
+
return e(self) || e(window) || e(this) || {};
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
t.exports.default = p, t.exports.pino = p;
|
|
367
|
+
/* istanbul ignore next */
|
|
368
|
+
function P() {
|
|
369
|
+
let e = (/* @__PURE__ */ Error()).stack;
|
|
370
|
+
if (!e) return null;
|
|
371
|
+
let t = e.split("\n");
|
|
372
|
+
for (let e = 1; e < t.length; e++) {
|
|
373
|
+
let n = t[e].trim();
|
|
374
|
+
if (/(^at\s+)?(createWrap|LOG|set\s*\(|asObject|Object\.apply|Function\.apply)/.test(n) || n.indexOf("browser.js") !== -1 || n.indexOf("node:internal") !== -1 || n.indexOf("node_modules") !== -1) continue;
|
|
375
|
+
let r = n.match(/\((.*?):(\d+):(\d+)\)/);
|
|
376
|
+
if (r ||= n.match(/at\s+(.*?):(\d+):(\d+)/), r) {
|
|
377
|
+
let e = r[1], t = r[2], n = r[3];
|
|
378
|
+
return e + ":" + t + ":" + n;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
})))(), 1), a = class {
|
|
384
|
+
pino;
|
|
385
|
+
constructor(e = {}) {
|
|
386
|
+
let t = {
|
|
387
|
+
level: e.level ?? "info",
|
|
388
|
+
timestamp: i.default.stdTimeFunctions.isoTime,
|
|
389
|
+
formatters: { level: (e) => ({ level: e }) },
|
|
390
|
+
...e.redact && { redact: {
|
|
391
|
+
paths: e.redact,
|
|
392
|
+
censor: "[REDACTED]"
|
|
393
|
+
} },
|
|
394
|
+
...e.pinoOptions
|
|
395
|
+
};
|
|
396
|
+
e.prettyPrint ? this.pino = (0, i.default)(t, n()) : e.destination ? this.pino = (0, i.default)(t, i.default.destination(e.destination)) : this.pino = (0, i.default)(t);
|
|
397
|
+
}
|
|
398
|
+
log(e, t, n) {
|
|
399
|
+
n ? this.pino[e](t, n) : this.pino[e](t);
|
|
400
|
+
}
|
|
401
|
+
child(e) {
|
|
402
|
+
return new o(this.pino.child(e));
|
|
403
|
+
}
|
|
404
|
+
async flush() {
|
|
405
|
+
this.pino.flush();
|
|
406
|
+
}
|
|
407
|
+
}, o = class e {
|
|
408
|
+
constructor(e) {
|
|
409
|
+
this.pinoChild = e;
|
|
410
|
+
}
|
|
411
|
+
log(e, t, n) {
|
|
412
|
+
n ? this.pinoChild[e](t, n) : this.pinoChild[e](t);
|
|
413
|
+
}
|
|
414
|
+
child(t) {
|
|
415
|
+
return new e(this.pinoChild.child(t));
|
|
416
|
+
}
|
|
417
|
+
async flush() {
|
|
418
|
+
this.pinoChild.flush();
|
|
419
|
+
}
|
|
420
|
+
}, s = {
|
|
421
|
+
trace: "debug",
|
|
422
|
+
debug: "debug",
|
|
423
|
+
info: "log",
|
|
424
|
+
warn: "warn",
|
|
425
|
+
error: "error",
|
|
426
|
+
fatal: "error"
|
|
427
|
+
}, c = class e {
|
|
428
|
+
bindings;
|
|
429
|
+
constructor(e) {
|
|
430
|
+
this.bindings = e ?? {};
|
|
431
|
+
}
|
|
432
|
+
log(e, t, n) {
|
|
433
|
+
let r = s[e], i = {
|
|
434
|
+
...this.bindings,
|
|
435
|
+
...t
|
|
436
|
+
}, a = Object.keys(i).length > 0;
|
|
437
|
+
n && a ? console[r](`[${e}]`, n, i) : n ? console[r](`[${e}]`, n) : a && console[r](`[${e}]`, i);
|
|
438
|
+
}
|
|
439
|
+
child(t) {
|
|
440
|
+
return new e({
|
|
441
|
+
...this.bindings,
|
|
442
|
+
...t
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
}, l = [
|
|
446
|
+
"password",
|
|
447
|
+
"token",
|
|
448
|
+
"apiKey",
|
|
449
|
+
"authorization",
|
|
450
|
+
"secret"
|
|
451
|
+
];
|
|
452
|
+
function u(e) {
|
|
453
|
+
if (typeof globalThis < "u" && typeof globalThis.process == "object") return globalThis.process.env[e];
|
|
454
|
+
}
|
|
455
|
+
function d() {
|
|
456
|
+
try {
|
|
457
|
+
return typeof process < "u" && typeof process.versions?.node == "string";
|
|
458
|
+
} catch {
|
|
459
|
+
return !1;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
function f(e) {
|
|
463
|
+
return d() ? new a({
|
|
464
|
+
level: e.level ?? u("LOG_LEVEL") ?? "info",
|
|
465
|
+
redact: e.redact ?? l,
|
|
466
|
+
prettyPrint: e.prettyPrint ?? u("NODE_ENV") === "development",
|
|
467
|
+
destination: e.destination
|
|
468
|
+
}) : new c();
|
|
469
|
+
}
|
|
470
|
+
var p = class e {
|
|
471
|
+
static transport;
|
|
472
|
+
static config = {};
|
|
473
|
+
options;
|
|
474
|
+
childTransport;
|
|
475
|
+
static {
|
|
476
|
+
e.transport = f(e.config);
|
|
477
|
+
}
|
|
478
|
+
constructor(t = {}) {
|
|
479
|
+
if (this.options = t, t.context || t.correlationId || t.namespace) {
|
|
480
|
+
let n = {
|
|
481
|
+
...t.namespace && { namespace: t.namespace },
|
|
482
|
+
...t.correlationId && { correlationId: t.correlationId },
|
|
483
|
+
...t.context
|
|
484
|
+
};
|
|
485
|
+
this.childTransport = e.transport.child(n);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
static configure(t) {
|
|
489
|
+
e.config = {
|
|
490
|
+
...e.config,
|
|
491
|
+
...t
|
|
492
|
+
}, e.transport = e.config.transport ?? f(e.config), e.rebindStaticMethods();
|
|
493
|
+
}
|
|
494
|
+
static getTransport() {
|
|
495
|
+
return e.transport;
|
|
496
|
+
}
|
|
497
|
+
static getPinoInstance() {
|
|
498
|
+
if (e.transport instanceof a) return e.transport.pino;
|
|
499
|
+
throw Error("getPinoInstance() requires PinoTransport. Use Logger.getTransport() for the active transport.");
|
|
500
|
+
}
|
|
501
|
+
static normalizeArgs(e, t) {
|
|
502
|
+
return typeof e == "string" ? [{}, [e, ...t]] : [e, t];
|
|
503
|
+
}
|
|
504
|
+
static isDevelopment() {
|
|
505
|
+
return u("NODE_ENV") === "development";
|
|
506
|
+
}
|
|
507
|
+
static formatError(e) {
|
|
508
|
+
return e instanceof Error ? `${e.name}: ${e.message}\nStack: ${e.stack}` : String(e);
|
|
509
|
+
}
|
|
510
|
+
static buildLogData(e) {
|
|
511
|
+
return {
|
|
512
|
+
...e.namespace && { namespace: e.namespace },
|
|
513
|
+
...e.correlationId && { correlationId: e.correlationId },
|
|
514
|
+
...e.context
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
static staticLog(t, n, ...r) {
|
|
518
|
+
if (n.developerOnly && !e.isDevelopment()) return;
|
|
519
|
+
let i = e.buildLogData(n);
|
|
520
|
+
e.transport.log(t, {
|
|
521
|
+
...i,
|
|
522
|
+
msg: r
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
static staticErrorLog(t, n, ...r) {
|
|
526
|
+
if (n.developerOnly && !e.isDevelopment()) return;
|
|
527
|
+
let i = n.error ? { error: e.formatError(n.error) } : {}, a = {
|
|
528
|
+
...e.buildLogData(n),
|
|
529
|
+
...i
|
|
530
|
+
};
|
|
531
|
+
e.transport.log(t, {
|
|
532
|
+
...a,
|
|
533
|
+
msg: r
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
static info(t, ...n) {
|
|
537
|
+
let [r, i] = e.normalizeArgs(t, n);
|
|
538
|
+
e.staticLog("info", r, ...i);
|
|
539
|
+
}
|
|
540
|
+
static debug(t, ...n) {
|
|
541
|
+
let [r, i] = e.normalizeArgs(t, n);
|
|
542
|
+
e.staticLog("debug", r, ...i);
|
|
543
|
+
}
|
|
544
|
+
static trace(t, ...n) {
|
|
545
|
+
let [r, i] = e.normalizeArgs(t, n);
|
|
546
|
+
e.staticLog("trace", r, ...i);
|
|
547
|
+
}
|
|
548
|
+
static warn(t, ...n) {
|
|
549
|
+
let [r, i] = e.normalizeArgs(t, n);
|
|
550
|
+
e.staticLog("warn", r, ...i);
|
|
551
|
+
}
|
|
552
|
+
static error(t, ...n) {
|
|
553
|
+
let [r, i] = e.normalizeArgs(t, n);
|
|
554
|
+
e.staticErrorLog("error", r, ...i);
|
|
555
|
+
}
|
|
556
|
+
static fatal(t, ...n) {
|
|
557
|
+
let [r, i] = e.normalizeArgs(t, n);
|
|
558
|
+
e.staticErrorLog("fatal", r, ...i);
|
|
559
|
+
}
|
|
560
|
+
static rebindStaticMethods() {}
|
|
561
|
+
static create(t = {}) {
|
|
562
|
+
return new e(t);
|
|
563
|
+
}
|
|
564
|
+
logInstance(t, n, r) {
|
|
565
|
+
let i = this.childTransport ?? e.transport;
|
|
566
|
+
typeof n == "string" ? i.log(t, {}, n) : r ? i.log(t, n ?? {}, r) : i.log(t, n ?? {});
|
|
567
|
+
}
|
|
568
|
+
trace(e, t) {
|
|
569
|
+
this.logInstance("trace", e, t);
|
|
570
|
+
}
|
|
571
|
+
debug(e, t) {
|
|
572
|
+
this.logInstance("debug", e, t);
|
|
573
|
+
}
|
|
574
|
+
info(e, t) {
|
|
575
|
+
this.logInstance("info", e, t);
|
|
576
|
+
}
|
|
577
|
+
warn(e, t) {
|
|
578
|
+
this.logInstance("warn", e, t);
|
|
579
|
+
}
|
|
580
|
+
error(t, n) {
|
|
581
|
+
let r = this.childTransport ?? e.transport;
|
|
582
|
+
typeof t == "string" ? r.log("error", {}, t) : t instanceof Error ? r.log("error", { error: t }, n) : n ? r.log("error", t ?? {}, n) : r.log("error", t ?? {});
|
|
583
|
+
}
|
|
584
|
+
fatal(t, n) {
|
|
585
|
+
let r = this.childTransport ?? e.transport;
|
|
586
|
+
typeof t == "string" ? r.log("fatal", {}, t) : t instanceof Error ? r.log("fatal", { error: t }, n) : n ? r.log("fatal", t ?? {}, n) : r.log("fatal", t ?? {});
|
|
587
|
+
}
|
|
588
|
+
}, m = [
|
|
589
|
+
"authorization",
|
|
590
|
+
"cookie",
|
|
591
|
+
"set-cookie",
|
|
592
|
+
"x-api-key",
|
|
593
|
+
"x-auth-token",
|
|
594
|
+
"proxy-authorization"
|
|
595
|
+
];
|
|
596
|
+
function h(e) {
|
|
597
|
+
let t = {};
|
|
598
|
+
return e instanceof Headers ? e.forEach((e, n) => {
|
|
599
|
+
t[n] = m.includes(n.toLowerCase()) ? "[REDACTED]" : e;
|
|
600
|
+
}) : Array.isArray(e) ? e.forEach(([e, n]) => {
|
|
601
|
+
t[e] = m.includes(e.toLowerCase()) ? "[REDACTED]" : String(n);
|
|
602
|
+
}) : Object.entries(e).forEach(([e, n]) => {
|
|
603
|
+
t[e] = m.includes(e.toLowerCase()) ? "[REDACTED]" : String(n);
|
|
604
|
+
}), t;
|
|
605
|
+
}
|
|
606
|
+
//#endregion
|
|
607
|
+
export { c as ConsoleTransport, p as Logger, a as PinoTransport, h as redactHeaders };
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js-only exports for @eventuras/logger.
|
|
3
|
+
*
|
|
4
|
+
* These utilities depend on `node:stream` and must not be imported in browser
|
|
5
|
+
* or edge runtime environments. Import from the root entry point
|
|
6
|
+
* (`@eventuras/logger`) for the browser-safe API.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* import { createPrettyStream, formatLogLine } from '@eventuras/logger/node';
|
|
10
|
+
*/
|
|
11
|
+
export { formatLogLine, createPrettyStream } from './transports/pretty';
|
|
12
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/node.js
ADDED