logan-logger 1.1.18 → 1.1.19

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,313 +0,0 @@
1
- function f() {
2
- const t = c(), e = l(t), o = d(t);
3
- return {
4
- name: t,
5
- version: e,
6
- capabilities: o
7
- };
8
- }
9
- function c() {
10
- return typeof globalThis.Deno < "u" ? "deno" : typeof globalThis.Bun < "u" ? "bun" : typeof window < "u" && typeof document < "u" ? "browser" : typeof globalThis.importScripts == "function" && typeof window > "u" ? "webworker" : typeof process < "u" && process.versions && process.versions.node ? "node" : "unknown";
11
- }
12
- function l(t) {
13
- switch (t) {
14
- case "node":
15
- return typeof process < "u" ? process.version : void 0;
16
- case "deno":
17
- return typeof globalThis.Deno < "u" ? (
18
- // biome-ignore lint/suspicious/noExplicitAny: Runtime-specific global not in TS types
19
- globalThis.Deno.version?.deno
20
- ) : void 0;
21
- case "bun":
22
- return typeof globalThis.Bun < "u" ? (
23
- // biome-ignore lint/suspicious/noExplicitAny: Runtime-specific global not in TS types
24
- globalThis.Bun.version
25
- ) : void 0;
26
- case "browser":
27
- return typeof navigator < "u" ? navigator.userAgent : void 0;
28
- default:
29
- return;
30
- }
31
- }
32
- function d(t) {
33
- switch (t) {
34
- case "node":
35
- return {
36
- fileSystem: !0,
37
- colorSupport: !0,
38
- processInfo: !0,
39
- streams: !0
40
- };
41
- case "deno":
42
- return {
43
- fileSystem: !0,
44
- colorSupport: !0,
45
- processInfo: !0,
46
- streams: !0
47
- };
48
- case "bun":
49
- return {
50
- fileSystem: !0,
51
- colorSupport: !0,
52
- processInfo: !0,
53
- streams: !0
54
- };
55
- case "browser":
56
- return {
57
- fileSystem: !1,
58
- colorSupport: !0,
59
- // CSS styling in console
60
- processInfo: !1,
61
- streams: !1
62
- };
63
- case "webworker":
64
- return {
65
- fileSystem: !1,
66
- colorSupport: !1,
67
- processInfo: !1,
68
- streams: !1
69
- };
70
- default:
71
- return {
72
- fileSystem: !1,
73
- colorSupport: !1,
74
- processInfo: !1,
75
- streams: !1
76
- };
77
- }
78
- }
79
- function h() {
80
- return c() === "node";
81
- }
82
- function y() {
83
- return c() === "browser";
84
- }
85
- function b() {
86
- return c() === "deno";
87
- }
88
- function w() {
89
- return c() === "bun";
90
- }
91
- var n = /* @__PURE__ */ ((t) => (t[t.DEBUG = 0] = "DEBUG", t[t.INFO = 1] = "INFO", t[t.WARN = 2] = "WARN", t[t.ERROR = 3] = "ERROR", t[t.SILENT = 4] = "SILENT", t))(n || {});
92
- class p {
93
- constructor(e = {}) {
94
- this.childMetadata = {}, this.config = e, this.level = e.level ?? n.INFO, this.runtime = f().name;
95
- }
96
- // biome-ignore lint/suspicious/noExplicitAny: Intentional - logger accepts arbitrary metadata (see ILogger interface)
97
- debug(e, o) {
98
- this.log(n.DEBUG, e, o);
99
- }
100
- // biome-ignore lint/suspicious/noExplicitAny: Intentional - logger accepts arbitrary metadata (see ILogger interface)
101
- info(e, o) {
102
- this.log(n.INFO, e, o);
103
- }
104
- // biome-ignore lint/suspicious/noExplicitAny: Intentional - logger accepts arbitrary metadata (see ILogger interface)
105
- warn(e, o) {
106
- this.log(n.WARN, e, o);
107
- }
108
- // biome-ignore lint/suspicious/noExplicitAny: Intentional - logger accepts arbitrary metadata (see ILogger interface)
109
- error(e, o) {
110
- this.log(n.ERROR, e, o);
111
- }
112
- // biome-ignore lint/suspicious/noExplicitAny: Intentional - logger accepts arbitrary metadata (see ILogger interface)
113
- log(e, o, s) {
114
- if (!this.shouldLog(e))
115
- return;
116
- const r = typeof o == "function" ? o() : o, i = { ...this.childMetadata, ...s }, a = {
117
- timestamp: /* @__PURE__ */ new Date(),
118
- level: e,
119
- message: r,
120
- metadata: Object.keys(i).length > 0 ? i : void 0,
121
- runtime: this.runtime
122
- };
123
- this.writeLog(a);
124
- }
125
- setLevel(e) {
126
- this.level = e;
127
- }
128
- getLevel() {
129
- return this.level;
130
- }
131
- // biome-ignore lint/suspicious/noExplicitAny: Intentional - logger accepts arbitrary metadata (see ILogger interface)
132
- child(e) {
133
- const o = this.createChild();
134
- return o.childMetadata = { ...this.childMetadata, ...e }, o;
135
- }
136
- shouldLog(e) {
137
- return e >= this.level;
138
- }
139
- }
140
- function m(t, e) {
141
- const o = /* @__PURE__ */ new WeakSet();
142
- return JSON.stringify(
143
- t,
144
- (s, r) => {
145
- if (typeof r == "object" && r !== null) {
146
- if (o.has(r))
147
- return "[Circular]";
148
- o.add(r);
149
- }
150
- return r instanceof Error ? {
151
- name: r.name,
152
- message: r.message,
153
- stack: r.stack,
154
- ...Object.getOwnPropertyNames(r).reduce((i, a) => (a !== "name" && a !== "message" && a !== "stack" && (i[a] = r[a]), i), {})
155
- } : typeof r == "function" ? `[Function: ${r.name || "anonymous"}]` : r === void 0 ? "[undefined]" : typeof r == "bigint" ? `[BigInt: ${r.toString()}]` : typeof r == "symbol" ? `[Symbol: ${r.toString()}]` : r;
156
- },
157
- e
158
- );
159
- }
160
- function g(t, e = ["password", "token", "secret", "key", "auth"]) {
161
- if (typeof t != "object" || t === null)
162
- return t;
163
- const o = Array.isArray(t) ? [] : {};
164
- for (const [s, r] of Object.entries(t))
165
- e.some(
166
- (a) => s.toLowerCase().includes(a.toLowerCase())
167
- ) ? o[s] = "[REDACTED]" : typeof r == "object" && r !== null ? o[s] = g(r, e) : o[s] = r;
168
- return o;
169
- }
170
- function S(t) {
171
- return t instanceof Error ? {
172
- name: t.name,
173
- message: t.message,
174
- stack: t.stack,
175
- // biome-ignore lint/suspicious/noExplicitAny: Spread Error to capture custom properties
176
- ...t
177
- // Include any additional properties
178
- } : t;
179
- }
180
- class u extends p {
181
- constructor(e = {}) {
182
- super(e);
183
- }
184
- writeLog(e) {
185
- const o = this.formatMessage(e), s = this.getConsoleStyle(e.level), r = e.metadata ? ` ${m(e.metadata)}` : "", i = `%c${o}${r}`;
186
- switch (e.level) {
187
- case n.DEBUG:
188
- console.debug ? console.debug(i, s) : console.log(i, s);
189
- break;
190
- case n.INFO:
191
- console.info(i, s);
192
- break;
193
- case n.WARN:
194
- console.warn(i, s);
195
- break;
196
- case n.ERROR:
197
- console.error(i, s);
198
- break;
199
- }
200
- }
201
- createChild() {
202
- return new u(this.config);
203
- }
204
- formatMessage(e) {
205
- const o = e.timestamp.toISOString(), s = n[e.level].toUpperCase();
206
- return `[${o}] ${s}: ${e.message}`;
207
- }
208
- getConsoleStyle(e) {
209
- if (!this.config.colorize)
210
- return "";
211
- switch (e) {
212
- case n.DEBUG:
213
- return "color: #888; font-weight: normal;";
214
- case n.INFO:
215
- return "color: #007acc; font-weight: normal;";
216
- case n.WARN:
217
- return "color: #ff8c00; font-weight: bold;";
218
- case n.ERROR:
219
- return "color: #dc3545; font-weight: bold;";
220
- default:
221
- return "";
222
- }
223
- }
224
- shouldLogInProduction() {
225
- return /* biome-ignore lint/suspicious/noExplicitAny: Browser environment may have process global from bundler */ (globalThis.process?.env?.NODE_ENV || // biome-ignore lint/suspicious/noExplicitAny: Browser environment may have process global from bundler
226
- globalThis.process?.env?.NEXT_PUBLIC_APP_ENV || "development") !== "production" || this.level <= n.ERROR;
227
- }
228
- shouldLog(e) {
229
- return !this.shouldLogInProduction() && e < n.ERROR ? !1 : super.shouldLog(e);
230
- }
231
- }
232
- class R extends u {
233
- constructor() {
234
- super(...arguments), this.groupStack = [];
235
- }
236
- group(e) {
237
- console.group(e), this.groupStack.push(e);
238
- }
239
- groupCollapsed(e) {
240
- console.groupCollapsed(e), this.groupStack.push(e);
241
- }
242
- groupEnd() {
243
- console.groupEnd(), this.groupStack.pop();
244
- }
245
- getCurrentGroupStack() {
246
- return [...this.groupStack];
247
- }
248
- getCurrentGroupPath() {
249
- return this.groupStack.join(" > ");
250
- }
251
- time(e) {
252
- console.time(e);
253
- }
254
- timeEnd(e) {
255
- console.timeEnd(e);
256
- }
257
- // biome-ignore lint/suspicious/noExplicitAny: Console method accepts arbitrary metadata
258
- trace(e, o) {
259
- console.trace(e, o);
260
- }
261
- count(e) {
262
- console.count(e);
263
- }
264
- countReset(e) {
265
- console.countReset(e);
266
- }
267
- // biome-ignore lint/suspicious/noExplicitAny: Console.table accepts arbitrary tabular data
268
- table(e) {
269
- console.table(e);
270
- }
271
- }
272
- class k extends u {
273
- mark(e) {
274
- typeof performance < "u" && performance.mark && performance.mark(e);
275
- }
276
- measure(e, o, s) {
277
- if (typeof performance < "u" && performance.measure)
278
- try {
279
- performance.measure(e, o, s);
280
- const r = performance.getEntriesByName(e, "measure");
281
- if (r.length > 0) {
282
- const i = r[r.length - 1];
283
- this.info(`Performance: ${e}`, {
284
- duration: i.duration,
285
- startTime: i.startTime
286
- });
287
- }
288
- } catch (r) {
289
- this.warn("Failed to measure performance", { name: e, error: r });
290
- }
291
- }
292
- clearMarks(e) {
293
- typeof performance < "u" && performance.clearMarks && performance.clearMarks(e);
294
- }
295
- clearMeasures(e) {
296
- typeof performance < "u" && performance.clearMeasures && performance.clearMeasures(e);
297
- }
298
- }
299
- export {
300
- u as B,
301
- R as C,
302
- n as L,
303
- k as P,
304
- y as a,
305
- b,
306
- w as c,
307
- f as d,
308
- S as e,
309
- g as f,
310
- p as g,
311
- h as i,
312
- m as s
313
- };
@@ -1,36 +0,0 @@
1
- import { L as e, s as i } from "./browser-Daz7tvRv.mjs";
2
- function l(t, o = "text") {
3
- if (o === "json") {
4
- const m = {
5
- timestamp: t.timestamp.toISOString(),
6
- level: e[t.level].toLowerCase(),
7
- message: t.message,
8
- runtime: t.runtime
9
- };
10
- return t.metadata !== void 0 && (m.metadata = t.metadata), i(m);
11
- }
12
- const a = t.timestamp.toISOString(), s = e[t.level].toUpperCase(), r = t.metadata ? ` ${i(t.metadata)}` : "";
13
- return `[${a}] ${s}: ${t.message}${r}`;
14
- }
15
- function c(t, o = !1) {
16
- const a = e[t].toUpperCase();
17
- if (!o)
18
- return a;
19
- const s = {
20
- [e.DEBUG]: "\x1B[36m",
21
- // Cyan
22
- [e.INFO]: "\x1B[32m",
23
- // Green
24
- [e.WARN]: "\x1B[33m",
25
- // Yellow
26
- [e.ERROR]: "\x1B[31m",
27
- // Red
28
- [e.SILENT]: "\x1B[37m"
29
- // White
30
- };
31
- return `${s[t] || s[e.INFO]}${a}\x1B[0m`;
32
- }
33
- export {
34
- c as a,
35
- l as f
36
- };
@@ -1 +0,0 @@
1
- "use strict";const t=require("./browser-BYqYELrw.js");function L(e,s="text"){if(s==="json"){const m={timestamp:e.timestamp.toISOString(),level:t.LogLevel[e.level].toLowerCase(),message:e.message,runtime:e.runtime};return e.metadata!==void 0&&(m.metadata=e.metadata),t.safeStringify(m)}const o=e.timestamp.toISOString(),a=t.LogLevel[e.level].toUpperCase(),r=e.metadata?` ${t.safeStringify(e.metadata)}`:"";return`[${o}] ${a}: ${e.message}${r}`}function l(e,s=!1){const o=t.LogLevel[e].toUpperCase();if(!s)return o;const a={[t.LogLevel.DEBUG]:"\x1B[36m",[t.LogLevel.INFO]:"\x1B[32m",[t.LogLevel.WARN]:"\x1B[33m",[t.LogLevel.ERROR]:"\x1B[31m",[t.LogLevel.SILENT]:"\x1B[37m"};return`${a[e]||a[t.LogLevel.INFO]}${o}\x1B[0m`}exports.formatLevel=l;exports.formatLogEntry=L;
@@ -1,341 +0,0 @@
1
- import { g as w, L as r, s as v, d as l, B as c } from "./browser-Daz7tvRv.mjs";
2
- class i extends w {
3
- constructor(e = {}) {
4
- super(e), this.initializeWinston();
5
- }
6
- async initializeWinston() {
7
- try {
8
- const n = await import("winston");
9
- this.winston = this.createWinstonLogger(n);
10
- } catch (e) {
11
- console.warn("[logan-logger] Winston not found, falling back to console logging:", e);
12
- }
13
- }
14
- // biome-ignore lint/suspicious/noExplicitAny: Winston is an optional peer dependency, types not guaranteed
15
- createWinstonLogger(e) {
16
- const n = e.format.combine(
17
- e.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
18
- e.format.errors({ stack: !0 }),
19
- e.format.json(),
20
- e.format.prettyPrint()
21
- ), o = e.format.combine(
22
- e.format.colorize(),
23
- e.format.timestamp({ format: "HH:mm:ss" }),
24
- // biome-ignore lint/suspicious/noExplicitAny: Winston format callback parameter has dynamic shape
25
- e.format.printf(({ timestamp: a, level: d, message: p, ...f }) => {
26
- const L = Object.keys(f).length ? JSON.stringify(f, null, 2) : "";
27
- return `${a} [${d}]: ${p} ${L}`;
28
- })
29
- ), s = e.createLogger({
30
- level: this.getWinstonLevel(this.level),
31
- format: n,
32
- transports: [
33
- new e.transports.Console({
34
- format: process.env.NODE_ENV === "production" ? n : o
35
- })
36
- ]
37
- });
38
- return process.env.NODE_ENV === "production" && (s.add(
39
- new e.transports.File({
40
- filename: "logs/error.log",
41
- level: "error",
42
- maxsize: 5242880,
43
- // 5MB
44
- maxFiles: 5
45
- })
46
- ), s.add(
47
- new e.transports.File({
48
- filename: "logs/combined.log",
49
- maxsize: 5242880,
50
- // 5MB
51
- maxFiles: 10
52
- })
53
- )), s;
54
- }
55
- writeLog(e) {
56
- this.winston ? this.winston.log({
57
- level: this.getWinstonLevel(e.level),
58
- message: e.message,
59
- timestamp: e.timestamp,
60
- ...e.metadata
61
- }) : this.writeToConsole(e);
62
- }
63
- createChild() {
64
- return new i(this.config);
65
- }
66
- writeToConsole(e) {
67
- const n = e.timestamp.toISOString(), o = r[e.level].toLowerCase(), s = e.metadata ? ` ${v(e.metadata)}` : "", a = `[${n}] ${o.toUpperCase()}: ${e.message}${s}`;
68
- switch (e.level) {
69
- case r.DEBUG:
70
- console.debug(a);
71
- break;
72
- case r.INFO:
73
- console.info(a);
74
- break;
75
- case r.WARN:
76
- console.warn(a);
77
- break;
78
- case r.ERROR:
79
- console.error(a);
80
- break;
81
- }
82
- }
83
- getWinstonLevel(e) {
84
- switch (e) {
85
- case r.DEBUG:
86
- return "debug";
87
- case r.INFO:
88
- return "info";
89
- case r.WARN:
90
- return "warn";
91
- case r.ERROR:
92
- return "error";
93
- default:
94
- return "info";
95
- }
96
- }
97
- setLevel(e) {
98
- super.setLevel(e), this.winston && (this.winston.level = this.getWinstonLevel(e));
99
- }
100
- }
101
- function b(t) {
102
- return {
103
- write: (e) => {
104
- t.info(e.trim());
105
- }
106
- };
107
- }
108
- function m() {
109
- const t = l();
110
- return {
111
- level: r.INFO,
112
- format: "text",
113
- timestamp: !0,
114
- colorize: t.capabilities.colorSupport,
115
- metadata: {},
116
- transports: [
117
- {
118
- type: "console",
119
- options: {}
120
- }
121
- ]
122
- };
123
- }
124
- function T() {
125
- const t = {};
126
- if (typeof process < "u" && process.env) {
127
- const e = process.env;
128
- e.LOG_LEVEL && (t.level = N(e.LOG_LEVEL)), e.LOG_FORMAT && ["json", "text"].includes(e.LOG_FORMAT) && (t.format = e.LOG_FORMAT), e.LOG_TIMESTAMP && (t.timestamp = e.LOG_TIMESTAMP.toLowerCase() === "true"), e.LOG_COLOR && (t.colorize = e.LOG_COLOR.toLowerCase() === "true");
129
- }
130
- return t;
131
- }
132
- async function W(t) {
133
- const e = l();
134
- if (!e.capabilities.fileSystem)
135
- return {};
136
- const n = t ? [t] : [
137
- "logan.config.json",
138
- "logan.config.js",
139
- ".loganrc",
140
- "package.json"
141
- // Check for logan config in package.json
142
- ];
143
- for (const o of n)
144
- try {
145
- if (e.name === "node")
146
- return await g(o);
147
- if (e.name === "deno")
148
- return await O(o);
149
- if (e.name === "bun")
150
- return await E(o);
151
- } catch {
152
- }
153
- return {};
154
- }
155
- async function g(t) {
156
- try {
157
- const e = await import("./__vite-browser-external-DYxpcVy9.mjs"), n = await import("./__vite-browser-external-DYxpcVy9.mjs");
158
- if (t.endsWith(".json")) {
159
- const o = await e.readFile(t, "utf-8"), s = JSON.parse(o);
160
- return t === "package.json" ? s.logan || {} : s;
161
- } else if (t.endsWith(".js")) {
162
- const a = await import(`file://${n.resolve(t)}`);
163
- return a.default || a;
164
- }
165
- } catch {
166
- }
167
- return {};
168
- }
169
- async function O(t) {
170
- try {
171
- if (t.endsWith(".json")) {
172
- const e = await globalThis.Deno.readTextFile(t), n = JSON.parse(e);
173
- return t === "package.json" ? n.logan || {} : n;
174
- } else if (t.endsWith(".js")) {
175
- const e = await import(
176
- /* @vite-ignore */
177
- `./${t}`
178
- );
179
- return e.default || e;
180
- }
181
- } catch {
182
- }
183
- return {};
184
- }
185
- async function E(t) {
186
- return g(t);
187
- }
188
- function N(t) {
189
- switch (t.toLowerCase()) {
190
- case "debug":
191
- return r.DEBUG;
192
- case "info":
193
- return r.INFO;
194
- case "warn":
195
- case "warning":
196
- return r.WARN;
197
- case "error":
198
- return r.ERROR;
199
- case "silent":
200
- case "none":
201
- return r.SILENT;
202
- default:
203
- return r.INFO;
204
- }
205
- }
206
- function I(...t) {
207
- const e = m();
208
- return t.reduce(
209
- (n, o) => ({
210
- // biome-ignore lint/performance/noAccumulatingSpread: Config merging is not performance-critical, readability preferred
211
- ...n,
212
- ...o,
213
- metadata: {
214
- ...n.metadata,
215
- ...o.metadata
216
- },
217
- transports: o.transports || n.transports
218
- }),
219
- e
220
- );
221
- }
222
- class u {
223
- /**
224
- * Create a logger instance appropriate for the current runtime.
225
- * @param config - Optional configuration for the logger
226
- * @returns A logger instance
227
- */
228
- static create(e = {}) {
229
- const n = l(), o = u.mergeConfig(e);
230
- switch (n.name) {
231
- case "node":
232
- return new i(o);
233
- case "deno":
234
- return new c(o);
235
- case "bun":
236
- return new i(o);
237
- case "browser":
238
- case "webworker":
239
- return new c(o);
240
- default:
241
- return new c(o);
242
- }
243
- }
244
- /**
245
- * Create a child logger with additional metadata.
246
- * @param parent - The parent logger instance
247
- * @param metadata - Additional metadata to include in all child log messages
248
- * @returns A new logger instance with the additional metadata
249
- */
250
- // biome-ignore lint/suspicious/noExplicitAny: Intentional - logger accepts arbitrary metadata
251
- static createChild(e, n) {
252
- return e.child(n);
253
- }
254
- static mergeConfig(e) {
255
- const n = m();
256
- return {
257
- ...n,
258
- ...e,
259
- metadata: {
260
- ...n.metadata,
261
- ...e.metadata
262
- }
263
- };
264
- }
265
- }
266
- function R(t) {
267
- return u.create(t);
268
- }
269
- function S() {
270
- const t = h(), e = {
271
- level: C(t),
272
- colorize: t !== "production",
273
- timestamp: !0,
274
- format: t === "production" ? "json" : "text"
275
- };
276
- return R(e);
277
- }
278
- function h() {
279
- return typeof process < "u" && process.env ? process.env.NODE_ENV || process.env.NEXT_PUBLIC_APP_ENV || process.env.ENVIRONMENT || "development" : typeof window < "u" && globalThis.__ENV__ || "development";
280
- }
281
- function C(t) {
282
- switch (t) {
283
- case "production":
284
- return r.ERROR;
285
- case "staging":
286
- case "test":
287
- return r.WARN;
288
- case "development":
289
- case "dev":
290
- return r.DEBUG;
291
- default:
292
- return r.INFO;
293
- }
294
- }
295
- function _(t) {
296
- switch (t.toLowerCase()) {
297
- case "debug":
298
- return r.DEBUG;
299
- case "info":
300
- return r.INFO;
301
- case "warn":
302
- case "warning":
303
- return r.WARN;
304
- case "error":
305
- return r.ERROR;
306
- case "silent":
307
- case "none":
308
- return r.SILENT;
309
- default:
310
- return r.INFO;
311
- }
312
- }
313
- function G(t) {
314
- switch (t) {
315
- case r.DEBUG:
316
- return "debug";
317
- case r.INFO:
318
- return "info";
319
- case r.WARN:
320
- return "warn";
321
- case r.ERROR:
322
- return "error";
323
- case r.SILENT:
324
- return "silent";
325
- default:
326
- return "info";
327
- }
328
- }
329
- export {
330
- u as L,
331
- i as N,
332
- S as a,
333
- W as b,
334
- R as c,
335
- G as d,
336
- b as e,
337
- m as g,
338
- T as l,
339
- I as m,
340
- _ as s
341
- };
@@ -1 +0,0 @@
1
- "use strict";const o=require("./browser-BYqYELrw.js");class i extends o.BaseLogger{constructor(e={}){super(e),this.initializeWinston()}async initializeWinston(){try{const r=await import("winston");this.winston=this.createWinstonLogger(r)}catch(e){console.warn("[logan-logger] Winston not found, falling back to console logging:",e)}}createWinstonLogger(e){const r=e.format.combine(e.format.timestamp({format:"YYYY-MM-DD HH:mm:ss"}),e.format.errors({stack:!0}),e.format.json(),e.format.prettyPrint()),n=e.format.combine(e.format.colorize(),e.format.timestamp({format:"HH:mm:ss"}),e.format.printf(({timestamp:a,level:f,message:m,...g})=>{const d=Object.keys(g).length?JSON.stringify(g,null,2):"";return`${a} [${f}]: ${m} ${d}`})),s=e.createLogger({level:this.getWinstonLevel(this.level),format:r,transports:[new e.transports.Console({format:process.env.NODE_ENV==="production"?r:n})]});return process.env.NODE_ENV==="production"&&(s.add(new e.transports.File({filename:"logs/error.log",level:"error",maxsize:5242880,maxFiles:5})),s.add(new e.transports.File({filename:"logs/combined.log",maxsize:5242880,maxFiles:10}))),s}writeLog(e){this.winston?this.winston.log({level:this.getWinstonLevel(e.level),message:e.message,timestamp:e.timestamp,...e.metadata}):this.writeToConsole(e)}createChild(){return new i(this.config)}writeToConsole(e){const r=e.timestamp.toISOString(),n=o.LogLevel[e.level].toLowerCase(),s=e.metadata?` ${o.safeStringify(e.metadata)}`:"",a=`[${r}] ${n.toUpperCase()}: ${e.message}${s}`;switch(e.level){case o.LogLevel.DEBUG:console.debug(a);break;case o.LogLevel.INFO:console.info(a);break;case o.LogLevel.WARN:console.warn(a);break;case o.LogLevel.ERROR:console.error(a);break}}getWinstonLevel(e){switch(e){case o.LogLevel.DEBUG:return"debug";case o.LogLevel.INFO:return"info";case o.LogLevel.WARN:return"warn";case o.LogLevel.ERROR:return"error";default:return"info"}}setLevel(e){super.setLevel(e),this.winston&&(this.winston.level=this.getWinstonLevel(e))}}function v(t){return{write:e=>{t.info(e.trim())}}}function l(){const t=o.detectRuntime();return{level:o.LogLevel.INFO,format:"text",timestamp:!0,colorize:t.capabilities.colorSupport,metadata:{},transports:[{type:"console",options:{}}]}}function p(){const t={};if(typeof process<"u"&&process.env){const e=process.env;e.LOG_LEVEL&&(t.level=N(e.LOG_LEVEL)),e.LOG_FORMAT&&["json","text"].includes(e.LOG_FORMAT)&&(t.format=e.LOG_FORMAT),e.LOG_TIMESTAMP&&(t.timestamp=e.LOG_TIMESTAMP.toLowerCase()==="true"),e.LOG_COLOR&&(t.colorize=e.LOG_COLOR.toLowerCase()==="true")}return t}async function w(t){const e=o.detectRuntime();if(!e.capabilities.fileSystem)return{};const r=t?[t]:["logan.config.json","logan.config.js",".loganrc","package.json"];for(const n of r)try{if(e.name==="node")return await u(n);if(e.name==="deno")return await O(n);if(e.name==="bun")return await E(n)}catch{}return{}}async function u(t){try{const e=await Promise.resolve().then(()=>require("./__vite-browser-external-BcPniuRQ.js")),r=await Promise.resolve().then(()=>require("./__vite-browser-external-BcPniuRQ.js"));if(t.endsWith(".json")){const n=await e.readFile(t,"utf-8"),s=JSON.parse(n);return t==="package.json"?s.logan||{}:s}else if(t.endsWith(".js")){const a=await import(`file://${r.resolve(t)}`);return a.default||a}}catch{}return{}}async function O(t){try{if(t.endsWith(".json")){const e=await globalThis.Deno.readTextFile(t),r=JSON.parse(e);return t==="package.json"?r.logan||{}:r}else if(t.endsWith(".js")){const e=await import(`./${t}`);return e.default||e}}catch{}return{}}async function E(t){return u(t)}function N(t){switch(t.toLowerCase()){case"debug":return o.LogLevel.DEBUG;case"info":return o.LogLevel.INFO;case"warn":case"warning":return o.LogLevel.WARN;case"error":return o.LogLevel.ERROR;case"silent":case"none":return o.LogLevel.SILENT;default:return o.LogLevel.INFO}}function R(...t){const e=l();return t.reduce((r,n)=>({...r,...n,metadata:{...r.metadata,...n.metadata},transports:n.transports||r.transports}),e)}class c{static create(e={}){const r=o.detectRuntime(),n=c.mergeConfig(e);switch(r.name){case"node":return new i(n);case"deno":return new o.BrowserLogger(n);case"bun":return new i(n);case"browser":case"webworker":return new o.BrowserLogger(n);default:return new o.BrowserLogger(n)}}static createChild(e,r){return e.child(r)}static mergeConfig(e){const r=l();return{...r,...e,metadata:{...r.metadata,...e.metadata}}}}function L(t){return c.create(t)}function h(){const t=F(),e={level:C(t),colorize:t!=="production",timestamp:!0,format:t==="production"?"json":"text"};return L(e)}function F(){return typeof process<"u"&&process.env?process.env.NODE_ENV||process.env.NEXT_PUBLIC_APP_ENV||process.env.ENVIRONMENT||"development":typeof window<"u"&&globalThis.__ENV__||"development"}function C(t){switch(t){case"production":return o.LogLevel.ERROR;case"staging":case"test":return o.LogLevel.WARN;case"development":case"dev":return o.LogLevel.DEBUG;default:return o.LogLevel.INFO}}function b(t){switch(t.toLowerCase()){case"debug":return o.LogLevel.DEBUG;case"info":return o.LogLevel.INFO;case"warn":case"warning":return o.LogLevel.WARN;case"error":return o.LogLevel.ERROR;case"silent":case"none":return o.LogLevel.SILENT;default:return o.LogLevel.INFO}}function T(t){switch(t){case o.LogLevel.DEBUG:return"debug";case o.LogLevel.INFO:return"info";case o.LogLevel.WARN:return"warn";case o.LogLevel.ERROR:return"error";case o.LogLevel.SILENT:return"silent";default:return"info"}}exports.LoggerFactory=c;exports.NodeLogger=i;exports.createLogger=L;exports.createLoggerForEnvironment=h;exports.createMorganStream=v;exports.getDefaultConfig=l;exports.loadConfigFromEnvironment=p;exports.loadConfigFromFile=w;exports.logLevelToString=T;exports.mergeConfigs=R;exports.stringToLogLevel=b;