logan-logger 2.2.0 → 2.4.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/dist/browser.cjs +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/bun.cjs +1 -1
- package/dist/bun.mjs +3 -3
- package/dist/chunks/config-BIFVBkeG.cjs +1 -0
- package/dist/chunks/{config-CpbjY9zX.mjs → config-C0Vj3nIk.mjs} +126 -86
- package/dist/chunks/{config-file-WYBC6sSB.cjs → config-file-BNPm7ZNS.cjs} +1 -1
- package/dist/chunks/{config-file-CvMv3rgc.mjs → config-file-CmxNUX1Z.mjs} +1 -1
- package/dist/chunks/{file-transport-yIPiX8TP.mjs → file-transport-Y2ZoG0re.mjs} +2 -2
- package/dist/chunks/{file-transport-B34EGzxL.cjs → file-transport-oFpf1vbE.cjs} +1 -1
- package/dist/core/internal.d.cts +47 -0
- package/dist/core/internal.d.mts +47 -0
- package/dist/core/internal.d.ts +47 -0
- package/dist/core/logger.d.cts +8 -0
- package/dist/core/logger.d.mts +8 -0
- package/dist/core/logger.d.ts +8 -0
- package/dist/deno.cjs +1 -1
- package/dist/deno.mjs +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/node.cjs +1 -1
- package/dist/node.mjs +2 -2
- package/dist/utils/serialization.d.cts +16 -3
- package/dist/utils/serialization.d.mts +16 -3
- package/dist/utils/serialization.d.ts +16 -3
- package/package.json +1 -1
- package/dist/chunks/config-DpSCCiRz.cjs +0 -1
package/dist/browser.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./chunks/config-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./chunks/config-BIFVBkeG.cjs");function t(){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 n(t){switch(t){case`production`:return e._.ERROR;case`staging`:case`test`:return e._.WARN;case`development`:case`dev`:return e._.DEBUG;default:return e._.INFO}}function r(t={}){let n=t.ignoreEnvironment?{}:e.n();return new e.u(e.r(t,n))}function i(){let e=t();return r({level:n(e),colorize:e!==`production`,timestamp:!0,format:e===`production`?`json`:`text`})}var a=i(),o={debug:(e,t)=>a.debug(e,t),info:(e,t)=>a.info(e,t),warn:(e,t)=>a.warn(e,t),error:(e,t)=>a.error(e,t)};exports.BrowserLogger=e.u,exports.ConsoleGroupLogger=e.d,exports.LogLevel=e._,exports.PerformanceLogger=e.f,exports.createLogger=r,exports.createLoggerForEnvironment=i,exports.detectRuntime=e.v,exports.filterSensitiveData=e.p,exports.formatLevel=e.c,exports.formatLogEntry=e.l,exports.isBrowser=e.y,exports.isBun=e.b,exports.isDeno=e.x,exports.isNode=e.S,exports.log=o,exports.logger=a,exports.safeStringify=e.m,exports.serializeError=e.h;
|
package/dist/browser.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as e, _ as t, b as n, c as r, d as i, f as a, h as o, l as s, m as c, n as l, p as u, r as d, u as f, v as p, x as m, y as h } from "./chunks/config-
|
|
1
|
+
import { S as e, _ as t, b as n, c as r, d as i, f as a, h as o, l as s, m as c, n as l, p as u, r as d, u as f, v as p, x as m, y as h } from "./chunks/config-C0Vj3nIk.mjs";
|
|
2
2
|
//#region src/browser.ts
|
|
3
3
|
function g() {
|
|
4
4
|
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";
|
package/dist/bun.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./chunks/config-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./chunks/config-BIFVBkeG.cjs"),t=require("./chunks/config-file-BNPm7ZNS.cjs"),n=require("./chunks/file-transport-oFpf1vbE.cjs");exports.ConsoleTransport=t.l,exports.FileTransport=n.t,exports.NodeLogger=t.s,exports.createLogger=t.r,exports.createLoggerForEnvironment=t.i,exports.createTransports=t.u,exports.detectRuntime=e.v,exports.filterSensitiveData=e.p,exports.formatLevel=e.c,exports.formatLogEntry=e.l,exports.getDefaultConfig=e.t,exports.isBrowser=e.y,exports.isBun=e.b,exports.isDeno=e.x,exports.isNode=e.S,exports.loadConfigFromEnvironment=e.n,exports.loadConfigFromFile=t.t,exports.mergeConfigs=e.r,exports.registerTransport=t.f,exports.resetEnvironmentWarnings=e.i,exports.safeStringify=e.m,exports.serializeError=e.h,exports.shouldColorize=e.a,exports.tryParseLogLevel=e.o;
|
package/dist/bun.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as e, a as t, b as n, c as r, h as i, i as a, l as o, m as s, n as c, o as l, p as u, r as d, t as f, v as p, x as m, y as h } from "./chunks/config-
|
|
2
|
-
import { f as g, i as _, l as v, r as y, s as b, t as x, u as S } from "./chunks/config-file-
|
|
3
|
-
import { t as C } from "./chunks/file-transport-
|
|
1
|
+
import { S as e, a as t, b as n, c as r, h as i, i as a, l as o, m as s, n as c, o as l, p as u, r as d, t as f, v as p, x as m, y as h } from "./chunks/config-C0Vj3nIk.mjs";
|
|
2
|
+
import { f as g, i as _, l as v, r as y, s as b, t as x, u as S } from "./chunks/config-file-CmxNUX1Z.mjs";
|
|
3
|
+
import { t as C } from "./chunks/file-transport-Y2ZoG0re.mjs";
|
|
4
4
|
export { v as ConsoleTransport, C as FileTransport, b as NodeLogger, y as createLogger, _ as createLoggerForEnvironment, S as createTransports, p as detectRuntime, u as filterSensitiveData, r as formatLevel, o as formatLogEntry, f as getDefaultConfig, h as isBrowser, n as isBun, m as isDeno, e as isNode, c as loadConfigFromEnvironment, x as loadConfigFromFile, d as mergeConfigs, g as registerTransport, a as resetEnvironmentWarnings, s as safeStringify, i as serializeError, t as shouldColorize, l as tryParseLogLevel };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(){let e=t();return{name:e,version:n(e),capabilities:r(e)}}function t(){return globalThis.Deno===void 0?globalThis.Bun===void 0?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`:`bun`:`deno`}function n(e){switch(e){case`node`:return typeof process<`u`?process.version:void 0;case`deno`:return globalThis.Deno===void 0?void 0:globalThis.Deno.version?.deno;case`bun`:return globalThis.Bun===void 0?void 0:globalThis.Bun.version;case`browser`:return typeof navigator<`u`?navigator.userAgent:void 0;default:return}}function r(e){switch(e){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 i(){return t()===`node`}function a(){return t()===`browser`}function o(){return t()===`deno`}function s(){return t()===`bun`}var c=Symbol.for(`logan-logger.internals`);function l(e){return e[c]??{}}var u=function(e){return e[e.DEBUG=0]=`DEBUG`,e[e.INFO=1]=`INFO`,e[e.WARN=2]=`WARN`,e[e.ERROR=3]=`ERROR`,e[e.SILENT=4]=`SILENT`,e}({}),d=()=>new Date,f=class{constructor(t={}){this.childMetadata={},this.config=t,this.level=t.level??u.INFO;let n=l(t);this.now=n.now??d,this.runtime=n.runtime??e().name,this.childMetadata={...t.metadata}}debug(e,t){this.log(u.DEBUG,e,t)}info(e,t){this.log(u.INFO,e,t)}warn(e,t){this.log(u.WARN,e,t)}error(e,t){this.log(u.ERROR,e,t)}log(e,t,n){if(!this.shouldLog(e))return;let r=typeof t==`function`?t():t,i={...this.childMetadata,...n},a={timestamp:this.now(),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){let t=this.createChild();return t.childMetadata={...this.childMetadata,...e},t}shouldLog(e){return e>=this.level}},p=100;function m(e,t,n,r){if(e===void 0)return`[undefined]`;if(typeof e==`bigint`)return`[BigInt: ${e.toString()}]`;if(typeof e==`symbol`)return`[Symbol: ${e.toString()}]`;if(typeof e==`function`)return`[Function: ${e.name||`anonymous`}]`;if(typeof e!=`object`||!e)return e;let i=e;if(t.has(i))return`[Circular]`;if(n>=r)return`[MaxDepth]`;t.add(i);try{if(i instanceof Error)return h(E(i),t,n,r);let e=i.toJSON;if(typeof e==`function`)return m(e.call(i),t,n,r);if(Array.isArray(i)){let e=[];for(let a=0;a<i.length;a++)e.push(m(i[a],t,n+1,r));return e}return h(i,t,n,r)}finally{t.delete(i)}}function h(e,t,n,r){let i={};for(let[a,o]of Object.entries(e))i[a]=m(o,t,n+1,r);return i}function g(e,t,n={}){let r=n.maxDepth??p;return JSON.stringify(m(e,new Set,0,r),null,t)}var _=[`password`,`token`,`secret`,`key`,`auth`,`authorization`,`apikey`,`authtoken`,`accesstoken`,`secretkey`],v=/[A-Z]+(?![a-z])|[A-Z]?[a-z]+|[0-9]+/g;function y(e){return(e.match(v)??[]).map(e=>e.toLowerCase())}function b(e){let t=[];for(let n of e){let e=y(n);if(e.length===0)continue;let r=e.join(``);t.push({tokens:e.map(e=>[e,`${e}s`]),joined:r,joinedPlural:`${r}s`})}return t}function x(e,t){let n=y(e);if(n.length===0)return!1;let r=n.join(``);return t.some(e=>e.tokens.every(([e,t])=>n.includes(e)||n.includes(t))||r===e.joined||r===e.joinedPlural)}function S(e,t){if(typeof e!=`object`||!e)return e;let n=Array.isArray(e)?[]:{};for(let[r,i]of Object.entries(e))n[r]=x(r,t)?`[REDACTED]`:typeof i==`object`&&i?S(i,t):i;return n}function C(e,t=_){return S(e,b(t))}var w=[`name`,`message`,`stack`];function T(e,t){let n=Object.getOwnPropertyDescriptor(e,t);if(n){if(n.get)try{return n.get.call(e)}catch{return`[Throws]`}return n.value}}function E(e){if(!(e instanceof Error))return e;let t={name:e.name,message:e.message};e.stack!==void 0&&(t.stack=e.stack);for(let n of Object.getOwnPropertyNames(e))w.includes(n)||(t[n]=T(e,n));return t}var D=class e extends f{constructor(e={}){super(e)}writeLog(e){let t=this.formatMessage(e),n=this.getConsoleStyle(e.level),r=`%c${t}${e.metadata?` ${g(e.metadata)}`:``}`;switch(e.level){case u.DEBUG:console.debug?console.debug(r,n):console.log(r,n);break;case u.INFO:console.info(r,n);break;case u.WARN:console.warn(r,n);break;case u.ERROR:console.error(r,n)}}createChild(){return new e(this.config)}formatMessage(e){return`[${e.timestamp.toISOString()}] ${u[e.level].toUpperCase()}: ${e.message}`}getConsoleStyle(e){if(!this.config.colorize)return``;switch(e){case u.DEBUG:return`color: #888; font-weight: normal;`;case u.INFO:return`color: #007acc; font-weight: normal;`;case u.WARN:return`color: #ff8c00; font-weight: bold;`;case u.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<=u.ERROR}shouldLog(e){return!this.shouldLogInProduction()&&e<u.ERROR?!1:super.shouldLog(e)}},O=class extends D{constructor(...e){super(...e),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,t){console.trace(e,t)}count(e){console.count(e)}countReset(e){console.countReset(e)}table(e){console.table(e)}},k=class extends D{mark(e){typeof performance<`u`&&performance.mark&&performance.mark(e)}measure(e,t,n){if(typeof performance<`u`&&performance.measure)try{performance.measure(e,t,n);let r=performance.getEntriesByName(e,`measure`);if(r.length>0){let t=r[r.length-1];this.info(`Performance: ${e}`,{duration:t.duration,startTime:t.startTime})}}catch(t){this.warn(`Failed to measure performance`,{name:e,error:t})}}clearMarks(e){typeof performance<`u`&&performance.clearMarks&&performance.clearMarks(e)}clearMeasures(e){typeof performance<`u`&&performance.clearMeasures&&performance.clearMeasures(e)}};function A(e,t=`text`,n={}){if(t===`json`){let t={timestamp:e.timestamp.toISOString(),level:u[e.level].toLowerCase(),message:e.message,runtime:e.runtime};return e.metadata!==void 0&&(t.metadata=e.metadata),g(t)}let r=n.timestamp===!1?``:`[${e.timestamp.toISOString()}] `,i=j(e.level,n.colorize===!0),a=e.metadata?` ${g(e.metadata)}`:``;return`${r}${i}: ${e.message}${a}`}function j(e,t=!1){let n=u[e].toUpperCase();if(!t)return n;let r={[u.DEBUG]:`\x1B[36m`,[u.INFO]:`\x1B[32m`,[u.WARN]:`\x1B[33m`,[u.ERROR]:`\x1B[31m`,[u.SILENT]:`\x1B[37m`};return`${r[e]||r[u.INFO]}${n}[0m`}var M=new Set;function N(e){M.has(e)||(M.add(e),console.warn(e))}function P(){M.clear()}function F(){return e().capabilities.colorSupport?typeof process>`u`||!process.env?!0:process.env.NO_COLOR?!1:process.env.FORCE_COLOR?process.env.FORCE_COLOR!==`0`:process.stdout?.isTTY===!0:!1}function I(){return{level:u.INFO,format:`text`,timestamp:!0,colorize:F(),metadata:{},transports:[{type:`console`,options:{}}]}}var L=[`true`,`1`,`yes`,`on`],R=[`false`,`0`,`no`,`off`];function z(){P()}function B(e){switch(e.trim().toLowerCase()){case`debug`:return u.DEBUG;case`info`:return u.INFO;case`warn`:case`warning`:return u.WARN;case`error`:return u.ERROR;case`silent`:case`none`:return u.SILENT;default:return}}function V(e,t){let n=t.trim().toLowerCase();if(L.includes(n))return!0;if(R.includes(n))return!1;N(`[logan-logger] ${e}="${t}" is not a recognized boolean and was ignored. Accepted: ${L.join(`, `)} / ${R.join(`, `)}.`)}function H(){let e={};if(typeof process>`u`||!process.env)return e;let t=process.env;if(t.LOG_LEVEL){let n=B(t.LOG_LEVEL);n===void 0?N(`[logan-logger] LOG_LEVEL="${t.LOG_LEVEL}" is not a recognized level and was ignored. Accepted: debug, info, warn, error, silent.`):e.level=n}if(t.LOG_FORMAT){let n=t.LOG_FORMAT.trim().toLowerCase();n===`json`||n===`text`?e.format=n:N(`[logan-logger] LOG_FORMAT="${t.LOG_FORMAT}" is not a recognized format and was ignored. Accepted: json, text.`)}if(t.LOG_TIMESTAMP){let n=V(`LOG_TIMESTAMP`,t.LOG_TIMESTAMP);n!==void 0&&(e.timestamp=n)}if(t.LOG_COLOR){let n=V(`LOG_COLOR`,t.LOG_COLOR);n!==void 0&&(e.colorize=n)}return e}function U(...e){let t=I();return e.reduce((e,t)=>({...e,...t,metadata:{...e.metadata,...t.metadata},transports:t.transports||e.transports}),t)}Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return a}});
|
|
@@ -72,24 +72,32 @@ function s() {
|
|
|
72
72
|
return t() === "bun";
|
|
73
73
|
}
|
|
74
74
|
//#endregion
|
|
75
|
+
//#region src/core/internal.ts
|
|
76
|
+
var c = Symbol.for("logan-logger.internals");
|
|
77
|
+
function l(e) {
|
|
78
|
+
return e[c] ?? {};
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
75
81
|
//#region src/core/types.ts
|
|
76
|
-
var
|
|
82
|
+
var u = /* @__PURE__ */ function(e) {
|
|
77
83
|
return e[e.DEBUG = 0] = "DEBUG", e[e.INFO = 1] = "INFO", e[e.WARN = 2] = "WARN", e[e.ERROR = 3] = "ERROR", e[e.SILENT = 4] = "SILENT", e;
|
|
78
|
-
}({}),
|
|
84
|
+
}({}), d = () => /* @__PURE__ */ new Date(), f = class {
|
|
79
85
|
constructor(t = {}) {
|
|
80
|
-
this.childMetadata = {}, this.config = t, this.level = t.level ??
|
|
86
|
+
this.childMetadata = {}, this.config = t, this.level = t.level ?? u.INFO;
|
|
87
|
+
let n = l(t);
|
|
88
|
+
this.now = n.now ?? d, this.runtime = n.runtime ?? e().name, this.childMetadata = { ...t.metadata };
|
|
81
89
|
}
|
|
82
90
|
debug(e, t) {
|
|
83
|
-
this.log(
|
|
91
|
+
this.log(u.DEBUG, e, t);
|
|
84
92
|
}
|
|
85
93
|
info(e, t) {
|
|
86
|
-
this.log(
|
|
94
|
+
this.log(u.INFO, e, t);
|
|
87
95
|
}
|
|
88
96
|
warn(e, t) {
|
|
89
|
-
this.log(
|
|
97
|
+
this.log(u.WARN, e, t);
|
|
90
98
|
}
|
|
91
99
|
error(e, t) {
|
|
92
|
-
this.log(
|
|
100
|
+
this.log(u.ERROR, e, t);
|
|
93
101
|
}
|
|
94
102
|
log(e, t, n) {
|
|
95
103
|
if (!this.shouldLog(e)) return;
|
|
@@ -97,7 +105,7 @@ var c = /* @__PURE__ */ function(e) {
|
|
|
97
105
|
...this.childMetadata,
|
|
98
106
|
...n
|
|
99
107
|
}, a = {
|
|
100
|
-
timestamp:
|
|
108
|
+
timestamp: this.now(),
|
|
101
109
|
level: e,
|
|
102
110
|
message: r,
|
|
103
111
|
metadata: Object.keys(i).length > 0 ? i : void 0,
|
|
@@ -121,8 +129,8 @@ var c = /* @__PURE__ */ function(e) {
|
|
|
121
129
|
shouldLog(e) {
|
|
122
130
|
return e >= this.level;
|
|
123
131
|
}
|
|
124
|
-
},
|
|
125
|
-
function
|
|
132
|
+
}, p = 100;
|
|
133
|
+
function m(e, t, n, r) {
|
|
126
134
|
if (e === void 0) return "[undefined]";
|
|
127
135
|
if (typeof e == "bigint") return `[BigInt: ${e.toString()}]`;
|
|
128
136
|
if (typeof e == "symbol") return `[Symbol: ${e.toString()}]`;
|
|
@@ -133,46 +141,78 @@ function d(e, t, n, r) {
|
|
|
133
141
|
if (n >= r) return "[MaxDepth]";
|
|
134
142
|
t.add(i);
|
|
135
143
|
try {
|
|
136
|
-
if (i instanceof Error) return
|
|
144
|
+
if (i instanceof Error) return h(E(i), t, n, r);
|
|
137
145
|
let e = i.toJSON;
|
|
138
|
-
if (typeof e == "function") return
|
|
146
|
+
if (typeof e == "function") return m(e.call(i), t, n, r);
|
|
139
147
|
if (Array.isArray(i)) {
|
|
140
148
|
let e = [];
|
|
141
|
-
for (let a = 0; a < i.length; a++) e.push(
|
|
149
|
+
for (let a = 0; a < i.length; a++) e.push(m(i[a], t, n + 1, r));
|
|
142
150
|
return e;
|
|
143
151
|
}
|
|
144
|
-
return
|
|
152
|
+
return h(i, t, n, r);
|
|
145
153
|
} finally {
|
|
146
154
|
t.delete(i);
|
|
147
155
|
}
|
|
148
156
|
}
|
|
149
|
-
function
|
|
157
|
+
function h(e, t, n, r) {
|
|
150
158
|
let i = {};
|
|
151
|
-
for (let [a, o] of Object.entries(e)) i[a] =
|
|
159
|
+
for (let [a, o] of Object.entries(e)) i[a] = m(o, t, n + 1, r);
|
|
152
160
|
return i;
|
|
153
161
|
}
|
|
154
|
-
function
|
|
155
|
-
let r = n.maxDepth ??
|
|
156
|
-
return JSON.stringify(
|
|
162
|
+
function g(e, t, n = {}) {
|
|
163
|
+
let r = n.maxDepth ?? p;
|
|
164
|
+
return JSON.stringify(m(e, /* @__PURE__ */ new Set(), 0, r), null, t);
|
|
157
165
|
}
|
|
158
|
-
|
|
166
|
+
var _ = [
|
|
159
167
|
"password",
|
|
160
168
|
"token",
|
|
161
169
|
"secret",
|
|
162
170
|
"key",
|
|
163
|
-
"auth"
|
|
164
|
-
|
|
171
|
+
"auth",
|
|
172
|
+
"authorization",
|
|
173
|
+
"apikey",
|
|
174
|
+
"authtoken",
|
|
175
|
+
"accesstoken",
|
|
176
|
+
"secretkey"
|
|
177
|
+
], v = /[A-Z]+(?![a-z])|[A-Z]?[a-z]+|[0-9]+/g;
|
|
178
|
+
function y(e) {
|
|
179
|
+
return (e.match(v) ?? []).map((e) => e.toLowerCase());
|
|
180
|
+
}
|
|
181
|
+
function b(e) {
|
|
182
|
+
let t = [];
|
|
183
|
+
for (let n of e) {
|
|
184
|
+
let e = y(n);
|
|
185
|
+
if (e.length === 0) continue;
|
|
186
|
+
let r = e.join("");
|
|
187
|
+
t.push({
|
|
188
|
+
tokens: e.map((e) => [e, `${e}s`]),
|
|
189
|
+
joined: r,
|
|
190
|
+
joinedPlural: `${r}s`
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
return t;
|
|
194
|
+
}
|
|
195
|
+
function x(e, t) {
|
|
196
|
+
let n = y(e);
|
|
197
|
+
if (n.length === 0) return !1;
|
|
198
|
+
let r = n.join("");
|
|
199
|
+
return t.some((e) => e.tokens.every(([e, t]) => n.includes(e) || n.includes(t)) || r === e.joined || r === e.joinedPlural);
|
|
200
|
+
}
|
|
201
|
+
function S(e, t) {
|
|
165
202
|
if (typeof e != "object" || !e) return e;
|
|
166
203
|
let n = Array.isArray(e) ? [] : {};
|
|
167
|
-
for (let [r, i] of Object.entries(e)) n[r] =
|
|
204
|
+
for (let [r, i] of Object.entries(e)) n[r] = x(r, t) ? "[REDACTED]" : typeof i == "object" && i ? S(i, t) : i;
|
|
168
205
|
return n;
|
|
169
206
|
}
|
|
170
|
-
|
|
207
|
+
function C(e, t = _) {
|
|
208
|
+
return S(e, b(t));
|
|
209
|
+
}
|
|
210
|
+
var w = [
|
|
171
211
|
"name",
|
|
172
212
|
"message",
|
|
173
213
|
"stack"
|
|
174
214
|
];
|
|
175
|
-
function
|
|
215
|
+
function T(e, t) {
|
|
176
216
|
let n = Object.getOwnPropertyDescriptor(e, t);
|
|
177
217
|
if (n) {
|
|
178
218
|
if (n.get) try {
|
|
@@ -183,60 +223,60 @@ function g(e, t) {
|
|
|
183
223
|
return n.value;
|
|
184
224
|
}
|
|
185
225
|
}
|
|
186
|
-
function
|
|
226
|
+
function E(e) {
|
|
187
227
|
if (!(e instanceof Error)) return e;
|
|
188
228
|
let t = {
|
|
189
229
|
name: e.name,
|
|
190
230
|
message: e.message
|
|
191
231
|
};
|
|
192
232
|
e.stack !== void 0 && (t.stack = e.stack);
|
|
193
|
-
for (let n of Object.getOwnPropertyNames(e))
|
|
233
|
+
for (let n of Object.getOwnPropertyNames(e)) w.includes(n) || (t[n] = T(e, n));
|
|
194
234
|
return t;
|
|
195
235
|
}
|
|
196
236
|
//#endregion
|
|
197
237
|
//#region src/runtime/browser.ts
|
|
198
|
-
var
|
|
238
|
+
var D = class e extends f {
|
|
199
239
|
constructor(e = {}) {
|
|
200
240
|
super(e);
|
|
201
241
|
}
|
|
202
242
|
writeLog(e) {
|
|
203
|
-
let t = this.formatMessage(e), n = this.getConsoleStyle(e.level), r = `%c${t}${e.metadata ? ` ${
|
|
243
|
+
let t = this.formatMessage(e), n = this.getConsoleStyle(e.level), r = `%c${t}${e.metadata ? ` ${g(e.metadata)}` : ""}`;
|
|
204
244
|
switch (e.level) {
|
|
205
|
-
case
|
|
245
|
+
case u.DEBUG:
|
|
206
246
|
console.debug ? console.debug(r, n) : console.log(r, n);
|
|
207
247
|
break;
|
|
208
|
-
case
|
|
248
|
+
case u.INFO:
|
|
209
249
|
console.info(r, n);
|
|
210
250
|
break;
|
|
211
|
-
case
|
|
251
|
+
case u.WARN:
|
|
212
252
|
console.warn(r, n);
|
|
213
253
|
break;
|
|
214
|
-
case
|
|
254
|
+
case u.ERROR: console.error(r, n);
|
|
215
255
|
}
|
|
216
256
|
}
|
|
217
257
|
createChild() {
|
|
218
258
|
return new e(this.config);
|
|
219
259
|
}
|
|
220
260
|
formatMessage(e) {
|
|
221
|
-
return `[${e.timestamp.toISOString()}] ${
|
|
261
|
+
return `[${e.timestamp.toISOString()}] ${u[e.level].toUpperCase()}: ${e.message}`;
|
|
222
262
|
}
|
|
223
263
|
getConsoleStyle(e) {
|
|
224
264
|
if (!this.config.colorize) return "";
|
|
225
265
|
switch (e) {
|
|
226
|
-
case
|
|
227
|
-
case
|
|
228
|
-
case
|
|
229
|
-
case
|
|
266
|
+
case u.DEBUG: return "color: #888; font-weight: normal;";
|
|
267
|
+
case u.INFO: return "color: #007acc; font-weight: normal;";
|
|
268
|
+
case u.WARN: return "color: #ff8c00; font-weight: bold;";
|
|
269
|
+
case u.ERROR: return "color: #dc3545; font-weight: bold;";
|
|
230
270
|
default: return "";
|
|
231
271
|
}
|
|
232
272
|
}
|
|
233
273
|
shouldLogInProduction() {
|
|
234
|
-
return (globalThis.process?.env?.NODE_ENV || globalThis.process?.env?.NEXT_PUBLIC_APP_ENV || "development") !== "production" || this.level <=
|
|
274
|
+
return (globalThis.process?.env?.NODE_ENV || globalThis.process?.env?.NEXT_PUBLIC_APP_ENV || "development") !== "production" || this.level <= u.ERROR;
|
|
235
275
|
}
|
|
236
276
|
shouldLog(e) {
|
|
237
|
-
return !this.shouldLogInProduction() && e <
|
|
277
|
+
return !this.shouldLogInProduction() && e < u.ERROR ? !1 : super.shouldLog(e);
|
|
238
278
|
}
|
|
239
|
-
},
|
|
279
|
+
}, O = class extends D {
|
|
240
280
|
constructor(...e) {
|
|
241
281
|
super(...e), this.groupStack = [];
|
|
242
282
|
}
|
|
@@ -273,7 +313,7 @@ var v = class e extends l {
|
|
|
273
313
|
table(e) {
|
|
274
314
|
console.table(e);
|
|
275
315
|
}
|
|
276
|
-
},
|
|
316
|
+
}, k = class extends D {
|
|
277
317
|
mark(e) {
|
|
278
318
|
typeof performance < "u" && performance.mark && performance.mark(e);
|
|
279
319
|
}
|
|
@@ -304,51 +344,51 @@ var v = class e extends l {
|
|
|
304
344
|
};
|
|
305
345
|
//#endregion
|
|
306
346
|
//#region src/utils/formatting.ts
|
|
307
|
-
function
|
|
347
|
+
function A(e, t = "text", n = {}) {
|
|
308
348
|
if (t === "json") {
|
|
309
349
|
let t = {
|
|
310
350
|
timestamp: e.timestamp.toISOString(),
|
|
311
|
-
level:
|
|
351
|
+
level: u[e.level].toLowerCase(),
|
|
312
352
|
message: e.message,
|
|
313
353
|
runtime: e.runtime
|
|
314
354
|
};
|
|
315
|
-
return e.metadata !== void 0 && (t.metadata = e.metadata),
|
|
355
|
+
return e.metadata !== void 0 && (t.metadata = e.metadata), g(t);
|
|
316
356
|
}
|
|
317
|
-
let r = n.timestamp === !1 ? "" : `[${e.timestamp.toISOString()}] `, i =
|
|
357
|
+
let r = n.timestamp === !1 ? "" : `[${e.timestamp.toISOString()}] `, i = j(e.level, n.colorize === !0), a = e.metadata ? ` ${g(e.metadata)}` : "";
|
|
318
358
|
return `${r}${i}: ${e.message}${a}`;
|
|
319
359
|
}
|
|
320
|
-
function
|
|
321
|
-
let n =
|
|
360
|
+
function j(e, t = !1) {
|
|
361
|
+
let n = u[e].toUpperCase();
|
|
322
362
|
if (!t) return n;
|
|
323
363
|
let r = {
|
|
324
|
-
[
|
|
325
|
-
[
|
|
326
|
-
[
|
|
327
|
-
[
|
|
328
|
-
[
|
|
364
|
+
[u.DEBUG]: "\x1B[36m",
|
|
365
|
+
[u.INFO]: "\x1B[32m",
|
|
366
|
+
[u.WARN]: "\x1B[33m",
|
|
367
|
+
[u.ERROR]: "\x1B[31m",
|
|
368
|
+
[u.SILENT]: "\x1B[37m"
|
|
329
369
|
};
|
|
330
|
-
return `${r[e] || r[
|
|
370
|
+
return `${r[e] || r[u.INFO]}${n}[0m`;
|
|
331
371
|
}
|
|
332
372
|
//#endregion
|
|
333
373
|
//#region src/utils/warn-once.ts
|
|
334
|
-
var
|
|
335
|
-
function
|
|
336
|
-
|
|
374
|
+
var M = /* @__PURE__ */ new Set();
|
|
375
|
+
function N(e) {
|
|
376
|
+
M.has(e) || (M.add(e), console.warn(e));
|
|
337
377
|
}
|
|
338
|
-
function
|
|
339
|
-
|
|
378
|
+
function P() {
|
|
379
|
+
M.clear();
|
|
340
380
|
}
|
|
341
381
|
//#endregion
|
|
342
382
|
//#region src/utils/config.ts
|
|
343
|
-
function
|
|
383
|
+
function F() {
|
|
344
384
|
return e().capabilities.colorSupport ? typeof process > "u" || !process.env ? !0 : process.env.NO_COLOR ? !1 : process.env.FORCE_COLOR ? process.env.FORCE_COLOR !== "0" : process.stdout?.isTTY === !0 : !1;
|
|
345
385
|
}
|
|
346
|
-
function
|
|
386
|
+
function I() {
|
|
347
387
|
return {
|
|
348
|
-
level:
|
|
388
|
+
level: u.INFO,
|
|
349
389
|
format: "text",
|
|
350
390
|
timestamp: !0,
|
|
351
|
-
colorize:
|
|
391
|
+
colorize: F(),
|
|
352
392
|
metadata: {},
|
|
353
393
|
transports: [{
|
|
354
394
|
type: "console",
|
|
@@ -356,62 +396,62 @@ function D() {
|
|
|
356
396
|
}]
|
|
357
397
|
};
|
|
358
398
|
}
|
|
359
|
-
var
|
|
399
|
+
var L = [
|
|
360
400
|
"true",
|
|
361
401
|
"1",
|
|
362
402
|
"yes",
|
|
363
403
|
"on"
|
|
364
|
-
],
|
|
404
|
+
], R = [
|
|
365
405
|
"false",
|
|
366
406
|
"0",
|
|
367
407
|
"no",
|
|
368
408
|
"off"
|
|
369
409
|
];
|
|
370
|
-
function
|
|
371
|
-
|
|
410
|
+
function z() {
|
|
411
|
+
P();
|
|
372
412
|
}
|
|
373
|
-
function
|
|
413
|
+
function B(e) {
|
|
374
414
|
switch (e.trim().toLowerCase()) {
|
|
375
|
-
case "debug": return
|
|
376
|
-
case "info": return
|
|
415
|
+
case "debug": return u.DEBUG;
|
|
416
|
+
case "info": return u.INFO;
|
|
377
417
|
case "warn":
|
|
378
|
-
case "warning": return
|
|
379
|
-
case "error": return
|
|
418
|
+
case "warning": return u.WARN;
|
|
419
|
+
case "error": return u.ERROR;
|
|
380
420
|
case "silent":
|
|
381
|
-
case "none": return
|
|
421
|
+
case "none": return u.SILENT;
|
|
382
422
|
default: return;
|
|
383
423
|
}
|
|
384
424
|
}
|
|
385
|
-
function
|
|
425
|
+
function V(e, t) {
|
|
386
426
|
let n = t.trim().toLowerCase();
|
|
387
|
-
if (
|
|
388
|
-
if (
|
|
389
|
-
|
|
427
|
+
if (L.includes(n)) return !0;
|
|
428
|
+
if (R.includes(n)) return !1;
|
|
429
|
+
N(`[logan-logger] ${e}="${t}" is not a recognized boolean and was ignored. Accepted: ${L.join(", ")} / ${R.join(", ")}.`);
|
|
390
430
|
}
|
|
391
|
-
function
|
|
431
|
+
function H() {
|
|
392
432
|
let e = {};
|
|
393
433
|
if (typeof process > "u" || !process.env) return e;
|
|
394
434
|
let t = process.env;
|
|
395
435
|
if (t.LOG_LEVEL) {
|
|
396
|
-
let n =
|
|
397
|
-
n === void 0 ?
|
|
436
|
+
let n = B(t.LOG_LEVEL);
|
|
437
|
+
n === void 0 ? N(`[logan-logger] LOG_LEVEL="${t.LOG_LEVEL}" is not a recognized level and was ignored. Accepted: debug, info, warn, error, silent.`) : e.level = n;
|
|
398
438
|
}
|
|
399
439
|
if (t.LOG_FORMAT) {
|
|
400
440
|
let n = t.LOG_FORMAT.trim().toLowerCase();
|
|
401
|
-
n === "json" || n === "text" ? e.format = n :
|
|
441
|
+
n === "json" || n === "text" ? e.format = n : N(`[logan-logger] LOG_FORMAT="${t.LOG_FORMAT}" is not a recognized format and was ignored. Accepted: json, text.`);
|
|
402
442
|
}
|
|
403
443
|
if (t.LOG_TIMESTAMP) {
|
|
404
|
-
let n =
|
|
444
|
+
let n = V("LOG_TIMESTAMP", t.LOG_TIMESTAMP);
|
|
405
445
|
n !== void 0 && (e.timestamp = n);
|
|
406
446
|
}
|
|
407
447
|
if (t.LOG_COLOR) {
|
|
408
|
-
let n =
|
|
448
|
+
let n = V("LOG_COLOR", t.LOG_COLOR);
|
|
409
449
|
n !== void 0 && (e.colorize = n);
|
|
410
450
|
}
|
|
411
451
|
return e;
|
|
412
452
|
}
|
|
413
|
-
function
|
|
414
|
-
let t =
|
|
453
|
+
function U(...e) {
|
|
454
|
+
let t = I();
|
|
415
455
|
return e.reduce((e, t) => ({
|
|
416
456
|
...e,
|
|
417
457
|
...t,
|
|
@@ -423,4 +463,4 @@ function P(...e) {
|
|
|
423
463
|
}), t);
|
|
424
464
|
}
|
|
425
465
|
//#endregion
|
|
426
|
-
export { i as S,
|
|
466
|
+
export { i as S, u as _, F as a, s as b, j as c, O as d, k as f, f as g, E as h, z as i, A as l, g as m, H as n, B as o, C as p, U as r, N as s, I as t, D as u, e as v, o as x, a as y };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./config-
|
|
1
|
+
const e=require("./config-BIFVBkeG.cjs");var t=new Map;function n(e,n){t.set(e,n)}function r(e){return t.get(e)}var i=class{constructor(e={}){this.type=`console`,this.level=e.level,this.format=e.format===`json`?`json`:`text`,this.formatOptions={timestamp:e.timestamp!==!1,colorize:e.colorize===!0}}write(t){let n=e.l(t,this.format,this.formatOptions);switch(t.level){case e._.DEBUG:console.debug(n);break;case e._.WARN:console.warn(n);break;case e._.ERROR:console.error(n);break;default:console.info(n)}}};n(`console`,(e,t)=>{let n=e.options??{};return new i({format:n.format??t.format,timestamp:n.timestamp??t.timestamp,colorize:n.colorize??t.colorize,level:e.level})}),n(`custom`,e=>{let t=e.options?.transport;if(!t||typeof t.write!=`function`)throw Error(`custom transport requires options.transport to be an object with a write(entry) method`);return e.level===void 0?t:{type:t.type??`custom`,level:e.level,write:e=>t.write(e),close:t.close?()=>t.close?.():void 0}});function a(e){let t={format:e.format??`text`,timestamp:e.timestamp??!0,colorize:e.colorize??!1};if(e.transports===void 0)return[new i({format:t.format,timestamp:t.timestamp,colorize:t.colorize})];let n=[];for(let i of e.transports){let e=r(i.type);if(!e){console.warn(`[logan-logger] ${o(i.type)}`);continue}try{n.push(e(i,t))}catch(e){console.warn(`[logan-logger] transport '${i.type}' failed to initialize:`,e)}}return n}function o(e){return e===`file`?`the 'file' transport is not registered; import from 'logan-logger/node' (or 'logan-logger/bun') rather than the main entry point to use file logging`:e===`http`?`the 'http' transport is not built in; supply one with { type: 'custom', options: { transport } }`:`unknown transport type '${e}'; skipping`}var s=class t extends e.g{constructor(e={},t){super(e),this.transports=t??a(e)}getTransports(){return this.transports}close(){for(let e of this.transports)e.close?.()}writeLog(e){for(let t of this.transports)if(!(t.level!==void 0&&e.level<t.level))try{t.write(e)}catch(e){console.warn(`[logan-logger] transport '${t.type}' failed to write:`,e)}}createChild(){return new t(this.config,this.transports)}};function c(e){return{write:t=>{e.info(t.trim())}}}var l=class t{static create(n={}){let r=e.v(),i=t.mergeConfig(n);switch(r.name){case`node`:return new s(i);case`deno`:return new e.u(i);case`bun`:return new s(i);case`browser`:case`webworker`:return new e.u(i);default:return new e.u(i)}}static createChild(e,t){return e.child(t)}static mergeConfig(t){let n=t.ignoreEnvironment?{}:e.n();return e.r(t,n)}};function u(e){return l.create(e)}function d(){let t=f();return u({level:p(t),colorize:t!==`production`&&e.a(),timestamp:!0,format:t===`production`?`json`:`text`})}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 p(t){switch(t){case`production`:return e._.ERROR;case`staging`:case`test`:return e._.WARN;case`development`:case`dev`:return e._.DEBUG;default:return e._.INFO}}function m(t){return e.o(t)??e._.INFO}function h(t){switch(t){case e._.DEBUG:return`debug`;case e._.INFO:return`info`;case e._.WARN:return`warn`;case e._.ERROR:return`error`;case e._.SILENT:return`silent`;default:return`info`}}var g=[{path:`logan.config.json`},{path:`.loganrc`},{path:`package.json`,key:`logan`}],_=new Set([`level`,`format`,`timestamp`,`colorize`,`ignoreEnvironment`,`metadata`,`transports`,`$schema`]),v=new Set([`EACCES`,`EPERM`,`NotCapable`,`PermissionDenied`]);function y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function b(e){return e instanceof Error?e.message:String(e)}function x(e){let t=/at position \d+(?: \(line \d+ column \d+\))?/.exec(b(e));return t?`not valid JSON (${t[0]})`:`not valid JSON`}function S(e){return e.startsWith(`/`)||e.startsWith(`\\`)||/^[A-Za-z]:/.test(e)}function C(e,t){return t===void 0||t===``||S(e)?e:`${t.replace(/[\\/]+$/,``)}/${e}`}async function w(e,t){if(e===`deno`)return e=>C(e,t);let{resolve:n}=await import(`node:path`);return t===void 0?e=>n(e):e=>n(t,e)}function T(e){let t=e.split(/[\\/]/);return t[t.length-1]||e}function E(e){if(e===`deno`)try{return globalThis.Deno?.cwd?.()}catch{return}return typeof process<`u`&&typeof process.cwd==`function`?process.cwd():void 0}function D(e){let t=e?.code??``,n=e?.name??``;return t===`ENOENT`||n===`NotFound`?{kind:`absent`}:v.has(t)||v.has(n)?{kind:`denied`,reason:b(e)}:{kind:`unreadable`,reason:b(e)}}async function O(e,t){let n=t===`deno`?()=>globalThis.Deno.readTextFile(e):async()=>(await import(`node:fs/promises`)).readFile(e,`utf-8`);try{return{kind:`content`,content:await n()}}catch(e){return D(e)}}function k(t){if(typeof t==`string`)return e.o(t);if(typeof t==`number`&&e._[t]!==void 0)return t}function A(t,n,r){let i=t=>{e.s(`[logan-logger] ${r}: ignoring transports[${n}]: ${t}.`)};if(!y(t)){i(`expected an object, got ${JSON.stringify(t)??typeof t}`);return}if(typeof t.type!=`string`){i(`"type" is required and must be a string`);return}if(t.options!==void 0&&!y(t.options)){i(`"options" must be an object`);return}let a={type:t.type,options:t.options??{}};if(t.level!==void 0){let i=k(t.level);i===void 0?e.s(`[logan-logger] ${r}: ignoring transports[${n}].level=${JSON.stringify(t.level)}. Accepted: debug, info, warn, error, silent.`):a.level=i}return a}function j(t,n){let r={},i=(t,r,i)=>{e.s(`[logan-logger] ${n}: ignoring ${t}=${JSON.stringify(r)}. Accepted: ${i}.`)};for(let r of Object.keys(t))_.has(r)||e.s(`[logan-logger] ${n}: ignoring unknown field "${r}". Known fields: level, format, timestamp, colorize, ignoreEnvironment, metadata, transports.`);if(t.level!==void 0){let e=k(t.level);e===void 0?i(`level`,t.level,`debug, info, warn, error, silent`):r.level=e}t.format!==void 0&&(t.format===`json`||t.format===`text`||t.format===`custom`?r.format=t.format:i(`format`,t.format,`json, text, custom`));for(let e of[`timestamp`,`colorize`,`ignoreEnvironment`])t[e]!==void 0&&(typeof t[e]==`boolean`?r[e]=t[e]:i(e,t[e],`true, false`));if(t.metadata!==void 0&&(y(t.metadata)?r.metadata=t.metadata:i(`metadata`,t.metadata,`an object`)),Array.isArray(t.transports)){let e=t.transports.map((e,t)=>A(e,t,n)).filter(e=>e!==void 0);(e.length>0||t.transports.length===0)&&(r.transports=e)}else t.transports!==void 0&&i(`transports`,t.transports,`an array of transport configs`);return r}async function M(e,t){let n=await O(e.path,t);if(n.kind===`absent`)return n;if(n.kind!==`content`)return{kind:n.kind,path:e.path,reason:n.reason};let r;try{r=JSON.parse(n.content)}catch(t){return{kind:`invalid`,path:e.path,reason:x(t)}}let i=r;if(e.key){if(!y(r))return{kind:`invalid`,path:e.path,reason:`expected a JSON object`};if(!Object.hasOwn(r,e.key))return{kind:`keyless`,path:e.path,key:e.key};i=r[e.key]}if(!y(i)){let t=e.key?`the "${e.key}" key`:`the file`;return{kind:`invalid`,path:e.path,reason:`expected ${t} to be an object`}}return{kind:`found`,config:j(i,e.path)}}function N(e){let t=g.find(t=>t.path===T(e));return t?{...t,path:e}:{path:e}}function P(t,n){e.s(`[logan-logger] cannot read config at ${t} — no permission; using defaults instead: ${n}`)}async function F(t,n={}){let r=e.v();if(!r.capabilities.fileSystem)return{};let i=n.cwd||E(r.name),a=await w(r.name,i);if(t!==void 0){let e=a(t),n=await M(N(e),r.name);if(n.kind===`found`)return n.config;if(n.kind===`absent`)throw Error(`[logan-logger] config file not found: ${e}`);if(n.kind===`keyless`)throw Error(`[logan-logger] no "${n.key}" key in ${n.path}`);if(n.kind===`denied`)return P(n.path,n.reason),{};throw n.kind===`unreadable`?Error(`[logan-logger] config at ${n.path} is not a readable file: ${n.reason}`):Error(`[logan-logger] config at ${n.path} is invalid: ${n.reason}`)}for(let t of g){let n=await M({...t,path:a(t.path)},r.name);if(n.kind===`found`)return n.config;if(n.kind===`invalid`)return e.s(`[logan-logger] config at ${n.path} is invalid: ${n.reason}`),{};if(n.kind===`denied`)return P(n.path,n.reason),{};n.kind===`unreadable`&&e.s(`[logan-logger] skipping ${n.path}: not a readable file (${n.reason})`)}return{}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return a}});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as e, a as t, g as n, l as r, n as i, o as a, r as o, s, u as c, v as l } from "./config-
|
|
1
|
+
import { _ as e, a as t, g as n, l as r, n as i, o as a, r as o, s, u as c, v as l } from "./config-C0Vj3nIk.mjs";
|
|
2
2
|
//#region src/core/transport.ts
|
|
3
3
|
var u = /* @__PURE__ */ new Map();
|
|
4
4
|
function d(e, t) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as e } from "./config-
|
|
2
|
-
import { f as t } from "./config-file-
|
|
1
|
+
import { l as e } from "./config-C0Vj3nIk.mjs";
|
|
2
|
+
import { f as t } from "./config-file-CmxNUX1Z.mjs";
|
|
3
3
|
import { closeSync as n, existsSync as r, fstatSync as i, mkdirSync as a, openSync as o, renameSync as s, unlinkSync as c, writeSync as l } from "node:fs";
|
|
4
4
|
import { dirname as u, resolve as d } from "node:path";
|
|
5
5
|
//#region src/runtime/file-transport.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./config-
|
|
1
|
+
const e=require("./config-BIFVBkeG.cjs"),t=require("./config-file-BNPm7ZNS.cjs");let n=require("node:fs"),r=require("node:path");var i=5242880,a=5,o=class{constructor(e){if(this.type=`file`,this.size=0,this.warned=!1,!e?.filename)throw Error(`file transport requires options.filename`);this.path=(0,r.resolve)(e.filename),this.maxsize=e.maxsize??i,this.maxFiles=e.maxFiles??a,this.format=e.format===`text`?`text`:`json`,this.timestamp=e.timestamp!==!1,this.level=e.level}get filename(){return this.path}write(t){let r=`${e.l(t,this.format,{timestamp:this.timestamp,colorize:!1})}\n`;try{this.open(),this.maxsize>0&&this.size>=this.maxsize&&(this.rotate(),this.open()),this.size+=(0,n.writeSync)(this.fd,r)}catch(e){this.warnOnce(e)}}close(){if(this.fd!==void 0)try{(0,n.closeSync)(this.fd)}finally{this.fd=void 0}}open(){if(this.fd!==void 0)return;let e=(0,r.dirname)(this.path);try{(0,n.mkdirSync)(e,{recursive:!0})}catch(t){throw s(`create log directory`,e,t)}try{this.fd=(0,n.openSync)(this.path,`a`)}catch(e){throw s(`open log file`,this.path,e)}this.size=(0,n.fstatSync)(this.fd).size}rotate(){if(this.close(),this.maxFiles<=0){(0,n.existsSync)(this.path)&&(0,n.unlinkSync)(this.path),this.size=0;return}let e=`${this.path}.${this.maxFiles}`;(0,n.existsSync)(e)&&(0,n.unlinkSync)(e);for(let e=this.maxFiles-1;e>=1;e--){let t=`${this.path}.${e}`;(0,n.existsSync)(t)&&(0,n.renameSync)(t,`${this.path}.${e+1}`)}(0,n.existsSync)(this.path)&&(0,n.renameSync)(this.path,`${this.path}.1`),this.size=0}warnOnce(e){this.close(),!this.warned&&(this.warned=!0,console.warn(`[logan-logger] file transport for '${this.path}' failed and will keep retrying quietly:`,e instanceof Error?e.message:e))}};function s(e,t,n){let r=n,i=r?.code?` [${r.code}]`:``,a=r?.syscall?` during ${r.syscall}`:``,o=Error(`could not ${e} '${t}'${i}${a}: ${r?.message??n}`);return o.cause=n,o}t.f(`file`,(e,t)=>{let n=e.options??{};return new o({filename:n.filename,maxsize:n.maxsize,maxFiles:n.maxFiles,format:n.format,timestamp:n.timestamp??t.timestamp,level:e.level})}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { LoggerConfig, RuntimeName } from './types.cjs';
|
|
2
|
+
/**
|
|
3
|
+
* Key under which a caller may freeze the two values a record takes from its
|
|
4
|
+
* surroundings rather than from its caller: the wall clock and the detected
|
|
5
|
+
* runtime.
|
|
6
|
+
*
|
|
7
|
+
* This is a **test seam**, not configuration. It rides on the config object
|
|
8
|
+
* under a symbol instead of becoming a named `LoggerConfig` field because a
|
|
9
|
+
* named field would be public API — permanently documented, permanently
|
|
10
|
+
* supported — for something whose only caller is a conformance harness. The
|
|
11
|
+
* treering fixtures supply a frozen `timestamp` and `runtime` on every case
|
|
12
|
+
* that emits a record, and `fixtures/README.md` requires the runner to inject
|
|
13
|
+
* them rather than let the implementation read a real clock.
|
|
14
|
+
*
|
|
15
|
+
* Carrying it on the config also makes inheritance free: `BaseLogger.child()`
|
|
16
|
+
* hands `this.config` to the child it builds, so every descendant sees the same
|
|
17
|
+
* frozen values. A constructor argument or a protected member would each need
|
|
18
|
+
* `child()` to be taught about them separately.
|
|
19
|
+
*
|
|
20
|
+
* `Symbol.for` rather than `Symbol()`: a test runner that isolates module
|
|
21
|
+
* graphs can end up holding two instances of this file, and a per-instance
|
|
22
|
+
* symbol would not match across them.
|
|
23
|
+
*/
|
|
24
|
+
export declare const LOGGER_INTERNALS: unique symbol;
|
|
25
|
+
/** Environment-derived values a caller may pin. */
|
|
26
|
+
export interface LoggerInternals {
|
|
27
|
+
/** Supplies the record timestamp. Defaults to the real clock. */
|
|
28
|
+
now?: () => Date;
|
|
29
|
+
/** Stands in for `detectRuntime().name` on the `runtime` field. */
|
|
30
|
+
runtime?: RuntimeName;
|
|
31
|
+
}
|
|
32
|
+
type ConfigWithInternals = Partial<LoggerConfig> & {
|
|
33
|
+
[LOGGER_INTERNALS]?: LoggerInternals;
|
|
34
|
+
};
|
|
35
|
+
/** Read whatever internals a config carries; an empty object when it carries none. */
|
|
36
|
+
export declare function readLoggerInternals(config: Partial<LoggerConfig>): LoggerInternals;
|
|
37
|
+
/**
|
|
38
|
+
* Attach internals to a copy of `config`.
|
|
39
|
+
*
|
|
40
|
+
* The property is enumerable, which is what lets `mergeConfigs` carry it
|
|
41
|
+
* through: object spread copies own enumerable symbol-keyed properties.
|
|
42
|
+
* @param config - Configuration to copy
|
|
43
|
+
* @param internals - Values to pin
|
|
44
|
+
* @returns A new config object carrying the internals
|
|
45
|
+
*/
|
|
46
|
+
export declare function withLoggerInternals<T extends Partial<LoggerConfig>>(config: T, internals: LoggerInternals): T & ConfigWithInternals;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { LoggerConfig, RuntimeName } from './types.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Key under which a caller may freeze the two values a record takes from its
|
|
4
|
+
* surroundings rather than from its caller: the wall clock and the detected
|
|
5
|
+
* runtime.
|
|
6
|
+
*
|
|
7
|
+
* This is a **test seam**, not configuration. It rides on the config object
|
|
8
|
+
* under a symbol instead of becoming a named `LoggerConfig` field because a
|
|
9
|
+
* named field would be public API — permanently documented, permanently
|
|
10
|
+
* supported — for something whose only caller is a conformance harness. The
|
|
11
|
+
* treering fixtures supply a frozen `timestamp` and `runtime` on every case
|
|
12
|
+
* that emits a record, and `fixtures/README.md` requires the runner to inject
|
|
13
|
+
* them rather than let the implementation read a real clock.
|
|
14
|
+
*
|
|
15
|
+
* Carrying it on the config also makes inheritance free: `BaseLogger.child()`
|
|
16
|
+
* hands `this.config` to the child it builds, so every descendant sees the same
|
|
17
|
+
* frozen values. A constructor argument or a protected member would each need
|
|
18
|
+
* `child()` to be taught about them separately.
|
|
19
|
+
*
|
|
20
|
+
* `Symbol.for` rather than `Symbol()`: a test runner that isolates module
|
|
21
|
+
* graphs can end up holding two instances of this file, and a per-instance
|
|
22
|
+
* symbol would not match across them.
|
|
23
|
+
*/
|
|
24
|
+
export declare const LOGGER_INTERNALS: unique symbol;
|
|
25
|
+
/** Environment-derived values a caller may pin. */
|
|
26
|
+
export interface LoggerInternals {
|
|
27
|
+
/** Supplies the record timestamp. Defaults to the real clock. */
|
|
28
|
+
now?: () => Date;
|
|
29
|
+
/** Stands in for `detectRuntime().name` on the `runtime` field. */
|
|
30
|
+
runtime?: RuntimeName;
|
|
31
|
+
}
|
|
32
|
+
type ConfigWithInternals = Partial<LoggerConfig> & {
|
|
33
|
+
[LOGGER_INTERNALS]?: LoggerInternals;
|
|
34
|
+
};
|
|
35
|
+
/** Read whatever internals a config carries; an empty object when it carries none. */
|
|
36
|
+
export declare function readLoggerInternals(config: Partial<LoggerConfig>): LoggerInternals;
|
|
37
|
+
/**
|
|
38
|
+
* Attach internals to a copy of `config`.
|
|
39
|
+
*
|
|
40
|
+
* The property is enumerable, which is what lets `mergeConfigs` carry it
|
|
41
|
+
* through: object spread copies own enumerable symbol-keyed properties.
|
|
42
|
+
* @param config - Configuration to copy
|
|
43
|
+
* @param internals - Values to pin
|
|
44
|
+
* @returns A new config object carrying the internals
|
|
45
|
+
*/
|
|
46
|
+
export declare function withLoggerInternals<T extends Partial<LoggerConfig>>(config: T, internals: LoggerInternals): T & ConfigWithInternals;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { LoggerConfig, RuntimeName } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Key under which a caller may freeze the two values a record takes from its
|
|
4
|
+
* surroundings rather than from its caller: the wall clock and the detected
|
|
5
|
+
* runtime.
|
|
6
|
+
*
|
|
7
|
+
* This is a **test seam**, not configuration. It rides on the config object
|
|
8
|
+
* under a symbol instead of becoming a named `LoggerConfig` field because a
|
|
9
|
+
* named field would be public API — permanently documented, permanently
|
|
10
|
+
* supported — for something whose only caller is a conformance harness. The
|
|
11
|
+
* treering fixtures supply a frozen `timestamp` and `runtime` on every case
|
|
12
|
+
* that emits a record, and `fixtures/README.md` requires the runner to inject
|
|
13
|
+
* them rather than let the implementation read a real clock.
|
|
14
|
+
*
|
|
15
|
+
* Carrying it on the config also makes inheritance free: `BaseLogger.child()`
|
|
16
|
+
* hands `this.config` to the child it builds, so every descendant sees the same
|
|
17
|
+
* frozen values. A constructor argument or a protected member would each need
|
|
18
|
+
* `child()` to be taught about them separately.
|
|
19
|
+
*
|
|
20
|
+
* `Symbol.for` rather than `Symbol()`: a test runner that isolates module
|
|
21
|
+
* graphs can end up holding two instances of this file, and a per-instance
|
|
22
|
+
* symbol would not match across them.
|
|
23
|
+
*/
|
|
24
|
+
export declare const LOGGER_INTERNALS: unique symbol;
|
|
25
|
+
/** Environment-derived values a caller may pin. */
|
|
26
|
+
export interface LoggerInternals {
|
|
27
|
+
/** Supplies the record timestamp. Defaults to the real clock. */
|
|
28
|
+
now?: () => Date;
|
|
29
|
+
/** Stands in for `detectRuntime().name` on the `runtime` field. */
|
|
30
|
+
runtime?: RuntimeName;
|
|
31
|
+
}
|
|
32
|
+
type ConfigWithInternals = Partial<LoggerConfig> & {
|
|
33
|
+
[LOGGER_INTERNALS]?: LoggerInternals;
|
|
34
|
+
};
|
|
35
|
+
/** Read whatever internals a config carries; an empty object when it carries none. */
|
|
36
|
+
export declare function readLoggerInternals(config: Partial<LoggerConfig>): LoggerInternals;
|
|
37
|
+
/**
|
|
38
|
+
* Attach internals to a copy of `config`.
|
|
39
|
+
*
|
|
40
|
+
* The property is enumerable, which is what lets `mergeConfigs` carry it
|
|
41
|
+
* through: object spread copies own enumerable symbol-keyed properties.
|
|
42
|
+
* @param config - Configuration to copy
|
|
43
|
+
* @param internals - Values to pin
|
|
44
|
+
* @returns A new config object carrying the internals
|
|
45
|
+
*/
|
|
46
|
+
export declare function withLoggerInternals<T extends Partial<LoggerConfig>>(config: T, internals: LoggerInternals): T & ConfigWithInternals;
|
|
47
|
+
export {};
|
package/dist/core/logger.d.cts
CHANGED
|
@@ -3,6 +3,14 @@ export declare abstract class BaseLogger implements ILogger {
|
|
|
3
3
|
protected level: LogLevel;
|
|
4
4
|
protected config: Partial<LoggerConfig>;
|
|
5
5
|
protected runtime: RuntimeName;
|
|
6
|
+
/**
|
|
7
|
+
* Source of the `timestamp` on every record.
|
|
8
|
+
*
|
|
9
|
+
* A seam rather than a direct `new Date()` so conformance fixtures can pin it
|
|
10
|
+
* and compare output byte for byte. See `core/internal.ts` for why it is not
|
|
11
|
+
* a public config field.
|
|
12
|
+
*/
|
|
13
|
+
protected readonly now: () => Date;
|
|
6
14
|
protected childMetadata: Record<string, any>;
|
|
7
15
|
protected constructor(config?: Partial<LoggerConfig>);
|
|
8
16
|
debug(message: LogMessage, metadata?: any): void;
|
package/dist/core/logger.d.mts
CHANGED
|
@@ -3,6 +3,14 @@ export declare abstract class BaseLogger implements ILogger {
|
|
|
3
3
|
protected level: LogLevel;
|
|
4
4
|
protected config: Partial<LoggerConfig>;
|
|
5
5
|
protected runtime: RuntimeName;
|
|
6
|
+
/**
|
|
7
|
+
* Source of the `timestamp` on every record.
|
|
8
|
+
*
|
|
9
|
+
* A seam rather than a direct `new Date()` so conformance fixtures can pin it
|
|
10
|
+
* and compare output byte for byte. See `core/internal.ts` for why it is not
|
|
11
|
+
* a public config field.
|
|
12
|
+
*/
|
|
13
|
+
protected readonly now: () => Date;
|
|
6
14
|
protected childMetadata: Record<string, any>;
|
|
7
15
|
protected constructor(config?: Partial<LoggerConfig>);
|
|
8
16
|
debug(message: LogMessage, metadata?: any): void;
|
package/dist/core/logger.d.ts
CHANGED
|
@@ -3,6 +3,14 @@ export declare abstract class BaseLogger implements ILogger {
|
|
|
3
3
|
protected level: LogLevel;
|
|
4
4
|
protected config: Partial<LoggerConfig>;
|
|
5
5
|
protected runtime: RuntimeName;
|
|
6
|
+
/**
|
|
7
|
+
* Source of the `timestamp` on every record.
|
|
8
|
+
*
|
|
9
|
+
* A seam rather than a direct `new Date()` so conformance fixtures can pin it
|
|
10
|
+
* and compare output byte for byte. See `core/internal.ts` for why it is not
|
|
11
|
+
* a public config field.
|
|
12
|
+
*/
|
|
13
|
+
protected readonly now: () => Date;
|
|
6
14
|
protected childMetadata: Record<string, any>;
|
|
7
15
|
protected constructor(config?: Partial<LoggerConfig>);
|
|
8
16
|
debug(message: LogMessage, metadata?: any): void;
|
package/dist/deno.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./chunks/config-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./chunks/config-BIFVBkeG.cjs"),t=require("./chunks/config-file-BNPm7ZNS.cjs");exports.BrowserLogger=e.u,exports.ConsoleGroupLogger=e.d,exports.ConsoleTransport=t.l,exports.PerformanceLogger=e.f,exports.createLogger=t.r,exports.createLoggerForEnvironment=t.i,exports.createTransports=t.u,exports.detectRuntime=e.v,exports.filterSensitiveData=e.p,exports.formatLevel=e.c,exports.formatLogEntry=e.l,exports.getDefaultConfig=e.t,exports.isBrowser=e.y,exports.isBun=e.b,exports.isDeno=e.x,exports.isNode=e.S,exports.loadConfigFromEnvironment=e.n,exports.loadConfigFromFile=t.t,exports.mergeConfigs=e.r,exports.registerTransport=t.f,exports.resetEnvironmentWarnings=e.i,exports.safeStringify=e.m,exports.serializeError=e.h,exports.shouldColorize=e.a,exports.tryParseLogLevel=e.o;
|
package/dist/deno.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { S as e, a as t, b as n, c as r, d as i, f as a, h as o, i as s, l as c, m as l, n as u, o as d, p as f, r as p, t as m, u as h, v as g, x as _, y as v } from "./chunks/config-
|
|
2
|
-
import { f as y, i as b, l as x, r as S, t as C, u as w } from "./chunks/config-file-
|
|
1
|
+
import { S as e, a as t, b as n, c as r, d as i, f as a, h as o, i as s, l as c, m as l, n as u, o as d, p as f, r as p, t as m, u as h, v as g, x as _, y as v } from "./chunks/config-C0Vj3nIk.mjs";
|
|
2
|
+
import { f as y, i as b, l as x, r as S, t as C, u as w } from "./chunks/config-file-CmxNUX1Z.mjs";
|
|
3
3
|
export { h as BrowserLogger, i as ConsoleGroupLogger, x as ConsoleTransport, a as PerformanceLogger, S as createLogger, b as createLoggerForEnvironment, w as createTransports, g as detectRuntime, f as filterSensitiveData, r as formatLevel, c as formatLogEntry, m as getDefaultConfig, v as isBrowser, n as isBun, _ as isDeno, e as isNode, u as loadConfigFromEnvironment, C as loadConfigFromFile, p as mergeConfigs, y as registerTransport, s as resetEnvironmentWarnings, l as safeStringify, o as serializeError, t as shouldColorize, d as tryParseLogLevel };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./chunks/config-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./chunks/config-BIFVBkeG.cjs"),t=require("./chunks/config-file-BNPm7ZNS.cjs");var n=t.i(),r={debug:(e,t)=>n.debug(e,t),info:(e,t)=>n.info(e,t),warn:(e,t)=>n.warn(e,t),error:(e,t)=>n.error(e,t)};exports.BaseLogger=e.g,exports.BrowserLogger=e.u,exports.ConsoleGroupLogger=e.d,exports.ConsoleTransport=t.l,exports.LogLevel=e._,exports.LoggerFactory=t.n,exports.PerformanceLogger=e.f,exports.createLogger=t.r,exports.createLoggerForEnvironment=t.i,exports.createTransports=t.u,exports.detectRuntime=e.v,exports.filterSensitiveData=e.p,exports.formatLevel=e.c,exports.formatLogEntry=e.l,exports.getDefaultConfig=e.t,exports.getTransportFactory=t.d,exports.isBrowser=e.y,exports.isBun=e.b,exports.isDeno=e.x,exports.isNode=e.S,exports.loadConfigFromEnvironment=e.n,exports.loadConfigFromFile=t.t,exports.log=r,exports.logLevelToString=t.a,exports.logger=n,exports.mergeConfigs=e.r,exports.registerTransport=t.f,exports.resetEnvironmentWarnings=e.i,exports.safeStringify=e.m,exports.serializeError=e.h,exports.shouldColorize=e.a,exports.stringToLogLevel=t.o,exports.tryParseLogLevel=e.o;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as e, _ as t, a as n, b as r, c as i, d as a, f as o, g as s, h as c, i as l, l as u, m as d, n as f, o as p, p as m, r as h, t as g, u as _, v, x as y, y as b } from "./chunks/config-
|
|
2
|
-
import { a as x, d as S, f as C, i as w, l as T, n as E, o as D, r as O, t as k, u as A } from "./chunks/config-file-
|
|
1
|
+
import { S as e, _ as t, a as n, b as r, c as i, d as a, f as o, g as s, h as c, i as l, l as u, m as d, n as f, o as p, p as m, r as h, t as g, u as _, v, x as y, y as b } from "./chunks/config-C0Vj3nIk.mjs";
|
|
2
|
+
import { a as x, d as S, f as C, i as w, l as T, n as E, o as D, r as O, t as k, u as A } from "./chunks/config-file-CmxNUX1Z.mjs";
|
|
3
3
|
//#region src/index.ts
|
|
4
4
|
var j = w(), M = {
|
|
5
5
|
debug: (e, t) => j.debug(e, t),
|
package/dist/node.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./chunks/config-file-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./chunks/config-file-BNPm7ZNS.cjs"),t=require("./chunks/file-transport-oFpf1vbE.cjs");exports.ConsoleTransport=e.l,exports.FileTransport=t.t,exports.NodeLogger=e.s,exports.createLogger=e.r,exports.createLoggerForEnvironment=e.i,exports.createMorganStream=e.c,exports.createTransports=e.u,exports.loadConfigFromFile=e.t,exports.registerTransport=e.f;
|
package/dist/node.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { c as e, f as t, i as n, l as r, r as i, s as a, t as o, u as s } from "./chunks/config-file-
|
|
2
|
-
import { t as c } from "./chunks/file-transport-
|
|
1
|
+
import { c as e, f as t, i as n, l as r, r as i, s as a, t as o, u as s } from "./chunks/config-file-CmxNUX1Z.mjs";
|
|
2
|
+
import { t as c } from "./chunks/file-transport-Y2ZoG0re.mjs";
|
|
3
3
|
export { r as ConsoleTransport, c as FileTransport, a as NodeLogger, i as createLogger, n as createLoggerForEnvironment, e as createMorganStream, s as createTransports, o as loadConfigFromFile, t as registerTransport };
|
|
@@ -24,14 +24,27 @@ export interface SafeStringifyOptions {
|
|
|
24
24
|
export declare function safeStringify(obj: any, space?: number, options?: SafeStringifyOptions): string;
|
|
25
25
|
/**
|
|
26
26
|
* Filter out sensitive data from an object before logging.
|
|
27
|
+
*
|
|
28
|
+
* Never applied automatically — the caller invokes it (SPEC §8.3).
|
|
29
|
+
*
|
|
30
|
+
* Both the field name and each key are split into tokens, so `api_key`, `apiKey`
|
|
31
|
+
* and `API-KEY` are all redacted while `monkey` and `tokenizer` are not. A field
|
|
32
|
+
* matches a key when every token of the key is present in the field name, or
|
|
33
|
+
* when the two token lists joined are equal; a token also matches that token
|
|
34
|
+
* followed by `s`. Supplying a key set **replaces** the defaults rather than
|
|
35
|
+
* extending them.
|
|
36
|
+
*
|
|
37
|
+
* Because matching is on whole tokens, a name like `mytoken` is one token and is
|
|
38
|
+
* not redacted; pass your own keys if your codebase names fields that way.
|
|
39
|
+
*
|
|
27
40
|
* @param obj - The object to filter
|
|
28
|
-
* @param sensitiveKeys -
|
|
41
|
+
* @param sensitiveKeys - Key names to redact, tokenized and matched case-insensitively
|
|
29
42
|
* @returns A new object with sensitive values replaced with '[REDACTED]'
|
|
30
43
|
* @example
|
|
31
44
|
* ```typescript
|
|
32
|
-
* const data = { username: 'john', password: 'secret123' };
|
|
45
|
+
* const data = { username: 'john', password: 'secret123', monkey: 'george' };
|
|
33
46
|
* const filtered = filterSensitiveData(data);
|
|
34
|
-
* // Result: { username: 'john', password: '[REDACTED]' }
|
|
47
|
+
* // Result: { username: 'john', password: '[REDACTED]', monkey: 'george' }
|
|
35
48
|
* ```
|
|
36
49
|
*/
|
|
37
50
|
export declare function filterSensitiveData(obj: any, sensitiveKeys?: string[]): any;
|
|
@@ -24,14 +24,27 @@ export interface SafeStringifyOptions {
|
|
|
24
24
|
export declare function safeStringify(obj: any, space?: number, options?: SafeStringifyOptions): string;
|
|
25
25
|
/**
|
|
26
26
|
* Filter out sensitive data from an object before logging.
|
|
27
|
+
*
|
|
28
|
+
* Never applied automatically — the caller invokes it (SPEC §8.3).
|
|
29
|
+
*
|
|
30
|
+
* Both the field name and each key are split into tokens, so `api_key`, `apiKey`
|
|
31
|
+
* and `API-KEY` are all redacted while `monkey` and `tokenizer` are not. A field
|
|
32
|
+
* matches a key when every token of the key is present in the field name, or
|
|
33
|
+
* when the two token lists joined are equal; a token also matches that token
|
|
34
|
+
* followed by `s`. Supplying a key set **replaces** the defaults rather than
|
|
35
|
+
* extending them.
|
|
36
|
+
*
|
|
37
|
+
* Because matching is on whole tokens, a name like `mytoken` is one token and is
|
|
38
|
+
* not redacted; pass your own keys if your codebase names fields that way.
|
|
39
|
+
*
|
|
27
40
|
* @param obj - The object to filter
|
|
28
|
-
* @param sensitiveKeys -
|
|
41
|
+
* @param sensitiveKeys - Key names to redact, tokenized and matched case-insensitively
|
|
29
42
|
* @returns A new object with sensitive values replaced with '[REDACTED]'
|
|
30
43
|
* @example
|
|
31
44
|
* ```typescript
|
|
32
|
-
* const data = { username: 'john', password: 'secret123' };
|
|
45
|
+
* const data = { username: 'john', password: 'secret123', monkey: 'george' };
|
|
33
46
|
* const filtered = filterSensitiveData(data);
|
|
34
|
-
* // Result: { username: 'john', password: '[REDACTED]' }
|
|
47
|
+
* // Result: { username: 'john', password: '[REDACTED]', monkey: 'george' }
|
|
35
48
|
* ```
|
|
36
49
|
*/
|
|
37
50
|
export declare function filterSensitiveData(obj: any, sensitiveKeys?: string[]): any;
|
|
@@ -24,14 +24,27 @@ export interface SafeStringifyOptions {
|
|
|
24
24
|
export declare function safeStringify(obj: any, space?: number, options?: SafeStringifyOptions): string;
|
|
25
25
|
/**
|
|
26
26
|
* Filter out sensitive data from an object before logging.
|
|
27
|
+
*
|
|
28
|
+
* Never applied automatically — the caller invokes it (SPEC §8.3).
|
|
29
|
+
*
|
|
30
|
+
* Both the field name and each key are split into tokens, so `api_key`, `apiKey`
|
|
31
|
+
* and `API-KEY` are all redacted while `monkey` and `tokenizer` are not. A field
|
|
32
|
+
* matches a key when every token of the key is present in the field name, or
|
|
33
|
+
* when the two token lists joined are equal; a token also matches that token
|
|
34
|
+
* followed by `s`. Supplying a key set **replaces** the defaults rather than
|
|
35
|
+
* extending them.
|
|
36
|
+
*
|
|
37
|
+
* Because matching is on whole tokens, a name like `mytoken` is one token and is
|
|
38
|
+
* not redacted; pass your own keys if your codebase names fields that way.
|
|
39
|
+
*
|
|
27
40
|
* @param obj - The object to filter
|
|
28
|
-
* @param sensitiveKeys -
|
|
41
|
+
* @param sensitiveKeys - Key names to redact, tokenized and matched case-insensitively
|
|
29
42
|
* @returns A new object with sensitive values replaced with '[REDACTED]'
|
|
30
43
|
* @example
|
|
31
44
|
* ```typescript
|
|
32
|
-
* const data = { username: 'john', password: 'secret123' };
|
|
45
|
+
* const data = { username: 'john', password: 'secret123', monkey: 'george' };
|
|
33
46
|
* const filtered = filterSensitiveData(data);
|
|
34
|
-
* // Result: { username: 'john', password: '[REDACTED]' }
|
|
47
|
+
* // Result: { username: 'john', password: '[REDACTED]', monkey: 'george' }
|
|
35
48
|
* ```
|
|
36
49
|
*/
|
|
37
50
|
export declare function filterSensitiveData(obj: any, sensitiveKeys?: string[]): any;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(){let e=t();return{name:e,version:n(e),capabilities:r(e)}}function t(){return globalThis.Deno===void 0?globalThis.Bun===void 0?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`:`bun`:`deno`}function n(e){switch(e){case`node`:return typeof process<`u`?process.version:void 0;case`deno`:return globalThis.Deno===void 0?void 0:globalThis.Deno.version?.deno;case`bun`:return globalThis.Bun===void 0?void 0:globalThis.Bun.version;case`browser`:return typeof navigator<`u`?navigator.userAgent:void 0;default:return}}function r(e){switch(e){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 i(){return t()===`node`}function a(){return t()===`browser`}function o(){return t()===`deno`}function s(){return t()===`bun`}var c=function(e){return e[e.DEBUG=0]=`DEBUG`,e[e.INFO=1]=`INFO`,e[e.WARN=2]=`WARN`,e[e.ERROR=3]=`ERROR`,e[e.SILENT=4]=`SILENT`,e}({}),l=class{constructor(t={}){this.childMetadata={},this.config=t,this.level=t.level??c.INFO,this.runtime=e().name,this.childMetadata={...t.metadata}}debug(e,t){this.log(c.DEBUG,e,t)}info(e,t){this.log(c.INFO,e,t)}warn(e,t){this.log(c.WARN,e,t)}error(e,t){this.log(c.ERROR,e,t)}log(e,t,n){if(!this.shouldLog(e))return;let r=typeof t==`function`?t():t,i={...this.childMetadata,...n},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){let t=this.createChild();return t.childMetadata={...this.childMetadata,...e},t}shouldLog(e){return e>=this.level}},u=100;function d(e,t,n,r){if(e===void 0)return`[undefined]`;if(typeof e==`bigint`)return`[BigInt: ${e.toString()}]`;if(typeof e==`symbol`)return`[Symbol: ${e.toString()}]`;if(typeof e==`function`)return`[Function: ${e.name||`anonymous`}]`;if(typeof e!=`object`||!e)return e;let i=e;if(t.has(i))return`[Circular]`;if(n>=r)return`[MaxDepth]`;t.add(i);try{if(i instanceof Error)return f(_(i),t,n,r);let e=i.toJSON;if(typeof e==`function`)return d(e.call(i),t,n,r);if(Array.isArray(i)){let e=[];for(let a=0;a<i.length;a++)e.push(d(i[a],t,n+1,r));return e}return f(i,t,n,r)}finally{t.delete(i)}}function f(e,t,n,r){let i={};for(let[a,o]of Object.entries(e))i[a]=d(o,t,n+1,r);return i}function p(e,t,n={}){let r=n.maxDepth??u;return JSON.stringify(d(e,new Set,0,r),null,t)}function m(e,t=[`password`,`token`,`secret`,`key`,`auth`]){if(typeof e!=`object`||!e)return e;let n=Array.isArray(e)?[]:{};for(let[r,i]of Object.entries(e))n[r]=t.some(e=>r.toLowerCase().includes(e.toLowerCase()))?`[REDACTED]`:typeof i==`object`&&i?m(i,t):i;return n}var h=[`name`,`message`,`stack`];function g(e,t){let n=Object.getOwnPropertyDescriptor(e,t);if(n){if(n.get)try{return n.get.call(e)}catch{return`[Throws]`}return n.value}}function _(e){if(!(e instanceof Error))return e;let t={name:e.name,message:e.message};e.stack!==void 0&&(t.stack=e.stack);for(let n of Object.getOwnPropertyNames(e))h.includes(n)||(t[n]=g(e,n));return t}var v=class e extends l{constructor(e={}){super(e)}writeLog(e){let t=this.formatMessage(e),n=this.getConsoleStyle(e.level),r=`%c${t}${e.metadata?` ${p(e.metadata)}`:``}`;switch(e.level){case c.DEBUG:console.debug?console.debug(r,n):console.log(r,n);break;case c.INFO:console.info(r,n);break;case c.WARN:console.warn(r,n);break;case c.ERROR:console.error(r,n)}}createChild(){return new e(this.config)}formatMessage(e){return`[${e.timestamp.toISOString()}] ${c[e.level].toUpperCase()}: ${e.message}`}getConsoleStyle(e){if(!this.config.colorize)return``;switch(e){case c.DEBUG:return`color: #888; font-weight: normal;`;case c.INFO:return`color: #007acc; font-weight: normal;`;case c.WARN:return`color: #ff8c00; font-weight: bold;`;case c.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<=c.ERROR}shouldLog(e){return!this.shouldLogInProduction()&&e<c.ERROR?!1:super.shouldLog(e)}},y=class extends v{constructor(...e){super(...e),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,t){console.trace(e,t)}count(e){console.count(e)}countReset(e){console.countReset(e)}table(e){console.table(e)}},b=class extends v{mark(e){typeof performance<`u`&&performance.mark&&performance.mark(e)}measure(e,t,n){if(typeof performance<`u`&&performance.measure)try{performance.measure(e,t,n);let r=performance.getEntriesByName(e,`measure`);if(r.length>0){let t=r[r.length-1];this.info(`Performance: ${e}`,{duration:t.duration,startTime:t.startTime})}}catch(t){this.warn(`Failed to measure performance`,{name:e,error:t})}}clearMarks(e){typeof performance<`u`&&performance.clearMarks&&performance.clearMarks(e)}clearMeasures(e){typeof performance<`u`&&performance.clearMeasures&&performance.clearMeasures(e)}};function x(e,t=`text`,n={}){if(t===`json`){let t={timestamp:e.timestamp.toISOString(),level:c[e.level].toLowerCase(),message:e.message,runtime:e.runtime};return e.metadata!==void 0&&(t.metadata=e.metadata),p(t)}let r=n.timestamp===!1?``:`[${e.timestamp.toISOString()}] `,i=S(e.level,n.colorize===!0),a=e.metadata?` ${p(e.metadata)}`:``;return`${r}${i}: ${e.message}${a}`}function S(e,t=!1){let n=c[e].toUpperCase();if(!t)return n;let r={[c.DEBUG]:`\x1B[36m`,[c.INFO]:`\x1B[32m`,[c.WARN]:`\x1B[33m`,[c.ERROR]:`\x1B[31m`,[c.SILENT]:`\x1B[37m`};return`${r[e]||r[c.INFO]}${n}[0m`}var C=new Set;function w(e){C.has(e)||(C.add(e),console.warn(e))}function T(){C.clear()}function E(){return e().capabilities.colorSupport?typeof process>`u`||!process.env?!0:process.env.NO_COLOR?!1:process.env.FORCE_COLOR?process.env.FORCE_COLOR!==`0`:process.stdout?.isTTY===!0:!1}function D(){return{level:c.INFO,format:`text`,timestamp:!0,colorize:E(),metadata:{},transports:[{type:`console`,options:{}}]}}var O=[`true`,`1`,`yes`,`on`],k=[`false`,`0`,`no`,`off`];function A(){T()}function j(e){switch(e.trim().toLowerCase()){case`debug`:return c.DEBUG;case`info`:return c.INFO;case`warn`:case`warning`:return c.WARN;case`error`:return c.ERROR;case`silent`:case`none`:return c.SILENT;default:return}}function M(e,t){let n=t.trim().toLowerCase();if(O.includes(n))return!0;if(k.includes(n))return!1;w(`[logan-logger] ${e}="${t}" is not a recognized boolean and was ignored. Accepted: ${O.join(`, `)} / ${k.join(`, `)}.`)}function N(){let e={};if(typeof process>`u`||!process.env)return e;let t=process.env;if(t.LOG_LEVEL){let n=j(t.LOG_LEVEL);n===void 0?w(`[logan-logger] LOG_LEVEL="${t.LOG_LEVEL}" is not a recognized level and was ignored. Accepted: debug, info, warn, error, silent.`):e.level=n}if(t.LOG_FORMAT){let n=t.LOG_FORMAT.trim().toLowerCase();n===`json`||n===`text`?e.format=n:w(`[logan-logger] LOG_FORMAT="${t.LOG_FORMAT}" is not a recognized format and was ignored. Accepted: json, text.`)}if(t.LOG_TIMESTAMP){let n=M(`LOG_TIMESTAMP`,t.LOG_TIMESTAMP);n!==void 0&&(e.timestamp=n)}if(t.LOG_COLOR){let n=M(`LOG_COLOR`,t.LOG_COLOR);n!==void 0&&(e.colorize=n)}return e}function P(...e){let t=D();return e.reduce((e,t)=>({...e,...t,metadata:{...e.metadata,...t.metadata},transports:t.transports||e.transports}),t)}Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return a}});
|