@eventuras/logger 0.8.0 → 0.9.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.
@@ -1,208 +0,0 @@
1
- import e from "pino";
2
- //#region src/transports/pino.ts
3
- var t = class {
4
- pino;
5
- constructor(t = {}) {
6
- let n = {
7
- level: t.level ?? "info",
8
- timestamp: e.stdTimeFunctions.isoTime,
9
- formatters: { level: (e) => ({ level: e }) },
10
- ...t.redact && { redact: {
11
- paths: t.redact,
12
- censor: "[REDACTED]"
13
- } },
14
- ...t.pinoOptions
15
- };
16
- t.destinationStream ? this.pino = e(n, t.destinationStream) : t.destination ? this.pino = e(n, e.destination(t.destination)) : this.pino = e(n);
17
- }
18
- log(e, t, n) {
19
- n ? this.pino[e](t, n) : this.pino[e](t);
20
- }
21
- child(e) {
22
- return new n(this.pino.child(e));
23
- }
24
- async flush() {
25
- this.pino.flush();
26
- }
27
- }, n = class e {
28
- constructor(e) {
29
- this.pinoChild = e;
30
- }
31
- log(e, t, n) {
32
- n ? this.pinoChild[e](t, n) : this.pinoChild[e](t);
33
- }
34
- child(t) {
35
- return new e(this.pinoChild.child(t));
36
- }
37
- async flush() {
38
- this.pinoChild.flush();
39
- }
40
- }, r = {
41
- trace: "debug",
42
- debug: "debug",
43
- info: "log",
44
- warn: "warn",
45
- error: "error",
46
- fatal: "error"
47
- }, i = class e {
48
- bindings;
49
- constructor(e) {
50
- this.bindings = e ?? {};
51
- }
52
- log(e, t, n) {
53
- let i = r[e], a = {
54
- ...this.bindings,
55
- ...t
56
- }, o = Object.keys(a).length > 0;
57
- n && o ? console[i](`[${e}]`, n, a) : n ? console[i](`[${e}]`, n) : o && console[i](`[${e}]`, a);
58
- }
59
- child(t) {
60
- return new e({
61
- ...this.bindings,
62
- ...t
63
- });
64
- }
65
- }, a = [
66
- "password",
67
- "token",
68
- "apiKey",
69
- "authorization",
70
- "secret"
71
- ];
72
- function o(e) {
73
- if (typeof globalThis < "u" && typeof globalThis.process == "object") return globalThis.process.env[e];
74
- }
75
- function s() {
76
- try {
77
- return typeof process < "u" && typeof process.versions?.node == "string";
78
- } catch {
79
- return !1;
80
- }
81
- }
82
- function c(e) {
83
- return s() ? new t({
84
- level: e.level ?? o("LOG_LEVEL") ?? "info",
85
- redact: e.redact ?? a,
86
- destination: e.destination
87
- }) : new i();
88
- }
89
- var l = class e {
90
- static transport;
91
- static config = {};
92
- options;
93
- childTransport;
94
- static {
95
- e.transport = c(e.config);
96
- }
97
- constructor(t = {}) {
98
- if (this.options = t, t.context || t.correlationId || t.namespace) {
99
- let n = {
100
- ...t.namespace && { namespace: t.namespace },
101
- ...t.correlationId && { correlationId: t.correlationId },
102
- ...t.context
103
- };
104
- this.childTransport = e.transport.child(n);
105
- }
106
- }
107
- static configure(t) {
108
- e.config = {
109
- ...e.config,
110
- ...t
111
- }, e.transport = e.config.transport ?? c(e.config);
112
- }
113
- static getTransport() {
114
- return e.transport;
115
- }
116
- static getPinoInstance() {
117
- if (e.transport instanceof t) return e.transport.pino;
118
- throw Error("getPinoInstance() requires PinoTransport. Use Logger.getTransport() for the active transport.");
119
- }
120
- static normalizeArgs(e, t) {
121
- return typeof e == "string" ? [{}, [e, ...t]] : [e, t];
122
- }
123
- static isDevelopment() {
124
- return o("NODE_ENV") === "development";
125
- }
126
- static formatError(e) {
127
- return e instanceof Error ? `${e.name}: ${e.message}\nStack: ${e.stack}` : String(e);
128
- }
129
- static buildLogData(e) {
130
- return {
131
- ...e.namespace && { namespace: e.namespace },
132
- ...e.correlationId && { correlationId: e.correlationId },
133
- ...e.context
134
- };
135
- }
136
- static staticLog(t, n, ...r) {
137
- if (n.developerOnly && !e.isDevelopment()) return;
138
- let i = e.buildLogData(n);
139
- e.transport.log(t, {
140
- ...i,
141
- msg: r
142
- });
143
- }
144
- static staticErrorLog(t, n, ...r) {
145
- if (n.developerOnly && !e.isDevelopment()) return;
146
- let i = n.error ? { error: e.formatError(n.error) } : {}, a = {
147
- ...e.buildLogData(n),
148
- ...i
149
- };
150
- e.transport.log(t, {
151
- ...a,
152
- msg: r
153
- });
154
- }
155
- static info(t, ...n) {
156
- let [r, i] = e.normalizeArgs(t, n);
157
- e.staticLog("info", r, ...i);
158
- }
159
- static debug(t, ...n) {
160
- let [r, i] = e.normalizeArgs(t, n);
161
- e.staticLog("debug", r, ...i);
162
- }
163
- static trace(t, ...n) {
164
- let [r, i] = e.normalizeArgs(t, n);
165
- e.staticLog("trace", r, ...i);
166
- }
167
- static warn(t, ...n) {
168
- let [r, i] = e.normalizeArgs(t, n);
169
- e.staticLog("warn", r, ...i);
170
- }
171
- static error(t, ...n) {
172
- let [r, i] = e.normalizeArgs(t, n);
173
- e.staticErrorLog("error", r, ...i);
174
- }
175
- static fatal(t, ...n) {
176
- let [r, i] = e.normalizeArgs(t, n);
177
- e.staticErrorLog("fatal", r, ...i);
178
- }
179
- static create(t = {}) {
180
- return new e(t);
181
- }
182
- logInstance(t, n, r) {
183
- let i = this.childTransport ?? e.transport;
184
- typeof n == "string" ? i.log(t, {}, n) : r ? i.log(t, n ?? {}, r) : i.log(t, n ?? {});
185
- }
186
- trace(e, t) {
187
- this.logInstance("trace", e, t);
188
- }
189
- debug(e, t) {
190
- this.logInstance("debug", e, t);
191
- }
192
- info(e, t) {
193
- this.logInstance("info", e, t);
194
- }
195
- warn(e, t) {
196
- this.logInstance("warn", e, t);
197
- }
198
- error(t, n) {
199
- let r = this.childTransport ?? e.transport;
200
- 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 ?? {});
201
- }
202
- fatal(t, n) {
203
- let r = this.childTransport ?? e.transport;
204
- 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 ?? {});
205
- }
206
- };
207
- //#endregion
208
- export { i as n, t as r, l as t };
@@ -1,20 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (e && (t = e(e = 0)), t), s = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), c = (e, n) => {
3
- let r = {};
4
- for (var i in e) t(r, i, {
5
- get: e[i],
6
- enumerable: !0
7
- });
8
- return n || t(r, Symbol.toStringTag, { value: "Module" }), r;
9
- }, l = (e, i, o, s) => {
10
- if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
11
- get: ((e) => i[e]).bind(null, d),
12
- enumerable: !(s = n(i, d)) || s.enumerable
13
- });
14
- return e;
15
- }, u = (n, r, a) => (a = n == null ? {} : e(i(n)), l(r || !n || !n.__esModule ? t(a, "default", {
16
- value: n,
17
- enumerable: !0
18
- }) : a, n)), d = (e) => a.call(e, "module.exports") ? e["module.exports"] : l(t({}, "__esModule", { value: !0 }), e);
19
- //#endregion
20
- export { u as a, d as i, o as n, c as r, s as t };