logan-logger 1.1.2 → 1.1.3
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/browser-BzeNXjes.js +1 -0
- package/dist/browser-C6UkWymL.mjs +293 -0
- package/dist/browser.d.ts +12 -16
- package/dist/browser.esm.js +80 -17
- package/dist/browser.js +1 -1
- package/dist/bun.esm.js +17 -16
- package/dist/bun.js +1 -1
- package/dist/deno.esm.js +21 -51
- package/dist/deno.js +1 -1
- package/dist/formatting-BDuKuXIh.js +1 -0
- package/dist/formatting-BZyid6rr.mjs +36 -0
- package/dist/index.esm.js +26 -25
- package/dist/index.js +1 -1
- package/dist/node-BO4IXArm.js +1 -0
- package/dist/node-cR0agAz0.mjs +336 -0
- package/dist/node.esm.js +1 -1
- package/dist/node.js +1 -1
- package/package.json +1 -1
- package/dist/node-BKsollr4.js +0 -1
- package/dist/node-BqvVrzA_.mjs +0 -626
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var n=(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||{});function f(){const t=c(),e=m(t),o=g(t);return{name:t,version:e,capabilities:o}}function c(){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"}function m(t){switch(t){case"node":return typeof process<"u"?process.version:void 0;case"deno":return typeof globalThis.Deno<"u"?globalThis.Deno.version?.deno:void 0;case"bun":return typeof globalThis.Bun<"u"?globalThis.Bun.version:void 0;case"browser":return typeof navigator<"u"?navigator.userAgent:void 0;default:return}}function g(t){switch(t){case"node":return{fileSystem:!0,colorSupport:!0,processInfo:!0,streams:!0};case"deno":return{fileSystem:!0,colorSupport:!0,processInfo:!0,streams:!0};case"bun":return{fileSystem:!0,colorSupport:!0,processInfo:!0,streams:!0};case"browser":return{fileSystem:!1,colorSupport:!0,processInfo:!1,streams:!1};case"webworker":return{fileSystem:!1,colorSupport:!1,processInfo:!1,streams:!1};default:return{fileSystem:!1,colorSupport:!1,processInfo:!1,streams:!1}}}function h(){return c()==="node"}function y(){return c()==="browser"}function b(){return c()==="deno"}function w(){return c()==="bun"}class l{constructor(e={}){this.childMetadata={},this.config=e,this.level=e.level??n.INFO,this.runtime=f().name}debug(e,o){this.log(n.DEBUG,e,o)}info(e,o){this.log(n.INFO,e,o)}warn(e,o){this.log(n.WARN,e,o)}error(e,o){this.log(n.ERROR,e,o)}log(e,o,s){if(!this.shouldLog(e))return;const r=typeof o=="function"?o():o,i={...this.childMetadata,...s},a={timestamp:new Date,level:e,message:r,metadata:Object.keys(i).length>0?i:void 0,runtime:this.runtime};this.writeLog(a)}setLevel(e){this.level=e}getLevel(){return this.level}child(e){const o=this.createChild();return o.childMetadata={...this.childMetadata,...e},o}shouldLog(e){return e>=this.level}}function d(t,e){const o=new WeakSet;return JSON.stringify(t,(s,r)=>{if(typeof r=="object"&&r!==null){if(o.has(r))return"[Circular]";o.add(r)}return r instanceof Error?{name:r.name,message:r.message,stack:r.stack,...Object.getOwnPropertyNames(r).reduce((i,a)=>(a!=="name"&&a!=="message"&&a!=="stack"&&(i[a]=r[a]),i),{})}:typeof r=="function"?`[Function: ${r.name||"anonymous"}]`:r===void 0?"[undefined]":typeof r=="bigint"?`[BigInt: ${r.toString()}]`:typeof r=="symbol"?`[Symbol: ${r.toString()}]`:r},e)}function p(t,e=["password","token","secret","key","auth"]){if(typeof t!="object"||t===null)return t;const o=Array.isArray(t)?[]:{};for(const[s,r]of Object.entries(t))e.some(a=>s.toLowerCase().includes(a.toLowerCase()))?o[s]="[REDACTED]":typeof r=="object"&&r!==null?o[s]=p(r,e):o[s]=r;return o}function S(t){return t instanceof Error?{name:t.name,message:t.message,stack:t.stack,...t}:t}class u extends l{constructor(e={}){super(e)}writeLog(e){const o=this.formatMessage(e),s=this.getConsoleStyle(e.level),r=e.metadata?` ${d(e.metadata)}`:"",i=`%c${o}${r}`;switch(e.level){case n.DEBUG:console.debug?console.debug(i,s):console.log(i,s);break;case n.INFO:console.info(i,s);break;case n.WARN:console.warn(i,s);break;case n.ERROR:console.error(i,s);break}}createChild(){return new u(this.config)}formatMessage(e){const o=e.timestamp.toISOString(),s=n[e.level].toUpperCase();return`[${o}] ${s}: ${e.message}`}getConsoleStyle(e){if(!this.config.colorize)return"";switch(e){case n.DEBUG:return"color: #888; font-weight: normal;";case n.INFO:return"color: #007acc; font-weight: normal;";case n.WARN:return"color: #ff8c00; font-weight: bold;";case n.ERROR:return"color: #dc3545; font-weight: bold;";default:return""}}shouldLogInProduction(){return(globalThis.process?.env?.NODE_ENV||globalThis.process?.env?.NEXT_PUBLIC_APP_ENV||"development")!=="production"||this.level<=n.ERROR}shouldLog(e){return!this.shouldLogInProduction()&&e<n.ERROR?!1:super.shouldLog(e)}}class R extends u{constructor(){super(...arguments),this.groupStack=[]}group(e){console.group(e),this.groupStack.push(e)}groupCollapsed(e){console.groupCollapsed(e),this.groupStack.push(e)}groupEnd(){console.groupEnd(),this.groupStack.pop()}getCurrentGroupStack(){return[...this.groupStack]}getCurrentGroupPath(){return this.groupStack.join(" > ")}time(e){console.time(e)}timeEnd(e){console.timeEnd(e)}trace(e,o){console.trace(e,o)}count(e){console.count(e)}countReset(e){console.countReset(e)}table(e){console.table(e)}}class k extends u{mark(e){typeof performance<"u"&&performance.mark&&performance.mark(e)}measure(e,o,s){if(typeof performance<"u"&&performance.measure)try{performance.measure(e,o,s);const r=performance.getEntriesByName(e,"measure");if(r.length>0){const i=r[r.length-1];this.info(`Performance: ${e}`,{duration:i.duration,startTime:i.startTime})}}catch(r){this.warn("Failed to measure performance",{name:e,error:r})}}clearMarks(e){typeof performance<"u"&&performance.clearMarks&&performance.clearMarks(e)}clearMeasures(e){typeof performance<"u"&&performance.clearMeasures&&performance.clearMeasures(e)}}exports.BaseLogger=l;exports.BrowserLogger=u;exports.ConsoleGroupLogger=R;exports.LogLevel=n;exports.PerformanceLogger=k;exports.detectRuntime=f;exports.filterSensitiveData=p;exports.isBrowser=y;exports.isBun=w;exports.isDeno=b;exports.isNode=h;exports.safeStringify=d;exports.serializeError=S;
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
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 || {});
|
|
2
|
+
function f() {
|
|
3
|
+
const t = c(), e = l(t), o = d(t);
|
|
4
|
+
return {
|
|
5
|
+
name: t,
|
|
6
|
+
version: e,
|
|
7
|
+
capabilities: o
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function c() {
|
|
11
|
+
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";
|
|
12
|
+
}
|
|
13
|
+
function l(t) {
|
|
14
|
+
switch (t) {
|
|
15
|
+
case "node":
|
|
16
|
+
return typeof process < "u" ? process.version : void 0;
|
|
17
|
+
case "deno":
|
|
18
|
+
return typeof globalThis.Deno < "u" ? globalThis.Deno.version?.deno : void 0;
|
|
19
|
+
case "bun":
|
|
20
|
+
return typeof globalThis.Bun < "u" ? globalThis.Bun.version : void 0;
|
|
21
|
+
case "browser":
|
|
22
|
+
return typeof navigator < "u" ? navigator.userAgent : void 0;
|
|
23
|
+
default:
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function d(t) {
|
|
28
|
+
switch (t) {
|
|
29
|
+
case "node":
|
|
30
|
+
return {
|
|
31
|
+
fileSystem: !0,
|
|
32
|
+
colorSupport: !0,
|
|
33
|
+
processInfo: !0,
|
|
34
|
+
streams: !0
|
|
35
|
+
};
|
|
36
|
+
case "deno":
|
|
37
|
+
return {
|
|
38
|
+
fileSystem: !0,
|
|
39
|
+
colorSupport: !0,
|
|
40
|
+
processInfo: !0,
|
|
41
|
+
streams: !0
|
|
42
|
+
};
|
|
43
|
+
case "bun":
|
|
44
|
+
return {
|
|
45
|
+
fileSystem: !0,
|
|
46
|
+
colorSupport: !0,
|
|
47
|
+
processInfo: !0,
|
|
48
|
+
streams: !0
|
|
49
|
+
};
|
|
50
|
+
case "browser":
|
|
51
|
+
return {
|
|
52
|
+
fileSystem: !1,
|
|
53
|
+
colorSupport: !0,
|
|
54
|
+
// CSS styling in console
|
|
55
|
+
processInfo: !1,
|
|
56
|
+
streams: !1
|
|
57
|
+
};
|
|
58
|
+
case "webworker":
|
|
59
|
+
return {
|
|
60
|
+
fileSystem: !1,
|
|
61
|
+
colorSupport: !1,
|
|
62
|
+
processInfo: !1,
|
|
63
|
+
streams: !1
|
|
64
|
+
};
|
|
65
|
+
default:
|
|
66
|
+
return {
|
|
67
|
+
fileSystem: !1,
|
|
68
|
+
colorSupport: !1,
|
|
69
|
+
processInfo: !1,
|
|
70
|
+
streams: !1
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function h() {
|
|
75
|
+
return c() === "node";
|
|
76
|
+
}
|
|
77
|
+
function y() {
|
|
78
|
+
return c() === "browser";
|
|
79
|
+
}
|
|
80
|
+
function b() {
|
|
81
|
+
return c() === "deno";
|
|
82
|
+
}
|
|
83
|
+
function w() {
|
|
84
|
+
return c() === "bun";
|
|
85
|
+
}
|
|
86
|
+
class p {
|
|
87
|
+
constructor(e = {}) {
|
|
88
|
+
this.childMetadata = {}, this.config = e, this.level = e.level ?? n.INFO, this.runtime = f().name;
|
|
89
|
+
}
|
|
90
|
+
debug(e, o) {
|
|
91
|
+
this.log(n.DEBUG, e, o);
|
|
92
|
+
}
|
|
93
|
+
info(e, o) {
|
|
94
|
+
this.log(n.INFO, e, o);
|
|
95
|
+
}
|
|
96
|
+
warn(e, o) {
|
|
97
|
+
this.log(n.WARN, e, o);
|
|
98
|
+
}
|
|
99
|
+
error(e, o) {
|
|
100
|
+
this.log(n.ERROR, e, o);
|
|
101
|
+
}
|
|
102
|
+
log(e, o, s) {
|
|
103
|
+
if (!this.shouldLog(e))
|
|
104
|
+
return;
|
|
105
|
+
const r = typeof o == "function" ? o() : o, i = { ...this.childMetadata, ...s }, a = {
|
|
106
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
107
|
+
level: e,
|
|
108
|
+
message: r,
|
|
109
|
+
metadata: Object.keys(i).length > 0 ? i : void 0,
|
|
110
|
+
runtime: this.runtime
|
|
111
|
+
};
|
|
112
|
+
this.writeLog(a);
|
|
113
|
+
}
|
|
114
|
+
setLevel(e) {
|
|
115
|
+
this.level = e;
|
|
116
|
+
}
|
|
117
|
+
getLevel() {
|
|
118
|
+
return this.level;
|
|
119
|
+
}
|
|
120
|
+
child(e) {
|
|
121
|
+
const o = this.createChild();
|
|
122
|
+
return o.childMetadata = { ...this.childMetadata, ...e }, o;
|
|
123
|
+
}
|
|
124
|
+
shouldLog(e) {
|
|
125
|
+
return e >= this.level;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function m(t, e) {
|
|
129
|
+
const o = /* @__PURE__ */ new WeakSet();
|
|
130
|
+
return JSON.stringify(t, (s, r) => {
|
|
131
|
+
if (typeof r == "object" && r !== null) {
|
|
132
|
+
if (o.has(r))
|
|
133
|
+
return "[Circular]";
|
|
134
|
+
o.add(r);
|
|
135
|
+
}
|
|
136
|
+
return r instanceof Error ? {
|
|
137
|
+
name: r.name,
|
|
138
|
+
message: r.message,
|
|
139
|
+
stack: r.stack,
|
|
140
|
+
...Object.getOwnPropertyNames(r).reduce((i, a) => (a !== "name" && a !== "message" && a !== "stack" && (i[a] = r[a]), i), {})
|
|
141
|
+
} : typeof r == "function" ? `[Function: ${r.name || "anonymous"}]` : r === void 0 ? "[undefined]" : typeof r == "bigint" ? `[BigInt: ${r.toString()}]` : typeof r == "symbol" ? `[Symbol: ${r.toString()}]` : r;
|
|
142
|
+
}, e);
|
|
143
|
+
}
|
|
144
|
+
function g(t, e = ["password", "token", "secret", "key", "auth"]) {
|
|
145
|
+
if (typeof t != "object" || t === null)
|
|
146
|
+
return t;
|
|
147
|
+
const o = Array.isArray(t) ? [] : {};
|
|
148
|
+
for (const [s, r] of Object.entries(t))
|
|
149
|
+
e.some(
|
|
150
|
+
(a) => s.toLowerCase().includes(a.toLowerCase())
|
|
151
|
+
) ? o[s] = "[REDACTED]" : typeof r == "object" && r !== null ? o[s] = g(r, e) : o[s] = r;
|
|
152
|
+
return o;
|
|
153
|
+
}
|
|
154
|
+
function S(t) {
|
|
155
|
+
return t instanceof Error ? {
|
|
156
|
+
name: t.name,
|
|
157
|
+
message: t.message,
|
|
158
|
+
stack: t.stack,
|
|
159
|
+
...t
|
|
160
|
+
// Include any additional properties
|
|
161
|
+
} : t;
|
|
162
|
+
}
|
|
163
|
+
class u extends p {
|
|
164
|
+
constructor(e = {}) {
|
|
165
|
+
super(e);
|
|
166
|
+
}
|
|
167
|
+
writeLog(e) {
|
|
168
|
+
const o = this.formatMessage(e), s = this.getConsoleStyle(e.level), r = e.metadata ? ` ${m(e.metadata)}` : "", i = `%c${o}${r}`;
|
|
169
|
+
switch (e.level) {
|
|
170
|
+
case n.DEBUG:
|
|
171
|
+
console.debug ? console.debug(i, s) : console.log(i, s);
|
|
172
|
+
break;
|
|
173
|
+
case n.INFO:
|
|
174
|
+
console.info(i, s);
|
|
175
|
+
break;
|
|
176
|
+
case n.WARN:
|
|
177
|
+
console.warn(i, s);
|
|
178
|
+
break;
|
|
179
|
+
case n.ERROR:
|
|
180
|
+
console.error(i, s);
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
createChild() {
|
|
185
|
+
return new u(this.config);
|
|
186
|
+
}
|
|
187
|
+
formatMessage(e) {
|
|
188
|
+
const o = e.timestamp.toISOString(), s = n[e.level].toUpperCase();
|
|
189
|
+
return `[${o}] ${s}: ${e.message}`;
|
|
190
|
+
}
|
|
191
|
+
getConsoleStyle(e) {
|
|
192
|
+
if (!this.config.colorize)
|
|
193
|
+
return "";
|
|
194
|
+
switch (e) {
|
|
195
|
+
case n.DEBUG:
|
|
196
|
+
return "color: #888; font-weight: normal;";
|
|
197
|
+
case n.INFO:
|
|
198
|
+
return "color: #007acc; font-weight: normal;";
|
|
199
|
+
case n.WARN:
|
|
200
|
+
return "color: #ff8c00; font-weight: bold;";
|
|
201
|
+
case n.ERROR:
|
|
202
|
+
return "color: #dc3545; font-weight: bold;";
|
|
203
|
+
default:
|
|
204
|
+
return "";
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
shouldLogInProduction() {
|
|
208
|
+
return (globalThis.process?.env?.NODE_ENV || globalThis.process?.env?.NEXT_PUBLIC_APP_ENV || "development") !== "production" || this.level <= n.ERROR;
|
|
209
|
+
}
|
|
210
|
+
shouldLog(e) {
|
|
211
|
+
return !this.shouldLogInProduction() && e < n.ERROR ? !1 : super.shouldLog(e);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
class R extends u {
|
|
215
|
+
constructor() {
|
|
216
|
+
super(...arguments), this.groupStack = [];
|
|
217
|
+
}
|
|
218
|
+
group(e) {
|
|
219
|
+
console.group(e), this.groupStack.push(e);
|
|
220
|
+
}
|
|
221
|
+
groupCollapsed(e) {
|
|
222
|
+
console.groupCollapsed(e), this.groupStack.push(e);
|
|
223
|
+
}
|
|
224
|
+
groupEnd() {
|
|
225
|
+
console.groupEnd(), this.groupStack.pop();
|
|
226
|
+
}
|
|
227
|
+
getCurrentGroupStack() {
|
|
228
|
+
return [...this.groupStack];
|
|
229
|
+
}
|
|
230
|
+
getCurrentGroupPath() {
|
|
231
|
+
return this.groupStack.join(" > ");
|
|
232
|
+
}
|
|
233
|
+
time(e) {
|
|
234
|
+
console.time(e);
|
|
235
|
+
}
|
|
236
|
+
timeEnd(e) {
|
|
237
|
+
console.timeEnd(e);
|
|
238
|
+
}
|
|
239
|
+
trace(e, o) {
|
|
240
|
+
console.trace(e, o);
|
|
241
|
+
}
|
|
242
|
+
count(e) {
|
|
243
|
+
console.count(e);
|
|
244
|
+
}
|
|
245
|
+
countReset(e) {
|
|
246
|
+
console.countReset(e);
|
|
247
|
+
}
|
|
248
|
+
table(e) {
|
|
249
|
+
console.table(e);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
class k extends u {
|
|
253
|
+
mark(e) {
|
|
254
|
+
typeof performance < "u" && performance.mark && performance.mark(e);
|
|
255
|
+
}
|
|
256
|
+
measure(e, o, s) {
|
|
257
|
+
if (typeof performance < "u" && performance.measure)
|
|
258
|
+
try {
|
|
259
|
+
performance.measure(e, o, s);
|
|
260
|
+
const r = performance.getEntriesByName(e, "measure");
|
|
261
|
+
if (r.length > 0) {
|
|
262
|
+
const i = r[r.length - 1];
|
|
263
|
+
this.info(`Performance: ${e}`, {
|
|
264
|
+
duration: i.duration,
|
|
265
|
+
startTime: i.startTime
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
} catch (r) {
|
|
269
|
+
this.warn("Failed to measure performance", { name: e, error: r });
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
clearMarks(e) {
|
|
273
|
+
typeof performance < "u" && performance.clearMarks && performance.clearMarks(e);
|
|
274
|
+
}
|
|
275
|
+
clearMeasures(e) {
|
|
276
|
+
typeof performance < "u" && performance.clearMeasures && performance.clearMeasures(e);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
export {
|
|
280
|
+
u as B,
|
|
281
|
+
R as C,
|
|
282
|
+
n as L,
|
|
283
|
+
k as P,
|
|
284
|
+
y as a,
|
|
285
|
+
b,
|
|
286
|
+
w as c,
|
|
287
|
+
f as d,
|
|
288
|
+
S as e,
|
|
289
|
+
g as f,
|
|
290
|
+
p as g,
|
|
291
|
+
h as i,
|
|
292
|
+
m as s
|
|
293
|
+
};
|
package/dist/browser.d.ts
CHANGED
|
@@ -43,28 +43,15 @@ export declare class ConsoleGroupLogger extends BrowserLogger {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* @returns A logger instance appropriate for the current runtime
|
|
49
|
-
* @example
|
|
50
|
-
* ```typescript
|
|
51
|
-
* import { createLogger, LogLevel } from 'logan-logger';
|
|
52
|
-
*
|
|
53
|
-
* const logger = createLogger({
|
|
54
|
-
* level: LogLevel.DEBUG,
|
|
55
|
-
* colorize: true
|
|
56
|
-
* });
|
|
57
|
-
*
|
|
58
|
-
* logger.info('Hello world!');
|
|
59
|
-
* ```
|
|
46
|
+
* Browser-specific logger factory function.
|
|
47
|
+
* Creates a BrowserLogger instance without importing Node.js dependencies.
|
|
60
48
|
*/
|
|
61
49
|
export declare function createLogger(config?: Partial<LoggerConfig>): ILogger;
|
|
62
50
|
|
|
63
51
|
/**
|
|
64
|
-
* Create a logger with configuration based on the current environment.
|
|
52
|
+
* Create a browser logger with configuration based on the current environment.
|
|
65
53
|
* Automatically detects production/development/test environments and
|
|
66
54
|
* sets appropriate log levels and formatting.
|
|
67
|
-
* @returns A logger instance configured for the current environment
|
|
68
55
|
*/
|
|
69
56
|
export declare function createLoggerForEnvironment(): ILogger;
|
|
70
57
|
|
|
@@ -203,6 +190,13 @@ export declare function isDeno(): boolean;
|
|
|
203
190
|
*/
|
|
204
191
|
export declare function isNode(): boolean;
|
|
205
192
|
|
|
193
|
+
export declare const log: {
|
|
194
|
+
debug: (message: string, meta?: any) => void;
|
|
195
|
+
info: (message: string, meta?: any) => void;
|
|
196
|
+
warn: (message: string, meta?: any) => void;
|
|
197
|
+
error: (message: string, meta?: any) => void;
|
|
198
|
+
};
|
|
199
|
+
|
|
206
200
|
/**
|
|
207
201
|
* Internal representation of a log entry.
|
|
208
202
|
*/
|
|
@@ -219,6 +213,8 @@ declare interface LogEntry {
|
|
|
219
213
|
runtime: RuntimeName;
|
|
220
214
|
}
|
|
221
215
|
|
|
216
|
+
export declare const logger: ILogger;
|
|
217
|
+
|
|
222
218
|
/**
|
|
223
219
|
* Configuration options for creating a logger instance.
|
|
224
220
|
*/
|
package/dist/browser.esm.js
CHANGED
|
@@ -1,19 +1,82 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { L as o, B as s, d as a } from "./browser-C6UkWymL.mjs";
|
|
2
|
+
import { C as v, P as E, f as L, a as N, c as w, b as B, i as _, s as C, e as R } from "./browser-C6UkWymL.mjs";
|
|
3
|
+
import { a as x, f as y } from "./formatting-BZyid6rr.mjs";
|
|
4
|
+
function i() {
|
|
5
|
+
const e = a();
|
|
6
|
+
return {
|
|
7
|
+
level: o.INFO,
|
|
8
|
+
format: "text",
|
|
9
|
+
timestamp: !0,
|
|
10
|
+
colorize: e.capabilities.colorSupport,
|
|
11
|
+
metadata: {},
|
|
12
|
+
transports: [
|
|
13
|
+
{
|
|
14
|
+
type: "console",
|
|
15
|
+
options: {}
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function c() {
|
|
21
|
+
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";
|
|
22
|
+
}
|
|
23
|
+
function f(e) {
|
|
24
|
+
switch (e) {
|
|
25
|
+
case "production":
|
|
26
|
+
return o.ERROR;
|
|
27
|
+
case "staging":
|
|
28
|
+
case "test":
|
|
29
|
+
return o.WARN;
|
|
30
|
+
case "development":
|
|
31
|
+
case "dev":
|
|
32
|
+
return o.DEBUG;
|
|
33
|
+
default:
|
|
34
|
+
return o.INFO;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function u(e = {}) {
|
|
38
|
+
const r = i(), n = {
|
|
39
|
+
...r,
|
|
40
|
+
...e,
|
|
41
|
+
metadata: {
|
|
42
|
+
...r.metadata,
|
|
43
|
+
...e.metadata
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return new s(n);
|
|
47
|
+
}
|
|
48
|
+
function g() {
|
|
49
|
+
const e = c(), r = {
|
|
50
|
+
level: f(e),
|
|
51
|
+
colorize: e !== "production",
|
|
52
|
+
timestamp: !0,
|
|
53
|
+
format: e === "production" ? "json" : "text"
|
|
54
|
+
};
|
|
55
|
+
return u(r);
|
|
56
|
+
}
|
|
57
|
+
const t = g(), p = {
|
|
58
|
+
debug: (e, r) => t.debug(e, r),
|
|
59
|
+
info: (e, r) => t.info(e, r),
|
|
60
|
+
warn: (e, r) => t.warn(e, r),
|
|
61
|
+
error: (e, r) => t.error(e, r)
|
|
62
|
+
};
|
|
3
63
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
g as
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
p as
|
|
64
|
+
s as BrowserLogger,
|
|
65
|
+
v as ConsoleGroupLogger,
|
|
66
|
+
o as LogLevel,
|
|
67
|
+
E as PerformanceLogger,
|
|
68
|
+
u as createLogger,
|
|
69
|
+
g as createLoggerForEnvironment,
|
|
70
|
+
a as detectRuntime,
|
|
71
|
+
L as filterSensitiveData,
|
|
72
|
+
x as formatLevel,
|
|
73
|
+
y as formatLogEntry,
|
|
74
|
+
N as isBrowser,
|
|
75
|
+
w as isBun,
|
|
76
|
+
B as isDeno,
|
|
77
|
+
_ as isNode,
|
|
78
|
+
p as log,
|
|
79
|
+
t as logger,
|
|
80
|
+
C as safeStringify,
|
|
81
|
+
R as serializeError
|
|
19
82
|
};
|
package/dist/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./browser-BzeNXjes.js"),n=require("./formatting-BDuKuXIh.js");function a(){const r=e.detectRuntime();return{level:e.LogLevel.INFO,format:"text",timestamp:!0,colorize:r.capabilities.colorSupport,metadata:{},transports:[{type:"console",options:{}}]}}function c(){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 l(r){switch(r){case"production":return e.LogLevel.ERROR;case"staging":case"test":return e.LogLevel.WARN;case"development":case"dev":return e.LogLevel.DEBUG;default:return e.LogLevel.INFO}}function i(r={}){const o=a(),g={...o,...r,metadata:{...o.metadata,...r.metadata}};return new e.BrowserLogger(g)}function s(){const r=c(),o={level:l(r),colorize:r!=="production",timestamp:!0,format:r==="production"?"json":"text"};return i(o)}const t=s(),u={debug:(r,o)=>t.debug(r,o),info:(r,o)=>t.info(r,o),warn:(r,o)=>t.warn(r,o),error:(r,o)=>t.error(r,o)};exports.BrowserLogger=e.BrowserLogger;exports.ConsoleGroupLogger=e.ConsoleGroupLogger;exports.LogLevel=e.LogLevel;exports.PerformanceLogger=e.PerformanceLogger;exports.detectRuntime=e.detectRuntime;exports.filterSensitiveData=e.filterSensitiveData;exports.isBrowser=e.isBrowser;exports.isBun=e.isBun;exports.isDeno=e.isDeno;exports.isNode=e.isNode;exports.safeStringify=e.safeStringify;exports.serializeError=e.serializeError;exports.formatLevel=n.formatLevel;exports.formatLogEntry=n.formatLogEntry;exports.createLogger=i;exports.createLoggerForEnvironment=s;exports.log=u;exports.logger=t;
|
package/dist/bun.esm.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { N as o,
|
|
2
|
-
import {
|
|
1
|
+
import { N as o, c as r, a as s, g as i, l as t, b as n, m as f } from "./node-cR0agAz0.mjs";
|
|
2
|
+
import { d as m, f as l, a as d, c, b as L, i as v, s as C, e as E } from "./browser-C6UkWymL.mjs";
|
|
3
|
+
import { a as p, f as u } from "./formatting-BZyid6rr.mjs";
|
|
3
4
|
export {
|
|
4
5
|
o as NodeLogger,
|
|
5
6
|
r as createLogger,
|
|
6
7
|
s as createLoggerForEnvironment,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
m as detectRuntime,
|
|
9
|
+
l as filterSensitiveData,
|
|
10
|
+
p as formatLevel,
|
|
11
|
+
u as formatLogEntry,
|
|
12
|
+
i as getDefaultConfig,
|
|
13
|
+
d as isBrowser,
|
|
14
|
+
c as isBun,
|
|
15
|
+
L as isDeno,
|
|
16
|
+
v as isNode,
|
|
17
|
+
t as loadConfigFromEnvironment,
|
|
18
|
+
n as loadConfigFromFile,
|
|
19
|
+
f as mergeConfigs,
|
|
20
|
+
C as safeStringify,
|
|
21
|
+
E as serializeError
|
|
21
22
|
};
|
package/dist/bun.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./node-BO4IXArm.js"),e=require("./browser-BzeNXjes.js"),o=require("./formatting-BDuKuXIh.js");exports.NodeLogger=r.NodeLogger;exports.createLogger=r.createLogger;exports.createLoggerForEnvironment=r.createLoggerForEnvironment;exports.getDefaultConfig=r.getDefaultConfig;exports.loadConfigFromEnvironment=r.loadConfigFromEnvironment;exports.loadConfigFromFile=r.loadConfigFromFile;exports.mergeConfigs=r.mergeConfigs;exports.detectRuntime=e.detectRuntime;exports.filterSensitiveData=e.filterSensitiveData;exports.isBrowser=e.isBrowser;exports.isBun=e.isBun;exports.isDeno=e.isDeno;exports.isNode=e.isNode;exports.safeStringify=e.safeStringify;exports.serializeError=e.serializeError;exports.formatLevel=o.formatLevel;exports.formatLogEntry=o.formatLogEntry;
|
package/dist/deno.esm.js
CHANGED
|
@@ -1,54 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
if (s === "json") {
|
|
5
|
-
const r = {
|
|
6
|
-
timestamp: e.timestamp.toISOString(),
|
|
7
|
-
level: o[e.level].toLowerCase(),
|
|
8
|
-
message: e.message,
|
|
9
|
-
runtime: e.runtime
|
|
10
|
-
};
|
|
11
|
-
return e.metadata !== void 0 && (r.metadata = e.metadata), i(r);
|
|
12
|
-
}
|
|
13
|
-
const a = e.timestamp.toISOString(), t = o[e.level].toUpperCase(), m = e.metadata ? ` ${i(e.metadata)}` : "";
|
|
14
|
-
return `[${a}] ${t}: ${e.message}${m}`;
|
|
15
|
-
}
|
|
16
|
-
function l(e, s = !1) {
|
|
17
|
-
const a = o[e].toUpperCase();
|
|
18
|
-
if (!s)
|
|
19
|
-
return a;
|
|
20
|
-
const t = {
|
|
21
|
-
[o.DEBUG]: "\x1B[36m",
|
|
22
|
-
// Cyan
|
|
23
|
-
[o.INFO]: "\x1B[32m",
|
|
24
|
-
// Green
|
|
25
|
-
[o.WARN]: "\x1B[33m",
|
|
26
|
-
// Yellow
|
|
27
|
-
[o.ERROR]: "\x1B[31m",
|
|
28
|
-
// Red
|
|
29
|
-
[o.SILENT]: "\x1B[37m"
|
|
30
|
-
// White
|
|
31
|
-
};
|
|
32
|
-
return `${t[e] || t[o.INFO]}${a}\x1B[0m`;
|
|
33
|
-
}
|
|
1
|
+
import { B as a, C as o, P as s, d as i, f as g, a as t, c as n, b as f, i as m, s as l, e as L } from "./browser-C6UkWymL.mjs";
|
|
2
|
+
import { c as C, a as d, g as p, l as u, b as v, m as B } from "./node-cR0agAz0.mjs";
|
|
3
|
+
import { a as F, f as x } from "./formatting-BZyid6rr.mjs";
|
|
34
4
|
export {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
5
|
+
a as BrowserLogger,
|
|
6
|
+
o as ConsoleGroupLogger,
|
|
7
|
+
s as PerformanceLogger,
|
|
8
|
+
C as createLogger,
|
|
39
9
|
d as createLoggerForEnvironment,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
10
|
+
i as detectRuntime,
|
|
11
|
+
g as filterSensitiveData,
|
|
12
|
+
F as formatLevel,
|
|
13
|
+
x as formatLogEntry,
|
|
14
|
+
p as getDefaultConfig,
|
|
15
|
+
t as isBrowser,
|
|
16
|
+
n as isBun,
|
|
17
|
+
f as isDeno,
|
|
18
|
+
m as isNode,
|
|
19
|
+
u as loadConfigFromEnvironment,
|
|
20
|
+
v as loadConfigFromFile,
|
|
21
|
+
B as mergeConfigs,
|
|
22
|
+
l as safeStringify,
|
|
23
|
+
L as serializeError
|
|
54
24
|
};
|
package/dist/deno.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./browser-BzeNXjes.js"),r=require("./node-BO4IXArm.js"),o=require("./formatting-BDuKuXIh.js");exports.BrowserLogger=e.BrowserLogger;exports.ConsoleGroupLogger=e.ConsoleGroupLogger;exports.PerformanceLogger=e.PerformanceLogger;exports.detectRuntime=e.detectRuntime;exports.filterSensitiveData=e.filterSensitiveData;exports.isBrowser=e.isBrowser;exports.isBun=e.isBun;exports.isDeno=e.isDeno;exports.isNode=e.isNode;exports.safeStringify=e.safeStringify;exports.serializeError=e.serializeError;exports.createLogger=r.createLogger;exports.createLoggerForEnvironment=r.createLoggerForEnvironment;exports.getDefaultConfig=r.getDefaultConfig;exports.loadConfigFromEnvironment=r.loadConfigFromEnvironment;exports.loadConfigFromFile=r.loadConfigFromFile;exports.mergeConfigs=r.mergeConfigs;exports.formatLevel=o.formatLevel;exports.formatLogEntry=o.formatLogEntry;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("./browser-BzeNXjes.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;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { L as e, s as i } from "./browser-C6UkWymL.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
|
+
};
|