logan-logger 2.0.2 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/browser.cjs +1 -1
- package/dist/browser.mjs +8 -8
- package/dist/bun.cjs +1 -1
- package/dist/bun.mjs +4 -5
- package/dist/chunks/{config-Db6PTLH2.mjs → config-CpbjY9zX.mjs} +31 -25
- package/dist/chunks/{config-PPDFSral.cjs → config-DpSCCiRz.cjs} +1 -1
- package/dist/chunks/config-file-CvMv3rgc.mjs +377 -0
- package/dist/chunks/config-file-WYBC6sSB.cjs +1 -0
- package/dist/chunks/file-transport-B34EGzxL.cjs +1 -0
- package/dist/chunks/{file-transport-DRyxQq8t.mjs → file-transport-yIPiX8TP.mjs} +2 -2
- package/dist/deno.cjs +1 -1
- package/dist/deno.mjs +3 -4
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +4 -5
- package/dist/node.cjs +1 -1
- package/dist/node.d.cts +1 -0
- package/dist/node.d.mts +1 -0
- package/dist/node.d.ts +1 -0
- package/dist/node.mjs +3 -3
- package/dist/utils/config-file.d.cts +47 -1
- package/dist/utils/config-file.d.mts +47 -1
- package/dist/utils/config-file.d.ts +47 -1
- package/dist/utils/config.d.cts +2 -1
- package/dist/utils/config.d.mts +2 -1
- package/dist/utils/config.d.ts +2 -1
- package/dist/utils/warn-once.d.cts +7 -0
- package/dist/utils/warn-once.d.mts +7 -0
- package/dist/utils/warn-once.d.ts +7 -0
- package/package.json +2 -2
- package/dist/chunks/config-file-37L8z8Lm.mjs +0 -56
- package/dist/chunks/config-file-Dvyi1e80.cjs +0 -1
- package/dist/chunks/factory-BPYE1-Nw.cjs +0 -1
- package/dist/chunks/factory-CXO2aNcc.mjs +0 -169
- package/dist/chunks/file-transport-SA6KG1oM.cjs +0 -1
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ Use named imports. There is no default export.
|
|
|
65
65
|
| Runtime | Import | Notes |
|
|
66
66
|
|---|---|---|
|
|
67
67
|
| Auto-detect | `logan-logger` | Also the right choice for Next.js and other isomorphic frameworks |
|
|
68
|
-
| Node.js
|
|
68
|
+
| Node.js 22.12+ | `logan-logger/node` | Adds the file transport and Morgan integration |
|
|
69
69
|
| Bun | `logan-logger/bun` | Same as Node |
|
|
70
70
|
| Browser / WebWorker | `logan-logger/browser` | CSS-styled console, performance marks, grouping |
|
|
71
71
|
| Deno | `jsr:@logan/logger` | Console; native implementation planned |
|
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-DpSCCiRz.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,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
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-CpbjY9zX.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";
|
|
5
5
|
}
|
|
6
6
|
function _(e) {
|
|
7
7
|
switch (e) {
|
|
8
|
-
case "production": return
|
|
8
|
+
case "production": return t.ERROR;
|
|
9
9
|
case "staging":
|
|
10
|
-
case "test": return
|
|
10
|
+
case "test": return t.WARN;
|
|
11
11
|
case "development":
|
|
12
|
-
case "dev": return
|
|
13
|
-
default: return
|
|
12
|
+
case "dev": return t.DEBUG;
|
|
13
|
+
default: return t.INFO;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
function v(e = {}) {
|
|
17
|
-
let t = e.ignoreEnvironment ? {} :
|
|
18
|
-
return new
|
|
17
|
+
let t = e.ignoreEnvironment ? {} : l();
|
|
18
|
+
return new f(d(e, t));
|
|
19
19
|
}
|
|
20
20
|
function y() {
|
|
21
21
|
let e = g();
|
|
@@ -33,4 +33,4 @@ var b = y(), x = {
|
|
|
33
33
|
error: (e, t) => b.error(e, t)
|
|
34
34
|
};
|
|
35
35
|
//#endregion
|
|
36
|
-
export {
|
|
36
|
+
export { f as BrowserLogger, i as ConsoleGroupLogger, t as LogLevel, a as PerformanceLogger, v as createLogger, y as createLoggerForEnvironment, p as detectRuntime, u as filterSensitiveData, r as formatLevel, s as formatLogEntry, h as isBrowser, n as isBun, m as isDeno, e as isNode, x as log, b as logger, c as safeStringify, o as serializeError };
|
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-DpSCCiRz.cjs"),t=require("./chunks/config-file-WYBC6sSB.cjs"),n=require("./chunks/file-transport-B34EGzxL.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,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
|
|
5
|
-
export { g as ConsoleTransport, C as FileTransport, b as NodeLogger, y as createLogger, x as createLoggerForEnvironment, v as createTransports, e as detectRuntime, i as filterSensitiveData, d as formatLevel, r as formatLogEntry, f as getDefaultConfig, p as isBrowser, h as isBun, n as isDeno, m as isNode, s as loadConfigFromEnvironment, S as loadConfigFromFile, u as mergeConfigs, _ as registerTransport, a as resetEnvironmentWarnings, l as safeStringify, o as serializeError, t as shouldColorize, c as tryParseLogLevel };
|
|
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-CpbjY9zX.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-CvMv3rgc.mjs";
|
|
3
|
+
import { t as C } from "./chunks/file-transport-yIPiX8TP.mjs";
|
|
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 };
|
|
@@ -330,16 +330,25 @@ function S(e, t = !1) {
|
|
|
330
330
|
return `${r[e] || r[c.INFO]}${n}[0m`;
|
|
331
331
|
}
|
|
332
332
|
//#endregion
|
|
333
|
+
//#region src/utils/warn-once.ts
|
|
334
|
+
var C = /* @__PURE__ */ new Set();
|
|
335
|
+
function w(e) {
|
|
336
|
+
C.has(e) || (C.add(e), console.warn(e));
|
|
337
|
+
}
|
|
338
|
+
function T() {
|
|
339
|
+
C.clear();
|
|
340
|
+
}
|
|
341
|
+
//#endregion
|
|
333
342
|
//#region src/utils/config.ts
|
|
334
|
-
function
|
|
343
|
+
function E() {
|
|
335
344
|
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;
|
|
336
345
|
}
|
|
337
|
-
function
|
|
346
|
+
function D() {
|
|
338
347
|
return {
|
|
339
348
|
level: c.INFO,
|
|
340
349
|
format: "text",
|
|
341
350
|
timestamp: !0,
|
|
342
|
-
colorize:
|
|
351
|
+
colorize: E(),
|
|
343
352
|
metadata: {},
|
|
344
353
|
transports: [{
|
|
345
354
|
type: "console",
|
|
@@ -347,24 +356,21 @@ function w() {
|
|
|
347
356
|
}]
|
|
348
357
|
};
|
|
349
358
|
}
|
|
350
|
-
var
|
|
359
|
+
var O = [
|
|
351
360
|
"true",
|
|
352
361
|
"1",
|
|
353
362
|
"yes",
|
|
354
363
|
"on"
|
|
355
|
-
],
|
|
364
|
+
], k = [
|
|
356
365
|
"false",
|
|
357
366
|
"0",
|
|
358
367
|
"no",
|
|
359
368
|
"off"
|
|
360
|
-
]
|
|
361
|
-
function
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
function k() {
|
|
365
|
-
D.clear();
|
|
369
|
+
];
|
|
370
|
+
function A() {
|
|
371
|
+
T();
|
|
366
372
|
}
|
|
367
|
-
function
|
|
373
|
+
function j(e) {
|
|
368
374
|
switch (e.trim().toLowerCase()) {
|
|
369
375
|
case "debug": return c.DEBUG;
|
|
370
376
|
case "info": return c.INFO;
|
|
@@ -376,36 +382,36 @@ function A(e) {
|
|
|
376
382
|
default: return;
|
|
377
383
|
}
|
|
378
384
|
}
|
|
379
|
-
function
|
|
385
|
+
function M(e, t) {
|
|
380
386
|
let n = t.trim().toLowerCase();
|
|
381
|
-
if (
|
|
382
|
-
if (
|
|
383
|
-
|
|
387
|
+
if (O.includes(n)) return !0;
|
|
388
|
+
if (k.includes(n)) return !1;
|
|
389
|
+
w(`[logan-logger] ${e}="${t}" is not a recognized boolean and was ignored. Accepted: ${O.join(", ")} / ${k.join(", ")}.`);
|
|
384
390
|
}
|
|
385
|
-
function
|
|
391
|
+
function N() {
|
|
386
392
|
let e = {};
|
|
387
393
|
if (typeof process > "u" || !process.env) return e;
|
|
388
394
|
let t = process.env;
|
|
389
395
|
if (t.LOG_LEVEL) {
|
|
390
|
-
let n =
|
|
391
|
-
n === void 0 ?
|
|
396
|
+
let n = j(t.LOG_LEVEL);
|
|
397
|
+
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;
|
|
392
398
|
}
|
|
393
399
|
if (t.LOG_FORMAT) {
|
|
394
400
|
let n = t.LOG_FORMAT.trim().toLowerCase();
|
|
395
|
-
n === "json" || n === "text" ? e.format = n :
|
|
401
|
+
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.`);
|
|
396
402
|
}
|
|
397
403
|
if (t.LOG_TIMESTAMP) {
|
|
398
|
-
let n =
|
|
404
|
+
let n = M("LOG_TIMESTAMP", t.LOG_TIMESTAMP);
|
|
399
405
|
n !== void 0 && (e.timestamp = n);
|
|
400
406
|
}
|
|
401
407
|
if (t.LOG_COLOR) {
|
|
402
|
-
let n =
|
|
408
|
+
let n = M("LOG_COLOR", t.LOG_COLOR);
|
|
403
409
|
n !== void 0 && (e.colorize = n);
|
|
404
410
|
}
|
|
405
411
|
return e;
|
|
406
412
|
}
|
|
407
|
-
function
|
|
408
|
-
let t =
|
|
413
|
+
function P(...e) {
|
|
414
|
+
let t = D();
|
|
409
415
|
return e.reduce((e, t) => ({
|
|
410
416
|
...e,
|
|
411
417
|
...t,
|
|
@@ -417,4 +423,4 @@ function N(...e) {
|
|
|
417
423
|
}), t);
|
|
418
424
|
}
|
|
419
425
|
//#endregion
|
|
420
|
-
export {
|
|
426
|
+
export { i as S, c as _, E as a, s as b, S as c, y as d, b as f, l as g, _ as h, A as i, x as l, p as m, N as n, j as o, m as p, P as r, w as s, D as t, v as u, e as v, o as x, a as y };
|
|
@@ -1 +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=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`}function C(){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
|
|
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}});
|
|
@@ -0,0 +1,377 @@
|
|
|
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-CpbjY9zX.mjs";
|
|
2
|
+
//#region src/core/transport.ts
|
|
3
|
+
var u = /* @__PURE__ */ new Map();
|
|
4
|
+
function d(e, t) {
|
|
5
|
+
u.set(e, t);
|
|
6
|
+
}
|
|
7
|
+
function f(e) {
|
|
8
|
+
return u.get(e);
|
|
9
|
+
}
|
|
10
|
+
var p = class {
|
|
11
|
+
constructor(e = {}) {
|
|
12
|
+
this.type = "console", this.level = e.level, this.format = e.format === "json" ? "json" : "text", this.formatOptions = {
|
|
13
|
+
timestamp: e.timestamp !== !1,
|
|
14
|
+
colorize: e.colorize === !0
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
write(t) {
|
|
18
|
+
let n = r(t, this.format, this.formatOptions);
|
|
19
|
+
switch (t.level) {
|
|
20
|
+
case e.DEBUG:
|
|
21
|
+
console.debug(n);
|
|
22
|
+
break;
|
|
23
|
+
case e.WARN:
|
|
24
|
+
console.warn(n);
|
|
25
|
+
break;
|
|
26
|
+
case e.ERROR:
|
|
27
|
+
console.error(n);
|
|
28
|
+
break;
|
|
29
|
+
default: console.info(n);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
d("console", (e, t) => {
|
|
34
|
+
let n = e.options ?? {};
|
|
35
|
+
return new p({
|
|
36
|
+
format: n.format ?? t.format,
|
|
37
|
+
timestamp: n.timestamp ?? t.timestamp,
|
|
38
|
+
colorize: n.colorize ?? t.colorize,
|
|
39
|
+
level: e.level
|
|
40
|
+
});
|
|
41
|
+
}), d("custom", (e) => {
|
|
42
|
+
let t = e.options?.transport;
|
|
43
|
+
if (!t || typeof t.write != "function") throw Error("custom transport requires options.transport to be an object with a write(entry) method");
|
|
44
|
+
return e.level === void 0 ? t : {
|
|
45
|
+
type: t.type ?? "custom",
|
|
46
|
+
level: e.level,
|
|
47
|
+
write: (e) => t.write(e),
|
|
48
|
+
close: t.close ? () => t.close?.() : void 0
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
function m(e) {
|
|
52
|
+
let t = {
|
|
53
|
+
format: e.format ?? "text",
|
|
54
|
+
timestamp: e.timestamp ?? !0,
|
|
55
|
+
colorize: e.colorize ?? !1
|
|
56
|
+
};
|
|
57
|
+
if (e.transports === void 0) return [new p({
|
|
58
|
+
format: t.format,
|
|
59
|
+
timestamp: t.timestamp,
|
|
60
|
+
colorize: t.colorize
|
|
61
|
+
})];
|
|
62
|
+
let n = [];
|
|
63
|
+
for (let r of e.transports) {
|
|
64
|
+
let e = f(r.type);
|
|
65
|
+
if (!e) {
|
|
66
|
+
console.warn(`[logan-logger] ${h(r.type)}`);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
n.push(e(r, t));
|
|
71
|
+
} catch (e) {
|
|
72
|
+
console.warn(`[logan-logger] transport '${r.type}' failed to initialize:`, e);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return n;
|
|
76
|
+
}
|
|
77
|
+
function h(e) {
|
|
78
|
+
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`;
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/runtime/node.ts
|
|
82
|
+
var g = class e extends n {
|
|
83
|
+
constructor(e = {}, t) {
|
|
84
|
+
super(e), this.transports = t ?? m(e);
|
|
85
|
+
}
|
|
86
|
+
getTransports() {
|
|
87
|
+
return this.transports;
|
|
88
|
+
}
|
|
89
|
+
close() {
|
|
90
|
+
for (let e of this.transports) e.close?.();
|
|
91
|
+
}
|
|
92
|
+
writeLog(e) {
|
|
93
|
+
for (let t of this.transports) if (!(t.level !== void 0 && e.level < t.level)) try {
|
|
94
|
+
t.write(e);
|
|
95
|
+
} catch (e) {
|
|
96
|
+
console.warn(`[logan-logger] transport '${t.type}' failed to write:`, e);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
createChild() {
|
|
100
|
+
return new e(this.config, this.transports);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
function _(e) {
|
|
104
|
+
return { write: (t) => {
|
|
105
|
+
e.info(t.trim());
|
|
106
|
+
} };
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/core/factory.ts
|
|
110
|
+
var v = class e {
|
|
111
|
+
static create(t = {}) {
|
|
112
|
+
let n = l(), r = e.mergeConfig(t);
|
|
113
|
+
switch (n.name) {
|
|
114
|
+
case "node": return new g(r);
|
|
115
|
+
case "deno": return new c(r);
|
|
116
|
+
case "bun": return new g(r);
|
|
117
|
+
case "browser":
|
|
118
|
+
case "webworker": return new c(r);
|
|
119
|
+
default: return new c(r);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
static createChild(e, t) {
|
|
123
|
+
return e.child(t);
|
|
124
|
+
}
|
|
125
|
+
static mergeConfig(e) {
|
|
126
|
+
let t = e.ignoreEnvironment ? {} : i();
|
|
127
|
+
return o(e, t);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
function y(e) {
|
|
131
|
+
return v.create(e);
|
|
132
|
+
}
|
|
133
|
+
function b() {
|
|
134
|
+
let e = x();
|
|
135
|
+
return y({
|
|
136
|
+
level: S(e),
|
|
137
|
+
colorize: e !== "production" && t(),
|
|
138
|
+
timestamp: !0,
|
|
139
|
+
format: e === "production" ? "json" : "text"
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function x() {
|
|
143
|
+
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";
|
|
144
|
+
}
|
|
145
|
+
function S(t) {
|
|
146
|
+
switch (t) {
|
|
147
|
+
case "production": return e.ERROR;
|
|
148
|
+
case "staging":
|
|
149
|
+
case "test": return e.WARN;
|
|
150
|
+
case "development":
|
|
151
|
+
case "dev": return e.DEBUG;
|
|
152
|
+
default: return e.INFO;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function C(t) {
|
|
156
|
+
return a(t) ?? e.INFO;
|
|
157
|
+
}
|
|
158
|
+
function w(t) {
|
|
159
|
+
switch (t) {
|
|
160
|
+
case e.DEBUG: return "debug";
|
|
161
|
+
case e.INFO: return "info";
|
|
162
|
+
case e.WARN: return "warn";
|
|
163
|
+
case e.ERROR: return "error";
|
|
164
|
+
case e.SILENT: return "silent";
|
|
165
|
+
default: return "info";
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//#endregion
|
|
169
|
+
//#region src/utils/config-file.ts
|
|
170
|
+
var T = [
|
|
171
|
+
{ path: "logan.config.json" },
|
|
172
|
+
{ path: ".loganrc" },
|
|
173
|
+
{
|
|
174
|
+
path: "package.json",
|
|
175
|
+
key: "logan"
|
|
176
|
+
}
|
|
177
|
+
], E = /* @__PURE__ */ new Set([
|
|
178
|
+
"level",
|
|
179
|
+
"format",
|
|
180
|
+
"timestamp",
|
|
181
|
+
"colorize",
|
|
182
|
+
"ignoreEnvironment",
|
|
183
|
+
"metadata",
|
|
184
|
+
"transports",
|
|
185
|
+
"$schema"
|
|
186
|
+
]), D = /* @__PURE__ */ new Set([
|
|
187
|
+
"EACCES",
|
|
188
|
+
"EPERM",
|
|
189
|
+
"NotCapable",
|
|
190
|
+
"PermissionDenied"
|
|
191
|
+
]);
|
|
192
|
+
function O(e) {
|
|
193
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
194
|
+
}
|
|
195
|
+
function k(e) {
|
|
196
|
+
return e instanceof Error ? e.message : String(e);
|
|
197
|
+
}
|
|
198
|
+
function A(e) {
|
|
199
|
+
let t = /at position \d+(?: \(line \d+ column \d+\))?/.exec(k(e));
|
|
200
|
+
return t ? `not valid JSON (${t[0]})` : "not valid JSON";
|
|
201
|
+
}
|
|
202
|
+
function j(e) {
|
|
203
|
+
return e.startsWith("/") || e.startsWith("\\") || /^[A-Za-z]:/.test(e);
|
|
204
|
+
}
|
|
205
|
+
function M(e, t) {
|
|
206
|
+
return t === void 0 || t === "" || j(e) ? e : `${t.replace(/[\\/]+$/, "")}/${e}`;
|
|
207
|
+
}
|
|
208
|
+
async function N(e, t) {
|
|
209
|
+
if (e === "deno") return (e) => M(e, t);
|
|
210
|
+
let { resolve: n } = await import("node:path");
|
|
211
|
+
return t === void 0 ? (e) => n(e) : (e) => n(t, e);
|
|
212
|
+
}
|
|
213
|
+
function P(e) {
|
|
214
|
+
let t = e.split(/[\\/]/);
|
|
215
|
+
return t[t.length - 1] || e;
|
|
216
|
+
}
|
|
217
|
+
function F(e) {
|
|
218
|
+
if (e === "deno") try {
|
|
219
|
+
return globalThis.Deno?.cwd?.();
|
|
220
|
+
} catch {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
return typeof process < "u" && typeof process.cwd == "function" ? process.cwd() : void 0;
|
|
224
|
+
}
|
|
225
|
+
function I(e) {
|
|
226
|
+
let t = e?.code ?? "", n = e?.name ?? "";
|
|
227
|
+
return t === "ENOENT" || n === "NotFound" ? { kind: "absent" } : D.has(t) || D.has(n) ? {
|
|
228
|
+
kind: "denied",
|
|
229
|
+
reason: k(e)
|
|
230
|
+
} : {
|
|
231
|
+
kind: "unreadable",
|
|
232
|
+
reason: k(e)
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
async function L(e, t) {
|
|
236
|
+
let n = t === "deno" ? () => globalThis.Deno.readTextFile(e) : async () => (await import("node:fs/promises")).readFile(e, "utf-8");
|
|
237
|
+
try {
|
|
238
|
+
return {
|
|
239
|
+
kind: "content",
|
|
240
|
+
content: await n()
|
|
241
|
+
};
|
|
242
|
+
} catch (e) {
|
|
243
|
+
return I(e);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function R(t) {
|
|
247
|
+
if (typeof t == "string") return a(t);
|
|
248
|
+
if (typeof t == "number" && e[t] !== void 0) return t;
|
|
249
|
+
}
|
|
250
|
+
function z(e, t, n) {
|
|
251
|
+
let r = (e) => {
|
|
252
|
+
s(`[logan-logger] ${n}: ignoring transports[${t}]: ${e}.`);
|
|
253
|
+
};
|
|
254
|
+
if (!O(e)) {
|
|
255
|
+
r(`expected an object, got ${JSON.stringify(e) ?? typeof e}`);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (typeof e.type != "string") {
|
|
259
|
+
r("\"type\" is required and must be a string");
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (e.options !== void 0 && !O(e.options)) {
|
|
263
|
+
r("\"options\" must be an object");
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
let i = {
|
|
267
|
+
type: e.type,
|
|
268
|
+
options: e.options ?? {}
|
|
269
|
+
};
|
|
270
|
+
if (e.level !== void 0) {
|
|
271
|
+
let r = R(e.level);
|
|
272
|
+
r === void 0 ? s(`[logan-logger] ${n}: ignoring transports[${t}].level=${JSON.stringify(e.level)}. Accepted: debug, info, warn, error, silent.`) : i.level = r;
|
|
273
|
+
}
|
|
274
|
+
return i;
|
|
275
|
+
}
|
|
276
|
+
function B(e, t) {
|
|
277
|
+
let n = {}, r = (e, n, r) => {
|
|
278
|
+
s(`[logan-logger] ${t}: ignoring ${e}=${JSON.stringify(n)}. Accepted: ${r}.`);
|
|
279
|
+
};
|
|
280
|
+
for (let n of Object.keys(e)) E.has(n) || s(`[logan-logger] ${t}: ignoring unknown field "${n}". Known fields: level, format, timestamp, colorize, ignoreEnvironment, metadata, transports.`);
|
|
281
|
+
if (e.level !== void 0) {
|
|
282
|
+
let t = R(e.level);
|
|
283
|
+
t === void 0 ? r("level", e.level, "debug, info, warn, error, silent") : n.level = t;
|
|
284
|
+
}
|
|
285
|
+
e.format !== void 0 && (e.format === "json" || e.format === "text" || e.format === "custom" ? n.format = e.format : r("format", e.format, "json, text, custom"));
|
|
286
|
+
for (let t of [
|
|
287
|
+
"timestamp",
|
|
288
|
+
"colorize",
|
|
289
|
+
"ignoreEnvironment"
|
|
290
|
+
]) e[t] !== void 0 && (typeof e[t] == "boolean" ? n[t] = e[t] : r(t, e[t], "true, false"));
|
|
291
|
+
if (e.metadata !== void 0 && (O(e.metadata) ? n.metadata = e.metadata : r("metadata", e.metadata, "an object")), Array.isArray(e.transports)) {
|
|
292
|
+
let r = e.transports.map((e, n) => z(e, n, t)).filter((e) => e !== void 0);
|
|
293
|
+
(r.length > 0 || e.transports.length === 0) && (n.transports = r);
|
|
294
|
+
} else e.transports !== void 0 && r("transports", e.transports, "an array of transport configs");
|
|
295
|
+
return n;
|
|
296
|
+
}
|
|
297
|
+
async function V(e, t) {
|
|
298
|
+
let n = await L(e.path, t);
|
|
299
|
+
if (n.kind === "absent") return n;
|
|
300
|
+
if (n.kind !== "content") return {
|
|
301
|
+
kind: n.kind,
|
|
302
|
+
path: e.path,
|
|
303
|
+
reason: n.reason
|
|
304
|
+
};
|
|
305
|
+
let r;
|
|
306
|
+
try {
|
|
307
|
+
r = JSON.parse(n.content);
|
|
308
|
+
} catch (t) {
|
|
309
|
+
return {
|
|
310
|
+
kind: "invalid",
|
|
311
|
+
path: e.path,
|
|
312
|
+
reason: A(t)
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
let i = r;
|
|
316
|
+
if (e.key) {
|
|
317
|
+
if (!O(r)) return {
|
|
318
|
+
kind: "invalid",
|
|
319
|
+
path: e.path,
|
|
320
|
+
reason: "expected a JSON object"
|
|
321
|
+
};
|
|
322
|
+
if (!Object.hasOwn(r, e.key)) return {
|
|
323
|
+
kind: "keyless",
|
|
324
|
+
path: e.path,
|
|
325
|
+
key: e.key
|
|
326
|
+
};
|
|
327
|
+
i = r[e.key];
|
|
328
|
+
}
|
|
329
|
+
if (!O(i)) {
|
|
330
|
+
let t = e.key ? `the "${e.key}" key` : "the file";
|
|
331
|
+
return {
|
|
332
|
+
kind: "invalid",
|
|
333
|
+
path: e.path,
|
|
334
|
+
reason: `expected ${t} to be an object`
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
return {
|
|
338
|
+
kind: "found",
|
|
339
|
+
config: B(i, e.path)
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
function H(e) {
|
|
343
|
+
let t = T.find((t) => t.path === P(e));
|
|
344
|
+
return t ? {
|
|
345
|
+
...t,
|
|
346
|
+
path: e
|
|
347
|
+
} : { path: e };
|
|
348
|
+
}
|
|
349
|
+
function U(e, t) {
|
|
350
|
+
s(`[logan-logger] cannot read config at ${e} — no permission; using defaults instead: ${t}`);
|
|
351
|
+
}
|
|
352
|
+
async function W(e, t = {}) {
|
|
353
|
+
let n = l();
|
|
354
|
+
if (!n.capabilities.fileSystem) return {};
|
|
355
|
+
let r = t.cwd || F(n.name), i = await N(n.name, r);
|
|
356
|
+
if (e !== void 0) {
|
|
357
|
+
let t = i(e), r = await V(H(t), n.name);
|
|
358
|
+
if (r.kind === "found") return r.config;
|
|
359
|
+
if (r.kind === "absent") throw Error(`[logan-logger] config file not found: ${t}`);
|
|
360
|
+
if (r.kind === "keyless") throw Error(`[logan-logger] no "${r.key}" key in ${r.path}`);
|
|
361
|
+
if (r.kind === "denied") return U(r.path, r.reason), {};
|
|
362
|
+
throw r.kind === "unreadable" ? Error(`[logan-logger] config at ${r.path} is not a readable file: ${r.reason}`) : Error(`[logan-logger] config at ${r.path} is invalid: ${r.reason}`);
|
|
363
|
+
}
|
|
364
|
+
for (let e of T) {
|
|
365
|
+
let t = await V({
|
|
366
|
+
...e,
|
|
367
|
+
path: i(e.path)
|
|
368
|
+
}, n.name);
|
|
369
|
+
if (t.kind === "found") return t.config;
|
|
370
|
+
if (t.kind === "invalid") return s(`[logan-logger] config at ${t.path} is invalid: ${t.reason}`), {};
|
|
371
|
+
if (t.kind === "denied") return U(t.path, t.reason), {};
|
|
372
|
+
t.kind === "unreadable" && s(`[logan-logger] skipping ${t.path}: not a readable file (${t.reason})`);
|
|
373
|
+
}
|
|
374
|
+
return {};
|
|
375
|
+
}
|
|
376
|
+
//#endregion
|
|
377
|
+
export { w as a, _ as c, f as d, d as f, b as i, p as l, v as n, C as o, y as r, g as s, W as t, m as u };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./config-DpSCCiRz.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}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./config-DpSCCiRz.cjs"),t=require("./config-file-WYBC6sSB.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}});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { l as e } from "./config-CpbjY9zX.mjs";
|
|
2
|
+
import { f as t } from "./config-file-CvMv3rgc.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
|
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-DpSCCiRz.cjs"),t=require("./chunks/config-file-WYBC6sSB.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,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export { s as BrowserLogger, h as ConsoleGroupLogger, y as ConsoleTransport, i as PerformanceLogger, S as createLogger, C as createLoggerForEnvironment, x as createTransports, e as detectRuntime, a as filterSensitiveData, p as formatLevel, r as formatLogEntry, m as getDefaultConfig, g as isBrowser, v as isBun, n as isDeno, _ as isNode, l as loadConfigFromEnvironment, w as loadConfigFromFile, f as mergeConfigs, b as registerTransport, o as resetEnvironmentWarnings, d as safeStringify, c as serializeError, t as shouldColorize, u as tryParseLogLevel };
|
|
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-CpbjY9zX.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-CvMv3rgc.mjs";
|
|
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-DpSCCiRz.cjs"),t=require("./chunks/config-file-WYBC6sSB.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,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as x,
|
|
3
|
-
import { t as A } from "./chunks/config-file-37L8z8Lm.mjs";
|
|
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-CpbjY9zX.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-CvMv3rgc.mjs";
|
|
4
3
|
//#region src/index.ts
|
|
5
|
-
var j =
|
|
4
|
+
var j = w(), M = {
|
|
6
5
|
debug: (e, t) => j.debug(e, t),
|
|
7
6
|
info: (e, t) => j.info(e, t),
|
|
8
7
|
warn: (e, t) => j.warn(e, t),
|
|
9
8
|
error: (e, t) => j.error(e, t)
|
|
10
9
|
};
|
|
11
10
|
//#endregion
|
|
12
|
-
export { s as BaseLogger,
|
|
11
|
+
export { s as BaseLogger, _ as BrowserLogger, a as ConsoleGroupLogger, T as ConsoleTransport, t as LogLevel, E as LoggerFactory, o as PerformanceLogger, O as createLogger, w as createLoggerForEnvironment, A as createTransports, v as detectRuntime, m as filterSensitiveData, i as formatLevel, u as formatLogEntry, g as getDefaultConfig, S as getTransportFactory, b as isBrowser, r as isBun, y as isDeno, e as isNode, f as loadConfigFromEnvironment, k as loadConfigFromFile, M as log, x as logLevelToString, j as logger, h as mergeConfigs, C as registerTransport, l as resetEnvironmentWarnings, d as safeStringify, c as serializeError, n as shouldColorize, D as stringToLogLevel, p as tryParseLogLevel };
|
package/dist/node.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./chunks/
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./chunks/config-file-WYBC6sSB.cjs"),t=require("./chunks/file-transport-B34EGzxL.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.d.cts
CHANGED
|
@@ -3,3 +3,4 @@ export { ConsoleTransport, createTransports, registerTransport, type Transport,
|
|
|
3
3
|
export type { ILogger, LoggerConfig, LogLevel, TransportConfig } from './core/types.cjs';
|
|
4
4
|
export { FileTransport, type FileTransportOptions } from './runtime/file-transport.cjs';
|
|
5
5
|
export { createMorganStream, NodeLogger } from './runtime/node.cjs';
|
|
6
|
+
export * from './utils/config-file.cjs';
|
package/dist/node.d.mts
CHANGED
|
@@ -3,3 +3,4 @@ export { ConsoleTransport, createTransports, registerTransport, type Transport,
|
|
|
3
3
|
export type { ILogger, LoggerConfig, LogLevel, TransportConfig } from './core/types.mjs';
|
|
4
4
|
export { FileTransport, type FileTransportOptions } from './runtime/file-transport.mjs';
|
|
5
5
|
export { createMorganStream, NodeLogger } from './runtime/node.mjs';
|
|
6
|
+
export * from './utils/config-file.mjs';
|
package/dist/node.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { ConsoleTransport, createTransports, registerTransport, type Transport,
|
|
|
3
3
|
export type { ILogger, LoggerConfig, LogLevel, TransportConfig } from './core/types';
|
|
4
4
|
export { FileTransport, type FileTransportOptions } from './runtime/file-transport';
|
|
5
5
|
export { createMorganStream, NodeLogger } from './runtime/node';
|
|
6
|
+
export * from './utils/config-file';
|
package/dist/node.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { c as e,
|
|
2
|
-
import { t as
|
|
3
|
-
export {
|
|
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-CvMv3rgc.mjs";
|
|
2
|
+
import { t as c } from "./chunks/file-transport-yIPiX8TP.mjs";
|
|
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 };
|
|
@@ -1,2 +1,48 @@
|
|
|
1
1
|
import { LoggerConfig } from '../core/types.cjs';
|
|
2
|
-
|
|
2
|
+
/** Options accepted by {@link loadConfigFromFile}. */
|
|
3
|
+
export interface LoadConfigFileOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Directory the search runs in, and the base a relative `configPath` resolves
|
|
6
|
+
* against. Defaults to the process working directory, which an empty string
|
|
7
|
+
* also falls back to.
|
|
8
|
+
*
|
|
9
|
+
* The working directory is not the package root in a monorepo, under
|
|
10
|
+
* pm2/systemd, or behind `pnpm -C`, and a search rooted there silently finds
|
|
11
|
+
* nothing. Pass the directory you actually mean.
|
|
12
|
+
*/
|
|
13
|
+
cwd?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Load logger configuration from a file.
|
|
17
|
+
*
|
|
18
|
+
* Without an explicit path, searches `logan.config.json`, then `.loganrc`, then
|
|
19
|
+
* a `logan` key in `package.json`, and returns the first one present. All are
|
|
20
|
+
* parsed as JSON.
|
|
21
|
+
*
|
|
22
|
+
* A file that is present but malformed **warns naming the path** and stops the
|
|
23
|
+
* search rather than silently falling through to defaults. A path that exists
|
|
24
|
+
* but is not a readable file — a directory named `.loganrc`, say — warns and
|
|
25
|
+
* the search continues, because that is not a config file at all. A runtime
|
|
26
|
+
* that refuses permission warns once and yields defaults without throwing;
|
|
27
|
+
* a sandbox is an environment problem, not a reason to fail startup.
|
|
28
|
+
*
|
|
29
|
+
* Every warning is emitted once per distinct message, so calling this per
|
|
30
|
+
* request does not repeat it forever.
|
|
31
|
+
*
|
|
32
|
+
* This is async, and `createLogger()` is not, so file configuration is not part
|
|
33
|
+
* of the automatic precedence chain. Apply it explicitly:
|
|
34
|
+
*
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const logger = createLogger(await loadConfigFromFile());
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @param configPath - Load exactly this file, resolved against `options.cwd`.
|
|
40
|
+
* Unlike the search, a missing file here is a caller error and throws. It must
|
|
41
|
+
* not be built from untrusted input: it names a file to read, and a config file
|
|
42
|
+
* can name an absolute path for the file transport to write.
|
|
43
|
+
* @param options - Search options; see {@link LoadConfigFileOptions}
|
|
44
|
+
* @returns The configuration found, or `{}` when no candidate exists
|
|
45
|
+
* @throws When `configPath` is given and that file does not exist, carries no
|
|
46
|
+
* `logan` key (for a `package.json`), is not a readable file, or is malformed
|
|
47
|
+
*/
|
|
48
|
+
export declare function loadConfigFromFile(configPath?: string, options?: LoadConfigFileOptions): Promise<Partial<LoggerConfig>>;
|
|
@@ -1,2 +1,48 @@
|
|
|
1
1
|
import { LoggerConfig } from '../core/types.mjs';
|
|
2
|
-
|
|
2
|
+
/** Options accepted by {@link loadConfigFromFile}. */
|
|
3
|
+
export interface LoadConfigFileOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Directory the search runs in, and the base a relative `configPath` resolves
|
|
6
|
+
* against. Defaults to the process working directory, which an empty string
|
|
7
|
+
* also falls back to.
|
|
8
|
+
*
|
|
9
|
+
* The working directory is not the package root in a monorepo, under
|
|
10
|
+
* pm2/systemd, or behind `pnpm -C`, and a search rooted there silently finds
|
|
11
|
+
* nothing. Pass the directory you actually mean.
|
|
12
|
+
*/
|
|
13
|
+
cwd?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Load logger configuration from a file.
|
|
17
|
+
*
|
|
18
|
+
* Without an explicit path, searches `logan.config.json`, then `.loganrc`, then
|
|
19
|
+
* a `logan` key in `package.json`, and returns the first one present. All are
|
|
20
|
+
* parsed as JSON.
|
|
21
|
+
*
|
|
22
|
+
* A file that is present but malformed **warns naming the path** and stops the
|
|
23
|
+
* search rather than silently falling through to defaults. A path that exists
|
|
24
|
+
* but is not a readable file — a directory named `.loganrc`, say — warns and
|
|
25
|
+
* the search continues, because that is not a config file at all. A runtime
|
|
26
|
+
* that refuses permission warns once and yields defaults without throwing;
|
|
27
|
+
* a sandbox is an environment problem, not a reason to fail startup.
|
|
28
|
+
*
|
|
29
|
+
* Every warning is emitted once per distinct message, so calling this per
|
|
30
|
+
* request does not repeat it forever.
|
|
31
|
+
*
|
|
32
|
+
* This is async, and `createLogger()` is not, so file configuration is not part
|
|
33
|
+
* of the automatic precedence chain. Apply it explicitly:
|
|
34
|
+
*
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const logger = createLogger(await loadConfigFromFile());
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @param configPath - Load exactly this file, resolved against `options.cwd`.
|
|
40
|
+
* Unlike the search, a missing file here is a caller error and throws. It must
|
|
41
|
+
* not be built from untrusted input: it names a file to read, and a config file
|
|
42
|
+
* can name an absolute path for the file transport to write.
|
|
43
|
+
* @param options - Search options; see {@link LoadConfigFileOptions}
|
|
44
|
+
* @returns The configuration found, or `{}` when no candidate exists
|
|
45
|
+
* @throws When `configPath` is given and that file does not exist, carries no
|
|
46
|
+
* `logan` key (for a `package.json`), is not a readable file, or is malformed
|
|
47
|
+
*/
|
|
48
|
+
export declare function loadConfigFromFile(configPath?: string, options?: LoadConfigFileOptions): Promise<Partial<LoggerConfig>>;
|
|
@@ -1,2 +1,48 @@
|
|
|
1
1
|
import { LoggerConfig } from '../core/types';
|
|
2
|
-
|
|
2
|
+
/** Options accepted by {@link loadConfigFromFile}. */
|
|
3
|
+
export interface LoadConfigFileOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Directory the search runs in, and the base a relative `configPath` resolves
|
|
6
|
+
* against. Defaults to the process working directory, which an empty string
|
|
7
|
+
* also falls back to.
|
|
8
|
+
*
|
|
9
|
+
* The working directory is not the package root in a monorepo, under
|
|
10
|
+
* pm2/systemd, or behind `pnpm -C`, and a search rooted there silently finds
|
|
11
|
+
* nothing. Pass the directory you actually mean.
|
|
12
|
+
*/
|
|
13
|
+
cwd?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Load logger configuration from a file.
|
|
17
|
+
*
|
|
18
|
+
* Without an explicit path, searches `logan.config.json`, then `.loganrc`, then
|
|
19
|
+
* a `logan` key in `package.json`, and returns the first one present. All are
|
|
20
|
+
* parsed as JSON.
|
|
21
|
+
*
|
|
22
|
+
* A file that is present but malformed **warns naming the path** and stops the
|
|
23
|
+
* search rather than silently falling through to defaults. A path that exists
|
|
24
|
+
* but is not a readable file — a directory named `.loganrc`, say — warns and
|
|
25
|
+
* the search continues, because that is not a config file at all. A runtime
|
|
26
|
+
* that refuses permission warns once and yields defaults without throwing;
|
|
27
|
+
* a sandbox is an environment problem, not a reason to fail startup.
|
|
28
|
+
*
|
|
29
|
+
* Every warning is emitted once per distinct message, so calling this per
|
|
30
|
+
* request does not repeat it forever.
|
|
31
|
+
*
|
|
32
|
+
* This is async, and `createLogger()` is not, so file configuration is not part
|
|
33
|
+
* of the automatic precedence chain. Apply it explicitly:
|
|
34
|
+
*
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const logger = createLogger(await loadConfigFromFile());
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @param configPath - Load exactly this file, resolved against `options.cwd`.
|
|
40
|
+
* Unlike the search, a missing file here is a caller error and throws. It must
|
|
41
|
+
* not be built from untrusted input: it names a file to read, and a config file
|
|
42
|
+
* can name an absolute path for the file transport to write.
|
|
43
|
+
* @param options - Search options; see {@link LoadConfigFileOptions}
|
|
44
|
+
* @returns The configuration found, or `{}` when no candidate exists
|
|
45
|
+
* @throws When `configPath` is given and that file does not exist, carries no
|
|
46
|
+
* `logan` key (for a `package.json`), is not a readable file, or is malformed
|
|
47
|
+
*/
|
|
48
|
+
export declare function loadConfigFromFile(configPath?: string, options?: LoadConfigFileOptions): Promise<Partial<LoggerConfig>>;
|
package/dist/utils/config.d.cts
CHANGED
|
@@ -12,7 +12,8 @@ import { LoggerConfig, LogLevel } from '../core/types.cjs';
|
|
|
12
12
|
export declare function shouldColorize(): boolean;
|
|
13
13
|
export declare function getDefaultConfig(): LoggerConfig;
|
|
14
14
|
/**
|
|
15
|
-
* Reset the warn-once state. Exposed for tests;
|
|
15
|
+
* Reset the warn-once state, config file warnings included. Exposed for tests;
|
|
16
|
+
* not part of the public contract.
|
|
16
17
|
*/
|
|
17
18
|
export declare function resetEnvironmentWarnings(): void;
|
|
18
19
|
/**
|
package/dist/utils/config.d.mts
CHANGED
|
@@ -12,7 +12,8 @@ import { LoggerConfig, LogLevel } from '../core/types.mjs';
|
|
|
12
12
|
export declare function shouldColorize(): boolean;
|
|
13
13
|
export declare function getDefaultConfig(): LoggerConfig;
|
|
14
14
|
/**
|
|
15
|
-
* Reset the warn-once state. Exposed for tests;
|
|
15
|
+
* Reset the warn-once state, config file warnings included. Exposed for tests;
|
|
16
|
+
* not part of the public contract.
|
|
16
17
|
*/
|
|
17
18
|
export declare function resetEnvironmentWarnings(): void;
|
|
18
19
|
/**
|
package/dist/utils/config.d.ts
CHANGED
|
@@ -12,7 +12,8 @@ import { LoggerConfig, LogLevel } from '../core/types';
|
|
|
12
12
|
export declare function shouldColorize(): boolean;
|
|
13
13
|
export declare function getDefaultConfig(): LoggerConfig;
|
|
14
14
|
/**
|
|
15
|
-
* Reset the warn-once state. Exposed for tests;
|
|
15
|
+
* Reset the warn-once state, config file warnings included. Exposed for tests;
|
|
16
|
+
* not part of the public contract.
|
|
16
17
|
*/
|
|
17
18
|
export declare function resetEnvironmentWarnings(): void;
|
|
18
19
|
/**
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Emit a diagnostic at most once per distinct message.
|
|
3
|
+
* @param message - The warning, used verbatim as the dedupe key
|
|
4
|
+
*/
|
|
5
|
+
export declare function warnOnce(message: string): void;
|
|
6
|
+
/** Forget every message emitted so far. Exposed for tests. */
|
|
7
|
+
export declare function resetWarnings(): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Emit a diagnostic at most once per distinct message.
|
|
3
|
+
* @param message - The warning, used verbatim as the dedupe key
|
|
4
|
+
*/
|
|
5
|
+
export declare function warnOnce(message: string): void;
|
|
6
|
+
/** Forget every message emitted so far. Exposed for tests. */
|
|
7
|
+
export declare function resetWarnings(): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Emit a diagnostic at most once per distinct message.
|
|
3
|
+
* @param message - The warning, used verbatim as the dedupe key
|
|
4
|
+
*/
|
|
5
|
+
export declare function warnOnce(message: string): void;
|
|
6
|
+
/** Forget every message emitted so far. Exposed for tests. */
|
|
7
|
+
export declare function resetWarnings(): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "logan-logger",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"packageManager": "pnpm@11.9.0",
|
|
5
5
|
"description": "Universal TypeScript logging library for all JavaScript runtimes",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"vitest": "^4.1.0"
|
|
123
123
|
},
|
|
124
124
|
"engines": {
|
|
125
|
-
"node": "
|
|
125
|
+
"node": ">=22.12.0"
|
|
126
126
|
},
|
|
127
127
|
"files": [
|
|
128
128
|
"dist",
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { _ as e } from "./config-Db6PTLH2.mjs";
|
|
2
|
-
//#region src/utils/config-file.ts
|
|
3
|
-
async function t(t) {
|
|
4
|
-
let a = e();
|
|
5
|
-
if (!a.capabilities.fileSystem) return {};
|
|
6
|
-
let o = t ? [t] : [
|
|
7
|
-
"logan.config.json",
|
|
8
|
-
"logan.config.js",
|
|
9
|
-
".loganrc",
|
|
10
|
-
"package.json"
|
|
11
|
-
];
|
|
12
|
-
for (let e of o) try {
|
|
13
|
-
if (a.name === "node") return await n(e);
|
|
14
|
-
if (a.name === "deno") return await r(e);
|
|
15
|
-
if (a.name === "bun") return await i(e);
|
|
16
|
-
} catch {}
|
|
17
|
-
return {};
|
|
18
|
-
}
|
|
19
|
-
async function n(e) {
|
|
20
|
-
try {
|
|
21
|
-
let t = await import("node:fs/promises"), n = await import("node:path");
|
|
22
|
-
if (e.endsWith(".json")) {
|
|
23
|
-
let n = await t.readFile(e, "utf-8"), r = JSON.parse(n);
|
|
24
|
-
return e === "package.json" ? r.logan || {} : r;
|
|
25
|
-
}
|
|
26
|
-
if (e.endsWith(".js")) {
|
|
27
|
-
let t = await import(
|
|
28
|
-
/* @vite-ignore */
|
|
29
|
-
`file://${n.resolve(e)}`
|
|
30
|
-
);
|
|
31
|
-
return t.default || t;
|
|
32
|
-
}
|
|
33
|
-
} catch {}
|
|
34
|
-
return {};
|
|
35
|
-
}
|
|
36
|
-
async function r(e) {
|
|
37
|
-
try {
|
|
38
|
-
if (e.endsWith(".json")) {
|
|
39
|
-
let t = await globalThis.Deno.readTextFile(e), n = JSON.parse(t);
|
|
40
|
-
return e === "package.json" ? n.logan || {} : n;
|
|
41
|
-
}
|
|
42
|
-
if (e.endsWith(".js")) {
|
|
43
|
-
let t = await import(
|
|
44
|
-
/* @vite-ignore */
|
|
45
|
-
`./${e}`
|
|
46
|
-
);
|
|
47
|
-
return t.default || t;
|
|
48
|
-
}
|
|
49
|
-
} catch {}
|
|
50
|
-
return {};
|
|
51
|
-
}
|
|
52
|
-
async function i(e) {
|
|
53
|
-
return n(e);
|
|
54
|
-
}
|
|
55
|
-
//#endregion
|
|
56
|
-
export { t };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./config-PPDFSral.cjs");async function t(t){let a=e._();if(!a.capabilities.fileSystem)return{};let o=t?[t]:[`logan.config.json`,`logan.config.js`,`.loganrc`,`package.json`];for(let e of o)try{if(a.name===`node`)return await n(e);if(a.name===`deno`)return await r(e);if(a.name===`bun`)return await i(e)}catch{}return{}}async function n(e){try{let t=await import(`node:fs/promises`),n=await import(`node:path`);if(e.endsWith(`.json`)){let n=await t.readFile(e,`utf-8`),r=JSON.parse(n);return e===`package.json`?r.logan||{}:r}if(e.endsWith(`.js`)){let t=await import(`file://${n.resolve(e)}`);return t.default||t}}catch{}return{}}async function r(e){try{if(e.endsWith(`.json`)){let t=await globalThis.Deno.readTextFile(e),n=JSON.parse(t);return e===`package.json`?n.logan||{}:n}if(e.endsWith(`.js`)){let t=await import(`./${e}`);return t.default||t}}catch{}return{}}async function i(e){return n(e)}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return t}});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./config-PPDFSral.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.c(t,this.format,this.formatOptions);switch(t.level){case e.g.DEBUG:console.debug(n);break;case e.g.WARN:console.warn(n);break;case e.g.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.h{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._(),i=t.mergeConfig(n);switch(r.name){case`node`:return new s(i);case`deno`:return new e.l(i);case`bun`:return new s(i);case`browser`:case`webworker`:return new e.l(i);default:return new e.l(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.g.ERROR;case`staging`:case`test`:return e.g.WARN;case`development`:case`dev`:return e.g.DEBUG;default:return e.g.INFO}}function m(t){return e.o(t)??e.g.INFO}function h(t){switch(t){case e.g.DEBUG:return`debug`;case e.g.INFO:return`info`;case e.g.WARN:return`warn`;case e.g.ERROR:return`error`;case e.g.SILENT:return`silent`;default:return`info`}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return r}});
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { _ as e, a as t, c as n, g as r, h as i, l as a, n as o, o as s, r as c } from "./config-Db6PTLH2.mjs";
|
|
2
|
-
//#region src/core/transport.ts
|
|
3
|
-
var l = /* @__PURE__ */ new Map();
|
|
4
|
-
function u(e, t) {
|
|
5
|
-
l.set(e, t);
|
|
6
|
-
}
|
|
7
|
-
function d(e) {
|
|
8
|
-
return l.get(e);
|
|
9
|
-
}
|
|
10
|
-
var f = class {
|
|
11
|
-
constructor(e = {}) {
|
|
12
|
-
this.type = "console", this.level = e.level, this.format = e.format === "json" ? "json" : "text", this.formatOptions = {
|
|
13
|
-
timestamp: e.timestamp !== !1,
|
|
14
|
-
colorize: e.colorize === !0
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
write(e) {
|
|
18
|
-
let t = n(e, this.format, this.formatOptions);
|
|
19
|
-
switch (e.level) {
|
|
20
|
-
case r.DEBUG:
|
|
21
|
-
console.debug(t);
|
|
22
|
-
break;
|
|
23
|
-
case r.WARN:
|
|
24
|
-
console.warn(t);
|
|
25
|
-
break;
|
|
26
|
-
case r.ERROR:
|
|
27
|
-
console.error(t);
|
|
28
|
-
break;
|
|
29
|
-
default: console.info(t);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
u("console", (e, t) => {
|
|
34
|
-
let n = e.options ?? {};
|
|
35
|
-
return new f({
|
|
36
|
-
format: n.format ?? t.format,
|
|
37
|
-
timestamp: n.timestamp ?? t.timestamp,
|
|
38
|
-
colorize: n.colorize ?? t.colorize,
|
|
39
|
-
level: e.level
|
|
40
|
-
});
|
|
41
|
-
}), u("custom", (e) => {
|
|
42
|
-
let t = e.options?.transport;
|
|
43
|
-
if (!t || typeof t.write != "function") throw Error("custom transport requires options.transport to be an object with a write(entry) method");
|
|
44
|
-
return e.level === void 0 ? t : {
|
|
45
|
-
type: t.type ?? "custom",
|
|
46
|
-
level: e.level,
|
|
47
|
-
write: (e) => t.write(e),
|
|
48
|
-
close: t.close ? () => t.close?.() : void 0
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
function p(e) {
|
|
52
|
-
let t = {
|
|
53
|
-
format: e.format ?? "text",
|
|
54
|
-
timestamp: e.timestamp ?? !0,
|
|
55
|
-
colorize: e.colorize ?? !1
|
|
56
|
-
};
|
|
57
|
-
if (e.transports === void 0) return [new f({
|
|
58
|
-
format: t.format,
|
|
59
|
-
timestamp: t.timestamp,
|
|
60
|
-
colorize: t.colorize
|
|
61
|
-
})];
|
|
62
|
-
let n = [];
|
|
63
|
-
for (let r of e.transports) {
|
|
64
|
-
let e = d(r.type);
|
|
65
|
-
if (!e) {
|
|
66
|
-
console.warn(`[logan-logger] ${m(r.type)}`);
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
try {
|
|
70
|
-
n.push(e(r, t));
|
|
71
|
-
} catch (e) {
|
|
72
|
-
console.warn(`[logan-logger] transport '${r.type}' failed to initialize:`, e);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return n;
|
|
76
|
-
}
|
|
77
|
-
function m(e) {
|
|
78
|
-
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`;
|
|
79
|
-
}
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region src/runtime/node.ts
|
|
82
|
-
var h = class e extends i {
|
|
83
|
-
constructor(e = {}, t) {
|
|
84
|
-
super(e), this.transports = t ?? p(e);
|
|
85
|
-
}
|
|
86
|
-
getTransports() {
|
|
87
|
-
return this.transports;
|
|
88
|
-
}
|
|
89
|
-
close() {
|
|
90
|
-
for (let e of this.transports) e.close?.();
|
|
91
|
-
}
|
|
92
|
-
writeLog(e) {
|
|
93
|
-
for (let t of this.transports) if (!(t.level !== void 0 && e.level < t.level)) try {
|
|
94
|
-
t.write(e);
|
|
95
|
-
} catch (e) {
|
|
96
|
-
console.warn(`[logan-logger] transport '${t.type}' failed to write:`, e);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
createChild() {
|
|
100
|
-
return new e(this.config, this.transports);
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
function g(e) {
|
|
104
|
-
return { write: (t) => {
|
|
105
|
-
e.info(t.trim());
|
|
106
|
-
} };
|
|
107
|
-
}
|
|
108
|
-
//#endregion
|
|
109
|
-
//#region src/core/factory.ts
|
|
110
|
-
var _ = class t {
|
|
111
|
-
static create(n = {}) {
|
|
112
|
-
let r = e(), i = t.mergeConfig(n);
|
|
113
|
-
switch (r.name) {
|
|
114
|
-
case "node": return new h(i);
|
|
115
|
-
case "deno": return new a(i);
|
|
116
|
-
case "bun": return new h(i);
|
|
117
|
-
case "browser":
|
|
118
|
-
case "webworker": return new a(i);
|
|
119
|
-
default: return new a(i);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
static createChild(e, t) {
|
|
123
|
-
return e.child(t);
|
|
124
|
-
}
|
|
125
|
-
static mergeConfig(e) {
|
|
126
|
-
let t = e.ignoreEnvironment ? {} : o();
|
|
127
|
-
return c(e, t);
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
function v(e) {
|
|
131
|
-
return _.create(e);
|
|
132
|
-
}
|
|
133
|
-
function y() {
|
|
134
|
-
let e = b();
|
|
135
|
-
return v({
|
|
136
|
-
level: x(e),
|
|
137
|
-
colorize: e !== "production" && t(),
|
|
138
|
-
timestamp: !0,
|
|
139
|
-
format: e === "production" ? "json" : "text"
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
function b() {
|
|
143
|
-
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";
|
|
144
|
-
}
|
|
145
|
-
function x(e) {
|
|
146
|
-
switch (e) {
|
|
147
|
-
case "production": return r.ERROR;
|
|
148
|
-
case "staging":
|
|
149
|
-
case "test": return r.WARN;
|
|
150
|
-
case "development":
|
|
151
|
-
case "dev": return r.DEBUG;
|
|
152
|
-
default: return r.INFO;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
function S(e) {
|
|
156
|
-
return s(e) ?? r.INFO;
|
|
157
|
-
}
|
|
158
|
-
function C(e) {
|
|
159
|
-
switch (e) {
|
|
160
|
-
case r.DEBUG: return "debug";
|
|
161
|
-
case r.INFO: return "info";
|
|
162
|
-
case r.WARN: return "warn";
|
|
163
|
-
case r.ERROR: return "error";
|
|
164
|
-
case r.SILENT: return "silent";
|
|
165
|
-
default: return "info";
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
//#endregion
|
|
169
|
-
export { S as a, f as c, u as d, C as i, p as l, v as n, h as o, y as r, g as s, _ as t, d as u };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./config-PPDFSral.cjs"),t=require("./factory-BPYE1-Nw.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.c(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.d(`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}});
|