logan-logger 2.5.1 → 2.5.2
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 +20 -20
- package/dist/bun.cjs +1 -1
- package/dist/bun.mjs +4 -4
- package/dist/chunks/{config-file-z0J0xfos.mjs → config-file-B2bCuTsh.mjs} +158 -149
- package/dist/chunks/config-file-Bi7lhPHV.cjs +1 -0
- package/dist/chunks/{file-transport-DF_YtZ1J.mjs → file-transport-DtEHuVUw.mjs} +2 -2
- package/dist/chunks/file-transport-jelqRjCs.cjs +1 -0
- package/dist/chunks/{config-DsFnr-rq.mjs → formatting-DTrgGC8g.mjs} +62 -56
- package/dist/chunks/{config-BoVokyIX.cjs → formatting-pzIQGL_7.cjs} +1 -1
- package/dist/core/types.d.cts +12 -0
- package/dist/core/types.d.mts +12 -0
- package/dist/core/types.d.ts +12 -0
- package/dist/deno.cjs +1 -1
- package/dist/deno.mjs +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +8 -8
- package/dist/node.cjs +1 -1
- package/dist/node.mjs +2 -2
- package/dist/utils/config.d.cts +87 -4
- package/dist/utils/config.d.mts +87 -4
- package/dist/utils/config.d.ts +87 -4
- package/package.json +1 -1
- package/dist/chunks/config-file-C_hoT1V-.cjs +0 -1
- package/dist/chunks/file-transport-93M9zaPy.cjs +0 -1
|
@@ -344,54 +344,27 @@ var D = class e extends f {
|
|
|
344
344
|
clearMeasures(e) {
|
|
345
345
|
typeof performance < "u" && performance.clearMeasures && performance.clearMeasures(e);
|
|
346
346
|
}
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
function A(e, t = "text", n = {}) {
|
|
351
|
-
if (t === "json") {
|
|
352
|
-
let t = {
|
|
353
|
-
timestamp: e.timestamp.toISOString(),
|
|
354
|
-
level: u[e.level].toLowerCase(),
|
|
355
|
-
message: e.message,
|
|
356
|
-
runtime: e.runtime
|
|
357
|
-
};
|
|
358
|
-
return e.metadata !== void 0 && (t.metadata = e.metadata), g(t);
|
|
359
|
-
}
|
|
360
|
-
let r = n.timestamp === !1 ? "" : `[${e.timestamp.toISOString()}] `, i = j(e.level, n.colorize === !0), a = e.metadata ? ` ${g(e.metadata)}` : "";
|
|
361
|
-
return `${r}${i}: ${e.message}${a}`;
|
|
347
|
+
}, A = /* @__PURE__ */ new Set();
|
|
348
|
+
function j(e) {
|
|
349
|
+
A.has(e) || (A.add(e), console.warn(e));
|
|
362
350
|
}
|
|
363
|
-
function
|
|
364
|
-
|
|
365
|
-
if (!t) return n;
|
|
366
|
-
let r = {
|
|
367
|
-
[u.DEBUG]: "\x1B[36m",
|
|
368
|
-
[u.INFO]: "\x1B[32m",
|
|
369
|
-
[u.WARN]: "\x1B[33m",
|
|
370
|
-
[u.ERROR]: "\x1B[31m",
|
|
371
|
-
[u.SILENT]: "\x1B[37m"
|
|
372
|
-
};
|
|
373
|
-
return `${r[e] || r[u.INFO]}${n}[0m`;
|
|
351
|
+
function M() {
|
|
352
|
+
A.clear();
|
|
374
353
|
}
|
|
375
354
|
//#endregion
|
|
376
|
-
//#region src/utils/
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
M.has(e) || (M.add(e), console.warn(e));
|
|
355
|
+
//#region src/utils/config.ts
|
|
356
|
+
function N() {
|
|
357
|
+
return e().capabilities.colorSupport ? typeof process > "u" || !process.env ? !0 : process.env.FORCE_COLOR ? process.env.FORCE_COLOR !== "0" : process.stdout?.isTTY === !0 : !1;
|
|
380
358
|
}
|
|
381
359
|
function P() {
|
|
382
|
-
|
|
360
|
+
return typeof process > "u" || !process.env ? !1 : !!process.env.NO_COLOR;
|
|
383
361
|
}
|
|
384
|
-
//#endregion
|
|
385
|
-
//#region src/utils/config.ts
|
|
386
362
|
function F() {
|
|
387
|
-
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;
|
|
388
|
-
}
|
|
389
|
-
function I() {
|
|
390
363
|
return {
|
|
391
364
|
level: u.INFO,
|
|
392
365
|
format: "text",
|
|
393
366
|
timestamp: !0,
|
|
394
|
-
colorize:
|
|
367
|
+
colorize: N(),
|
|
395
368
|
metadata: {},
|
|
396
369
|
transports: [{
|
|
397
370
|
type: "console",
|
|
@@ -399,21 +372,21 @@ function I() {
|
|
|
399
372
|
}]
|
|
400
373
|
};
|
|
401
374
|
}
|
|
402
|
-
var
|
|
375
|
+
var I = [
|
|
403
376
|
"true",
|
|
404
377
|
"1",
|
|
405
378
|
"yes",
|
|
406
379
|
"on"
|
|
407
|
-
],
|
|
380
|
+
], L = [
|
|
408
381
|
"false",
|
|
409
382
|
"0",
|
|
410
383
|
"no",
|
|
411
384
|
"off"
|
|
412
385
|
];
|
|
413
|
-
function
|
|
414
|
-
|
|
386
|
+
function R() {
|
|
387
|
+
M();
|
|
415
388
|
}
|
|
416
|
-
function
|
|
389
|
+
function z(e) {
|
|
417
390
|
switch (e.trim().toLowerCase()) {
|
|
418
391
|
case "debug": return u.DEBUG;
|
|
419
392
|
case "info": return u.INFO;
|
|
@@ -425,36 +398,36 @@ function B(e) {
|
|
|
425
398
|
default: return;
|
|
426
399
|
}
|
|
427
400
|
}
|
|
428
|
-
function
|
|
401
|
+
function B(e, t) {
|
|
429
402
|
let n = t.trim().toLowerCase();
|
|
430
|
-
if (
|
|
431
|
-
if (
|
|
432
|
-
|
|
403
|
+
if (I.includes(n)) return !0;
|
|
404
|
+
if (L.includes(n)) return !1;
|
|
405
|
+
j(`[logan-logger] ${e}="${t}" is not a recognized boolean and was ignored. Accepted: ${I.join(", ")} / ${L.join(", ")}.`);
|
|
433
406
|
}
|
|
434
|
-
function
|
|
407
|
+
function V() {
|
|
435
408
|
let e = {};
|
|
436
409
|
if (typeof process > "u" || !process.env) return e;
|
|
437
410
|
let t = process.env;
|
|
438
411
|
if (t.LOG_LEVEL !== void 0) {
|
|
439
|
-
let n =
|
|
440
|
-
n === void 0 ?
|
|
412
|
+
let n = z(t.LOG_LEVEL);
|
|
413
|
+
n === void 0 ? j(`[logan-logger] LOG_LEVEL="${t.LOG_LEVEL}" is not a recognized level and was ignored. Accepted: debug, info, warn, error, silent.`) : e.level = n;
|
|
441
414
|
}
|
|
442
415
|
if (t.LOG_FORMAT !== void 0) {
|
|
443
416
|
let n = t.LOG_FORMAT.trim().toLowerCase();
|
|
444
|
-
n === "json" || n === "text" ? e.format = n :
|
|
417
|
+
n === "json" || n === "text" ? e.format = n : j(`[logan-logger] LOG_FORMAT="${t.LOG_FORMAT}" is not a recognized format and was ignored. Accepted: json, text.`);
|
|
445
418
|
}
|
|
446
419
|
if (t.LOG_TIMESTAMP !== void 0) {
|
|
447
|
-
let n =
|
|
420
|
+
let n = B("LOG_TIMESTAMP", t.LOG_TIMESTAMP);
|
|
448
421
|
n !== void 0 && (e.timestamp = n);
|
|
449
422
|
}
|
|
450
423
|
if (t.LOG_COLOR !== void 0) {
|
|
451
|
-
let n =
|
|
452
|
-
n !== void 0 && (e.colorize = n);
|
|
424
|
+
let n = B("LOG_COLOR", t.LOG_COLOR);
|
|
425
|
+
n !== void 0 && (e.colorize = n), n === !0 && P() && j("[logan-logger] NO_COLOR is set and LOG_COLOR=true asks for color. NO_COLOR takes precedence: defaulting to no color.");
|
|
453
426
|
}
|
|
454
427
|
return e;
|
|
455
428
|
}
|
|
456
|
-
function
|
|
457
|
-
let t =
|
|
429
|
+
function H(...e) {
|
|
430
|
+
let t = F();
|
|
458
431
|
return e.reduce((e, t) => ({
|
|
459
432
|
...e,
|
|
460
433
|
...t,
|
|
@@ -465,5 +438,38 @@ function U(...e) {
|
|
|
465
438
|
transports: t.transports || e.transports
|
|
466
439
|
}), t);
|
|
467
440
|
}
|
|
441
|
+
function U(e) {
|
|
442
|
+
return P() ? {
|
|
443
|
+
...e,
|
|
444
|
+
colorize: !1
|
|
445
|
+
} : e;
|
|
446
|
+
}
|
|
447
|
+
//#endregion
|
|
448
|
+
//#region src/utils/formatting.ts
|
|
449
|
+
function W(e, t = "text", n = {}) {
|
|
450
|
+
if (t === "json") {
|
|
451
|
+
let t = {
|
|
452
|
+
timestamp: e.timestamp.toISOString(),
|
|
453
|
+
level: u[e.level].toLowerCase(),
|
|
454
|
+
message: e.message,
|
|
455
|
+
runtime: e.runtime
|
|
456
|
+
};
|
|
457
|
+
return e.metadata !== void 0 && (t.metadata = e.metadata), g(t);
|
|
458
|
+
}
|
|
459
|
+
let r = n.timestamp === !1 ? "" : `[${e.timestamp.toISOString()}] `, i = G(e.level, n.colorize === !0), a = e.metadata ? ` ${g(e.metadata)}` : "";
|
|
460
|
+
return `${r}${i}: ${e.message}${a}`;
|
|
461
|
+
}
|
|
462
|
+
function G(e, t = !1) {
|
|
463
|
+
let n = u[e].toUpperCase();
|
|
464
|
+
if (!t) return n;
|
|
465
|
+
let r = {
|
|
466
|
+
[u.DEBUG]: "\x1B[36m",
|
|
467
|
+
[u.INFO]: "\x1B[32m",
|
|
468
|
+
[u.WARN]: "\x1B[33m",
|
|
469
|
+
[u.ERROR]: "\x1B[31m",
|
|
470
|
+
[u.SILENT]: "\x1B[37m"
|
|
471
|
+
};
|
|
472
|
+
return `${r[e] || r[u.INFO]}${n}[0m`;
|
|
473
|
+
}
|
|
468
474
|
//#endregion
|
|
469
|
-
export {
|
|
475
|
+
export { o as C, s as S, E as _, V as a, e as b, R as c, j as d, D as f, g, C as h, F as i, N as l, k as m, W as n, H as o, O as p, U as r, P as s, G as t, z as u, f as v, i as w, a as x, u 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=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,n){if(typeof e!=`object`||!e)return e;let r=n.get(e);if(r!==void 0)return r;let i=Array.isArray(e)?[]:{};n.set(e,i);for(let[r,a]of Object.entries(e))i[r]=x(r,t)?`[REDACTED]`:S(a,t,n);return i}function C(e,t=_){return S(e,b(t),new Map)}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!==void 0){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!==void 0){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!==void 0){let n=V(`LOG_TIMESTAMP`,t.LOG_TIMESTAMP);n!==void 0&&(e.timestamp=n)}if(t.LOG_COLOR!==void 0){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}});
|
|
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,n){if(typeof e!=`object`||!e)return e;let r=n.get(e);if(r!==void 0)return r;let i=Array.isArray(e)?[]:{};n.set(e,i);for(let[r,a]of Object.entries(e))i[r]=x(r,t)?`[REDACTED]`:S(a,t,n);return i}function C(e,t=_){return S(e,b(t),new Map)}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)}},A=new Set;function j(e){A.has(e)||(A.add(e),console.warn(e))}function M(){A.clear()}function N(){return e().capabilities.colorSupport?typeof process>`u`||!process.env?!0:process.env.FORCE_COLOR?process.env.FORCE_COLOR!==`0`:process.stdout?.isTTY===!0:!1}function P(){return typeof process>`u`||!process.env?!1:!!process.env.NO_COLOR}function F(){return{level:u.INFO,format:`text`,timestamp:!0,colorize:N(),metadata:{},transports:[{type:`console`,options:{}}]}}var I=[`true`,`1`,`yes`,`on`],L=[`false`,`0`,`no`,`off`];function R(){M()}function z(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 B(e,t){let n=t.trim().toLowerCase();if(I.includes(n))return!0;if(L.includes(n))return!1;j(`[logan-logger] ${e}="${t}" is not a recognized boolean and was ignored. Accepted: ${I.join(`, `)} / ${L.join(`, `)}.`)}function V(){let e={};if(typeof process>`u`||!process.env)return e;let t=process.env;if(t.LOG_LEVEL!==void 0){let n=z(t.LOG_LEVEL);n===void 0?j(`[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!==void 0){let n=t.LOG_FORMAT.trim().toLowerCase();n===`json`||n===`text`?e.format=n:j(`[logan-logger] LOG_FORMAT="${t.LOG_FORMAT}" is not a recognized format and was ignored. Accepted: json, text.`)}if(t.LOG_TIMESTAMP!==void 0){let n=B(`LOG_TIMESTAMP`,t.LOG_TIMESTAMP);n!==void 0&&(e.timestamp=n)}if(t.LOG_COLOR!==void 0){let n=B(`LOG_COLOR`,t.LOG_COLOR);n!==void 0&&(e.colorize=n),n===!0&&P()&&j(`[logan-logger] NO_COLOR is set and LOG_COLOR=true asks for color. NO_COLOR takes precedence: defaulting to no color.`)}return e}function H(...e){let t=F();return e.reduce((e,t)=>({...e,...t,metadata:{...e.metadata,...t.metadata},transports:t.transports||e.transports}),t)}function U(e){return P()?{...e,colorize:!1}:e}function W(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=G(e.level,n.colorize===!0),a=e.metadata?` ${g(e.metadata)}`:``;return`${r}${i}: ${e.message}${a}`}function G(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`}Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return u}});
|
package/dist/core/types.d.cts
CHANGED
|
@@ -69,6 +69,18 @@ export interface LoggerConfig {
|
|
|
69
69
|
* operator can raise verbosity on a running service without a deploy. A
|
|
70
70
|
* library that must pin its own logging regardless of the host application's
|
|
71
71
|
* environment sets this instead.
|
|
72
|
+
*
|
|
73
|
+
* Those four variables and no others. `NO_COLOR` is unaffected: it is the end
|
|
74
|
+
* user's preference rather than the host application's setting, and it stays
|
|
75
|
+
* an override that nothing here can defeat. See SPEC §6.4.1.
|
|
76
|
+
*
|
|
77
|
+
* It does silence one diagnostic. The `NO_COLOR`/`LOG_COLOR=true`
|
|
78
|
+
* disagreement warning is emitted while reading the environment, which this
|
|
79
|
+
* flag skips, so with both variables set and this flag on, color is disabled
|
|
80
|
+
* and nothing is reported. Nothing is lost that the flag had not already
|
|
81
|
+
* discarded — `LOG_COLOR` was out of the running before `NO_COLOR` arrived,
|
|
82
|
+
* so the two never disagreed about anything that was going to be honored, and
|
|
83
|
+
* `LOG_COLOR="bogus"` goes equally unreported under this flag.
|
|
72
84
|
*/
|
|
73
85
|
ignoreEnvironment?: boolean;
|
|
74
86
|
}
|
package/dist/core/types.d.mts
CHANGED
|
@@ -69,6 +69,18 @@ export interface LoggerConfig {
|
|
|
69
69
|
* operator can raise verbosity on a running service without a deploy. A
|
|
70
70
|
* library that must pin its own logging regardless of the host application's
|
|
71
71
|
* environment sets this instead.
|
|
72
|
+
*
|
|
73
|
+
* Those four variables and no others. `NO_COLOR` is unaffected: it is the end
|
|
74
|
+
* user's preference rather than the host application's setting, and it stays
|
|
75
|
+
* an override that nothing here can defeat. See SPEC §6.4.1.
|
|
76
|
+
*
|
|
77
|
+
* It does silence one diagnostic. The `NO_COLOR`/`LOG_COLOR=true`
|
|
78
|
+
* disagreement warning is emitted while reading the environment, which this
|
|
79
|
+
* flag skips, so with both variables set and this flag on, color is disabled
|
|
80
|
+
* and nothing is reported. Nothing is lost that the flag had not already
|
|
81
|
+
* discarded — `LOG_COLOR` was out of the running before `NO_COLOR` arrived,
|
|
82
|
+
* so the two never disagreed about anything that was going to be honored, and
|
|
83
|
+
* `LOG_COLOR="bogus"` goes equally unreported under this flag.
|
|
72
84
|
*/
|
|
73
85
|
ignoreEnvironment?: boolean;
|
|
74
86
|
}
|
package/dist/core/types.d.ts
CHANGED
|
@@ -69,6 +69,18 @@ export interface LoggerConfig {
|
|
|
69
69
|
* operator can raise verbosity on a running service without a deploy. A
|
|
70
70
|
* library that must pin its own logging regardless of the host application's
|
|
71
71
|
* environment sets this instead.
|
|
72
|
+
*
|
|
73
|
+
* Those four variables and no others. `NO_COLOR` is unaffected: it is the end
|
|
74
|
+
* user's preference rather than the host application's setting, and it stays
|
|
75
|
+
* an override that nothing here can defeat. See SPEC §6.4.1.
|
|
76
|
+
*
|
|
77
|
+
* It does silence one diagnostic. The `NO_COLOR`/`LOG_COLOR=true`
|
|
78
|
+
* disagreement warning is emitted while reading the environment, which this
|
|
79
|
+
* flag skips, so with both variables set and this flag on, color is disabled
|
|
80
|
+
* and nothing is reported. Nothing is lost that the flag had not already
|
|
81
|
+
* discarded — `LOG_COLOR` was out of the running before `NO_COLOR` arrived,
|
|
82
|
+
* so the two never disagreed about anything that was going to be honored, and
|
|
83
|
+
* `LOG_COLOR="bogus"` goes equally unreported under this flag.
|
|
72
84
|
*/
|
|
73
85
|
ignoreEnvironment?: boolean;
|
|
74
86
|
}
|
package/dist/deno.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/formatting-pzIQGL_7.cjs"),t=require("./chunks/config-file-Bi7lhPHV.cjs");exports.BrowserLogger=e.f,exports.ConsoleGroupLogger=e.p,exports.ConsoleTransport=t.l,exports.PerformanceLogger=e.m,exports.applyNoColorOverride=e.r,exports.createLogger=t.r,exports.createLoggerForEnvironment=t.i,exports.createTransports=t.u,exports.detectRuntime=e.b,exports.filterSensitiveData=e.h,exports.formatLevel=e.t,exports.formatLogEntry=e.n,exports.getDefaultConfig=e.i,exports.isBrowser=e.x,exports.isBun=e.S,exports.isDeno=e.C,exports.isNode=e.w,exports.loadConfigFromEnvironment=e.a,exports.loadConfigFromFile=t.t,exports.mergeConfigs=e.o,exports.noColorRequested=e.s,exports.registerTransport=t.f,exports.resetEnvironmentWarnings=e.c,exports.safeStringify=e.g,exports.serializeError=e._,exports.shouldColorize=e.l,exports.tryParseLogLevel=e.u;
|
package/dist/deno.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as
|
|
3
|
-
export {
|
|
1
|
+
import { C as e, S as t, _ as n, a as r, b as i, c 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, s as g, t as _, u as v, w as y, x as b } from "./chunks/formatting-DTrgGC8g.mjs";
|
|
2
|
+
import { f as x, i as S, l as C, r as w, t as T, u as E } from "./chunks/config-file-B2bCuTsh.mjs";
|
|
3
|
+
export { o as BrowserLogger, m as ConsoleGroupLogger, C as ConsoleTransport, d as PerformanceLogger, h as applyNoColorOverride, w as createLogger, S as createLoggerForEnvironment, E as createTransports, i as detectRuntime, c as filterSensitiveData, _ as formatLevel, f as formatLogEntry, l as getDefaultConfig, b as isBrowser, t as isBun, e as isDeno, y as isNode, r as loadConfigFromEnvironment, T as loadConfigFromFile, p as mergeConfigs, g as noColorRequested, x as registerTransport, a as resetEnvironmentWarnings, s as safeStringify, n as serializeError, u as shouldColorize, v as tryParseLogLevel };
|
package/dist/index.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/formatting-pzIQGL_7.cjs"),t=require("./chunks/config-file-Bi7lhPHV.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.v,exports.BrowserLogger=e.f,exports.ConsoleGroupLogger=e.p,exports.ConsoleTransport=t.l,exports.LogLevel=e.y,exports.LoggerFactory=t.n,exports.PerformanceLogger=e.m,exports.applyNoColorOverride=e.r,exports.createLogger=t.r,exports.createLoggerForEnvironment=t.i,exports.createTransports=t.u,exports.detectRuntime=e.b,exports.filterSensitiveData=e.h,exports.formatLevel=e.t,exports.formatLogEntry=e.n,exports.getDefaultConfig=e.i,exports.getTransportFactory=t.d,exports.isBrowser=e.x,exports.isBun=e.S,exports.isDeno=e.C,exports.isNode=e.w,exports.loadConfigFromEnvironment=e.a,exports.loadConfigFromFile=t.t,exports.log=r,exports.logLevelToString=t.a,exports.logger=n,exports.mergeConfigs=e.o,exports.noColorRequested=e.s,exports.registerTransport=t.f,exports.resetEnvironmentWarnings=e.c,exports.safeStringify=e.g,exports.serializeError=e._,exports.shouldColorize=e.l,exports.stringToLogLevel=t.o,exports.tryParseLogLevel=e.u;
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
1
|
+
import { C as e, S as t, _ as n, a as r, b as i, c 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, s as g, t as _, u as v, v as y, w as b, x, y as S } from "./chunks/formatting-DTrgGC8g.mjs";
|
|
2
|
+
import { a as C, d as w, f as T, i as E, l as D, n as O, o as k, r as A, t as j, u as M } from "./chunks/config-file-B2bCuTsh.mjs";
|
|
3
3
|
//#region src/index.ts
|
|
4
|
-
var
|
|
5
|
-
debug: (e, t) =>
|
|
6
|
-
info: (e, t) =>
|
|
7
|
-
warn: (e, t) =>
|
|
8
|
-
error: (e, t) =>
|
|
4
|
+
var N = E(), P = {
|
|
5
|
+
debug: (e, t) => N.debug(e, t),
|
|
6
|
+
info: (e, t) => N.info(e, t),
|
|
7
|
+
warn: (e, t) => N.warn(e, t),
|
|
8
|
+
error: (e, t) => N.error(e, t)
|
|
9
9
|
};
|
|
10
10
|
//#endregion
|
|
11
|
-
export {
|
|
11
|
+
export { y as BaseLogger, o as BrowserLogger, m as ConsoleGroupLogger, D as ConsoleTransport, S as LogLevel, O as LoggerFactory, d as PerformanceLogger, h as applyNoColorOverride, A as createLogger, E as createLoggerForEnvironment, M as createTransports, i as detectRuntime, c as filterSensitiveData, _ as formatLevel, f as formatLogEntry, l as getDefaultConfig, w as getTransportFactory, x as isBrowser, t as isBun, e as isDeno, b as isNode, r as loadConfigFromEnvironment, j as loadConfigFromFile, P as log, C as logLevelToString, N as logger, p as mergeConfigs, g as noColorRequested, T as registerTransport, a as resetEnvironmentWarnings, s as safeStringify, n as serializeError, u as shouldColorize, k as stringToLogLevel, v as tryParseLogLevel };
|
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-Bi7lhPHV.cjs"),t=require("./chunks/file-transport-jelqRjCs.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-B2bCuTsh.mjs";
|
|
2
|
+
import { t as c } from "./chunks/file-transport-DtEHuVUw.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 };
|
package/dist/utils/config.d.cts
CHANGED
|
@@ -1,15 +1,44 @@
|
|
|
1
1
|
import { LoggerConfig, LogLevel } from '../core/types.cjs';
|
|
2
2
|
/**
|
|
3
|
-
* Whether colored output is appropriate
|
|
3
|
+
* Whether colored output is appropriate by default.
|
|
4
4
|
*
|
|
5
5
|
* `capabilities.colorSupport` answers whether the runtime *can* colorize.
|
|
6
6
|
* This answers whether it *should*: writing ANSI escapes into a redirected
|
|
7
7
|
* file or a log shipper is worse than writing none, so a non-TTY stdout
|
|
8
|
-
* disables color unless the caller forces it.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* disables color unless the caller forces it.
|
|
9
|
+
*
|
|
10
|
+
* This resolves the **default** only — every source in SPEC §6.2 outranks it.
|
|
11
|
+
* `NO_COLOR` is deliberately not consulted here: §6.4.1 makes it an override
|
|
12
|
+
* that beats every configuration source, so checking it at this layer would
|
|
13
|
+
* let `LOG_COLOR=true` or an explicit `colorize: true` defeat it. It is applied
|
|
14
|
+
* after the merge instead — see `noColorRequested`, `applyNoColorOverride`, and
|
|
15
|
+
* `createTransports`, which applies it again to per-transport options.
|
|
16
|
+
* @returns True when the level token should carry ANSI color by default
|
|
11
17
|
*/
|
|
12
18
|
export declare function shouldColorize(): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Whether the user has asked every program in this session not to emit color.
|
|
21
|
+
*
|
|
22
|
+
* SPEC §6.4.1. Presence is the entire signal and the value is meaningless, so
|
|
23
|
+
* `NO_COLOR=0` disables color exactly as `NO_COLOR=1` does. The value is read
|
|
24
|
+
* raw — neither trimmed nor case-folded — so a single space is a non-empty
|
|
25
|
+
* value and disables color.
|
|
26
|
+
*
|
|
27
|
+
* An empty string counts as **unset**, per no-color.org's own wording:
|
|
28
|
+
* "present and not an empty string". That is the exact opposite of the rule
|
|
29
|
+
* §6.3 imposes on `LOG_LEVEL`, `LOG_FORMAT`, `LOG_TIMESTAMP` and `LOG_COLOR`,
|
|
30
|
+
* where an empty value is *set*, matches nothing, and must warn — which is why
|
|
31
|
+
* `loadConfigFromEnvironment` below guards those with `!== undefined` rather
|
|
32
|
+
* than truthiness (#84).
|
|
33
|
+
*
|
|
34
|
+
* The two rules are opposite deliberately and **must not be reconciled**: §6.3
|
|
35
|
+
* governs variables in this library's namespace, where an empty value is a
|
|
36
|
+
* mistake worth reporting, while `NO_COLOR` is defined by a standard this
|
|
37
|
+
* library does not own and cannot revise. A truthiness test is correct here
|
|
38
|
+
* and a bug ninety lines further down.
|
|
39
|
+
* @returns True when `NO_COLOR` is set to a non-empty value
|
|
40
|
+
*/
|
|
41
|
+
export declare function noColorRequested(): boolean;
|
|
13
42
|
export declare function getDefaultConfig(): LoggerConfig;
|
|
14
43
|
/**
|
|
15
44
|
* Reset the warn-once state, config file warnings included. Exposed for tests;
|
|
@@ -31,7 +60,61 @@ export declare function tryParseLogLevel(level: string): LogLevel | undefined;
|
|
|
31
60
|
*
|
|
32
61
|
* In a browser these values exist only if the bundler inlined them at build
|
|
33
62
|
* time; otherwise this returns an empty object.
|
|
63
|
+
*
|
|
64
|
+
* **This reads the environment; it does not apply SPEC §6.4.1's `NO_COLOR`
|
|
65
|
+
* veto.** Called on its own under `NO_COLOR=1 LOG_COLOR=true` it emits the
|
|
66
|
+
* disagreement diagnostic and still returns `{ colorize: true }`: the message
|
|
67
|
+
* describes what the *resolved* configuration will do, not what this function
|
|
68
|
+
* did. `applyNoColorOverride` is what actually forces `colorize` off, and
|
|
69
|
+
* `createTransports` enforces it per transport. A caller assembling a
|
|
70
|
+
* configuration by hand from this function must apply the former, or let
|
|
71
|
+
* `createLogger()` do both.
|
|
34
72
|
* @returns The subset of configuration the environment specifies
|
|
35
73
|
*/
|
|
36
74
|
export declare function loadConfigFromEnvironment(): Partial<LoggerConfig>;
|
|
37
75
|
export declare function mergeConfigs(...configs: Partial<LoggerConfig>[]): LoggerConfig;
|
|
76
|
+
/**
|
|
77
|
+
* Apply SPEC §6.4.1's `NO_COLOR` override to an already-merged configuration.
|
|
78
|
+
*
|
|
79
|
+
* `NO_COLOR` is not another tier of §6.2's chain — it outranks all of it — so
|
|
80
|
+
* it cannot be expressed as one more argument to `mergeConfigs`, where anything
|
|
81
|
+
* later would beat it. That is precisely the bug this replaces: `shouldColorize()`
|
|
82
|
+
* consulted `NO_COLOR` at the defaults layer, so `LOG_COLOR=true` and an explicit
|
|
83
|
+
* `colorize: true` both silently defeated it.
|
|
84
|
+
*
|
|
85
|
+
* Precedence is the whole reason it is a separate step, and the only one. It is
|
|
86
|
+
* *not* that `mergeConfigs` must be kept clear of the environment: that function
|
|
87
|
+
* seeds itself with `getDefaultConfig()`, which calls `shouldColorize()`, which
|
|
88
|
+
* reads `FORCE_COLOR` and `process.stdout.isTTY`. It has always read the
|
|
89
|
+
* environment, and a purity argument here would be false.
|
|
90
|
+
*
|
|
91
|
+
* **`ignoreEnvironment` does not suppress this**, deliberately. That flag is
|
|
92
|
+
* documented as opting out of `LOG_LEVEL`, `LOG_FORMAT`, `LOG_TIMESTAMP` and
|
|
93
|
+
* `LOG_COLOR` by name, and it exists so a library is not hijacked by the *host
|
|
94
|
+
* application's* operational settings. `NO_COLOR` is a different kind of thing:
|
|
95
|
+
* the *end user's* preference, expressed to every program in their session. A
|
|
96
|
+
* library author who sets the flag for the documented reason must not silently
|
|
97
|
+
* also acquire "and ignore the user's `NO_COLOR`" — least of all because
|
|
98
|
+
* `ignoreEnvironment` is settable from a config file, which would let a file
|
|
99
|
+
* checked into a repository defeat every one of that project's users.
|
|
100
|
+
*
|
|
101
|
+
* **This is not the only place the veto is applied, and it must not be.** It
|
|
102
|
+
* rewrites the top-level `colorize` and nothing else, so a per-transport
|
|
103
|
+
* `options: { colorize: true }` sails straight past it — the console transport
|
|
104
|
+
* factory resolves `options.colorize ?? context.colorize`. `createTransports`
|
|
105
|
+
* therefore resolves `NO_COLOR` again when it builds each transport, which also
|
|
106
|
+
* covers a directly constructed `new NodeLogger(...)` that never reached this
|
|
107
|
+
* function. Between the two, no configuration source defeats `NO_COLOR`:
|
|
108
|
+
* neither `LOG_COLOR`, nor an explicit `colorize: true`, nor a config file, nor
|
|
109
|
+
* a per-transport option, nor `ignoreEnvironment`.
|
|
110
|
+
*
|
|
111
|
+
* What still does: bypassing configuration resolution entirely. `new
|
|
112
|
+
* BrowserLogger({ colorize: true })` reads `config.colorize` and consults no
|
|
113
|
+
* environment at all, so it honors neither `NO_COLOR` nor `LOG_COLOR` nor a
|
|
114
|
+
* config file. That is a property of constructing an adapter by hand rather
|
|
115
|
+
* than a hole in the veto, and `docs/configuration.md` says so where a reader
|
|
116
|
+
* meets `NO_COLOR`.
|
|
117
|
+
* @param config - The configuration after the whole precedence chain
|
|
118
|
+
* @returns The configuration with color forced off when `NO_COLOR` applies
|
|
119
|
+
*/
|
|
120
|
+
export declare function applyNoColorOverride(config: LoggerConfig): LoggerConfig;
|
package/dist/utils/config.d.mts
CHANGED
|
@@ -1,15 +1,44 @@
|
|
|
1
1
|
import { LoggerConfig, LogLevel } from '../core/types.mjs';
|
|
2
2
|
/**
|
|
3
|
-
* Whether colored output is appropriate
|
|
3
|
+
* Whether colored output is appropriate by default.
|
|
4
4
|
*
|
|
5
5
|
* `capabilities.colorSupport` answers whether the runtime *can* colorize.
|
|
6
6
|
* This answers whether it *should*: writing ANSI escapes into a redirected
|
|
7
7
|
* file or a log shipper is worse than writing none, so a non-TTY stdout
|
|
8
|
-
* disables color unless the caller forces it.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* disables color unless the caller forces it.
|
|
9
|
+
*
|
|
10
|
+
* This resolves the **default** only — every source in SPEC §6.2 outranks it.
|
|
11
|
+
* `NO_COLOR` is deliberately not consulted here: §6.4.1 makes it an override
|
|
12
|
+
* that beats every configuration source, so checking it at this layer would
|
|
13
|
+
* let `LOG_COLOR=true` or an explicit `colorize: true` defeat it. It is applied
|
|
14
|
+
* after the merge instead — see `noColorRequested`, `applyNoColorOverride`, and
|
|
15
|
+
* `createTransports`, which applies it again to per-transport options.
|
|
16
|
+
* @returns True when the level token should carry ANSI color by default
|
|
11
17
|
*/
|
|
12
18
|
export declare function shouldColorize(): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Whether the user has asked every program in this session not to emit color.
|
|
21
|
+
*
|
|
22
|
+
* SPEC §6.4.1. Presence is the entire signal and the value is meaningless, so
|
|
23
|
+
* `NO_COLOR=0` disables color exactly as `NO_COLOR=1` does. The value is read
|
|
24
|
+
* raw — neither trimmed nor case-folded — so a single space is a non-empty
|
|
25
|
+
* value and disables color.
|
|
26
|
+
*
|
|
27
|
+
* An empty string counts as **unset**, per no-color.org's own wording:
|
|
28
|
+
* "present and not an empty string". That is the exact opposite of the rule
|
|
29
|
+
* §6.3 imposes on `LOG_LEVEL`, `LOG_FORMAT`, `LOG_TIMESTAMP` and `LOG_COLOR`,
|
|
30
|
+
* where an empty value is *set*, matches nothing, and must warn — which is why
|
|
31
|
+
* `loadConfigFromEnvironment` below guards those with `!== undefined` rather
|
|
32
|
+
* than truthiness (#84).
|
|
33
|
+
*
|
|
34
|
+
* The two rules are opposite deliberately and **must not be reconciled**: §6.3
|
|
35
|
+
* governs variables in this library's namespace, where an empty value is a
|
|
36
|
+
* mistake worth reporting, while `NO_COLOR` is defined by a standard this
|
|
37
|
+
* library does not own and cannot revise. A truthiness test is correct here
|
|
38
|
+
* and a bug ninety lines further down.
|
|
39
|
+
* @returns True when `NO_COLOR` is set to a non-empty value
|
|
40
|
+
*/
|
|
41
|
+
export declare function noColorRequested(): boolean;
|
|
13
42
|
export declare function getDefaultConfig(): LoggerConfig;
|
|
14
43
|
/**
|
|
15
44
|
* Reset the warn-once state, config file warnings included. Exposed for tests;
|
|
@@ -31,7 +60,61 @@ export declare function tryParseLogLevel(level: string): LogLevel | undefined;
|
|
|
31
60
|
*
|
|
32
61
|
* In a browser these values exist only if the bundler inlined them at build
|
|
33
62
|
* time; otherwise this returns an empty object.
|
|
63
|
+
*
|
|
64
|
+
* **This reads the environment; it does not apply SPEC §6.4.1's `NO_COLOR`
|
|
65
|
+
* veto.** Called on its own under `NO_COLOR=1 LOG_COLOR=true` it emits the
|
|
66
|
+
* disagreement diagnostic and still returns `{ colorize: true }`: the message
|
|
67
|
+
* describes what the *resolved* configuration will do, not what this function
|
|
68
|
+
* did. `applyNoColorOverride` is what actually forces `colorize` off, and
|
|
69
|
+
* `createTransports` enforces it per transport. A caller assembling a
|
|
70
|
+
* configuration by hand from this function must apply the former, or let
|
|
71
|
+
* `createLogger()` do both.
|
|
34
72
|
* @returns The subset of configuration the environment specifies
|
|
35
73
|
*/
|
|
36
74
|
export declare function loadConfigFromEnvironment(): Partial<LoggerConfig>;
|
|
37
75
|
export declare function mergeConfigs(...configs: Partial<LoggerConfig>[]): LoggerConfig;
|
|
76
|
+
/**
|
|
77
|
+
* Apply SPEC §6.4.1's `NO_COLOR` override to an already-merged configuration.
|
|
78
|
+
*
|
|
79
|
+
* `NO_COLOR` is not another tier of §6.2's chain — it outranks all of it — so
|
|
80
|
+
* it cannot be expressed as one more argument to `mergeConfigs`, where anything
|
|
81
|
+
* later would beat it. That is precisely the bug this replaces: `shouldColorize()`
|
|
82
|
+
* consulted `NO_COLOR` at the defaults layer, so `LOG_COLOR=true` and an explicit
|
|
83
|
+
* `colorize: true` both silently defeated it.
|
|
84
|
+
*
|
|
85
|
+
* Precedence is the whole reason it is a separate step, and the only one. It is
|
|
86
|
+
* *not* that `mergeConfigs` must be kept clear of the environment: that function
|
|
87
|
+
* seeds itself with `getDefaultConfig()`, which calls `shouldColorize()`, which
|
|
88
|
+
* reads `FORCE_COLOR` and `process.stdout.isTTY`. It has always read the
|
|
89
|
+
* environment, and a purity argument here would be false.
|
|
90
|
+
*
|
|
91
|
+
* **`ignoreEnvironment` does not suppress this**, deliberately. That flag is
|
|
92
|
+
* documented as opting out of `LOG_LEVEL`, `LOG_FORMAT`, `LOG_TIMESTAMP` and
|
|
93
|
+
* `LOG_COLOR` by name, and it exists so a library is not hijacked by the *host
|
|
94
|
+
* application's* operational settings. `NO_COLOR` is a different kind of thing:
|
|
95
|
+
* the *end user's* preference, expressed to every program in their session. A
|
|
96
|
+
* library author who sets the flag for the documented reason must not silently
|
|
97
|
+
* also acquire "and ignore the user's `NO_COLOR`" — least of all because
|
|
98
|
+
* `ignoreEnvironment` is settable from a config file, which would let a file
|
|
99
|
+
* checked into a repository defeat every one of that project's users.
|
|
100
|
+
*
|
|
101
|
+
* **This is not the only place the veto is applied, and it must not be.** It
|
|
102
|
+
* rewrites the top-level `colorize` and nothing else, so a per-transport
|
|
103
|
+
* `options: { colorize: true }` sails straight past it — the console transport
|
|
104
|
+
* factory resolves `options.colorize ?? context.colorize`. `createTransports`
|
|
105
|
+
* therefore resolves `NO_COLOR` again when it builds each transport, which also
|
|
106
|
+
* covers a directly constructed `new NodeLogger(...)` that never reached this
|
|
107
|
+
* function. Between the two, no configuration source defeats `NO_COLOR`:
|
|
108
|
+
* neither `LOG_COLOR`, nor an explicit `colorize: true`, nor a config file, nor
|
|
109
|
+
* a per-transport option, nor `ignoreEnvironment`.
|
|
110
|
+
*
|
|
111
|
+
* What still does: bypassing configuration resolution entirely. `new
|
|
112
|
+
* BrowserLogger({ colorize: true })` reads `config.colorize` and consults no
|
|
113
|
+
* environment at all, so it honors neither `NO_COLOR` nor `LOG_COLOR` nor a
|
|
114
|
+
* config file. That is a property of constructing an adapter by hand rather
|
|
115
|
+
* than a hole in the veto, and `docs/configuration.md` says so where a reader
|
|
116
|
+
* meets `NO_COLOR`.
|
|
117
|
+
* @param config - The configuration after the whole precedence chain
|
|
118
|
+
* @returns The configuration with color forced off when `NO_COLOR` applies
|
|
119
|
+
*/
|
|
120
|
+
export declare function applyNoColorOverride(config: LoggerConfig): LoggerConfig;
|