@lskjs/log
Advanced tools
Comparing version 3.9.0 to 3.11.0
#!/usr/bin/env node | ||
"use strict";var Wt=Object.create;var v=Object.defineProperty;var At=Object.getOwnPropertyDescriptor;var Mt=Object.getOwnPropertyNames;var Ot=Object.getPrototypeOf,Pt=Object.prototype.hasOwnProperty;var o=(t,r)=>v(t,"name",{value:r,configurable:!0});var Nt=(t,r)=>{for(var e in r)v(t,e,{get:r[e],enumerable:!0})},_=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of Mt(r))!Pt.call(t,s)&&s!==e&&v(t,s,{get:()=>r[s],enumerable:!(n=At(r,s))||n.enumerable});return t},k=(t,r,e)=>(_(t,r,"default"),e&&_(e,r,"default")),m=(t,r,e)=>(e=t!=null?Wt(Ot(t)):{},_(r||!t||!t.__esModule?v(e,"default",{value:t,enumerable:!0}):e,t));var Lt=m(require("readline")),bt=m(require("split")),vt=m(require("through"));var U=require("@lskjs/algos"),c=require("@lskjs/env");function G(t=""){let r=[],e=[],n,s=(typeof t=="string"?t:"").split(/[\s,]+/);for(n=0;n<s.length;n++){if(!s[n])continue;let i=s[n].replace(/\*/g,".*?");i[0]==="-"?e.push(new RegExp(`^${i.slice(1)}$`)):r.push(new RegExp(`^${i}$`))}return{on:r,off:e}}o(G,"parseNs");var E=c.isDev||c.isClient?"pretty":"lsk",w=o(()=>{let t=(0,c.getEnvVar)("DEBUG","")||"",r=process.argv?.includes("--silent"),e=t.startsWith("lsk")||t.startsWith("*"),n=(0,c.getEnvVar)("LOG_FORMAT",(0,c.getEnvVar)("DEBUG_FORMAT",E)),{on:s,off:i}=G(t),f=(0,c.getEnvVar)("LOG_LEVEL",(0,c.getEnvVar)("DEBUG_LEVEL",r?"error":e?"trace":"debug"));return(0,U.omitNull)({format:n,level:f,on:s,off:i})},"getEnvConfig");var gt=require("@lskjs/algos");var B={start:99,log:99,fatal:60,error:50,warn:40,success:35,info:30,debug:20,trace:10},V={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},C=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],R=[["bold","white"],["bold","cyan"],["bold","green"],["white"]];var a;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(a||(a={}));var g=require("@lskjs/err");var d={};Nt(d,{default:()=>J.default,stringify:()=>S.default});k(d,require("fast-safe-stringify"));var S=m(require("fast-safe-stringify")),J=m(require("fast-safe-stringify"));var p=o((t,r=null,e=0)=>typeof t=="object"?(0,S.default)(t,r,e):String(t),"toString");var Y=o(t=>t.map(r=>(0,g.isError)(r)?(0,g.getCode)(r):null).filter(Boolean)[0],"getErrCode"),H=o(t=>t.length?t.map(r=>(0,g.isError)(r)?(0,g.getMessage)(r):p(r)).join(" "):null,"createMsg");var K=require("@lskjs/env");var h=o((t,r)=>{let e=[];return t!==null&&e.push((0,K.tryJSONparse)(t)),Object.keys(r).length&&e.push(r),e},"parseArgs");var $t={10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"},Dt={log:10,trace:10,debug:20,info:30,warn:40,error:50,fatal:60},Q=o(t=>!!(t.name&&t.hostname&&t.pid&&t.msg&&t.time),"isBunyan"),X=o(t=>{let{level:r,time:e,msg:n,hostname:s,pid:i,v:l,...f}=t;return{format:a.bunyan,meta:{level:$t[r],time:new Date(e)},args:h(n,f)}},"parseBunyan"),Z=o(t=>{let{level:r,time:e,...n}=t;return p({level:Dt[r],time:e.toISOString(),...n})},"stringifyBunyan");var Tt=["trace","debug","info","warning","error","fatal","panic"],zt={trace:"trace",debug:"debug",info:"info",warning:"warn",error:"error",fatal:"fatal",panic:"fatal"},Gt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"},F=o(t=>!!(t.msg&&Tt.includes(t.level)),"isLogrus"),j=o(t=>{let{level:r,time:e,msg:n,...s}=t;return{format:a.logrus,meta:{level:zt[r],time:new Date(e)},args:h(n,s)}},"parseLogrus"),q=o(t=>{let{level:r,time:e,...n}=t;return p({level:Gt[r],time:e.toISOString(),...n})},"stringifyLogrus");var tt=["trace","debug","info","warn","error","fatal"];var rt=o(t=>!!(tt.includes(t.level)&&t.ns),"isLsklog"),I=o(t=>!!tt.includes(t.level),"isLskLikelog"),u=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),W=o(t=>!!(u(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal"),A=o(t=>{let{level:r,time:e,msg:n,ns:s,name:i,...l}=t,f={level:r,time:e,msg:n,ns:s,name:i};if(!u(t))return{format:a.lsklogweb,meta:f,args:h(n,l)};let{reqId:kt,method:wt,host:St,ua:_t,ip:Et,url:Bt,status:Ct,length:Rt,duration:Ft,...It}=l;return{format:a.lsklog,meta:{...f,method:wt,host:St,reqId:kt,ua:_t,ip:Et,url:Bt,status:Ct,duration:Ft,length:Rt},args:h(n,It)}},"parseLsklog"),et=o(t=>{let{level:r,time:e,...n}=t;return p({level:r,time:+e,...n})},"stringifyLsklog");function Ut(t){return Q(t)?a.bunyan:rt(t)?a.lsklog:u(t)?a.lsklogweb:F(t)&&I(t)&&t?.name?a.lsklog:F(t)?a.logrus:I(t)?a.lsklog:null}o(Ut,"detectFormat");function ot(t,r,...e){let n=Y(e),s=H(e),i={code:n,...r,msg:s};return t==="bunyan"?Z(i):t==="logrus"?q(i):et(i)}o(ot,"stringify");function nt(t){let r=Ut(t);return r==="bunyan"?X(t):r==="lsklogweb"?A(t):r==="lsklog"?A(t):r==="logrus"?j(t):{format:r,meta:{},args:[t]}}o(nt,"parse");var it=require("@lskjs/colors"),lt=require("@lskjs/env"),at=m(require("pretty-bytes")),ft=m(require("pretty-time"));var O=require("@lskjs/colors");var M=o(t=>typeof t=="number"?t:Math.abs(String(t).split("").reduce((r,e)=>{let n=(r<<5)-r+e.charCodeAt(0);return n&n},0)-48),"hashCode"),st=M;function P(t,r){let e=C[st(r||"")%C.length]||[];return(0,O.colorize)(t,e)}o(P,"themeizeRandom");function x(t,r){let e=r?V[r]:[];return(0,O.colorize)(t,e)}o(x,"themeize");var Vt=(0,lt.getEnvVar)("LOG_VIEW","short"),L=o((t,r)=>String(t).padStart(r),"leftPad"),Jt=o((t,r)=>String(t).padEnd(r),"rightPad"),N=20,Yt=o((t,r=0)=>(N=Math.max(t&&t.length||0,N,r),Jt(t,N)),"prettyPath"),ct=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),Ht=o(t=>{let r=ct(t);return r||(r=t!==200?"log":null),x(L(String(t),3),r)},"prettyStatus"),Kt=o(t=>L(`#${t}`,3),"prettyReqId"),Qt=o(t=>{let r=t==="REMOVE"?"error":t==="WS"?"debug":null;return x(L(t,4),r)},"prettyMethod"),Xt=o((t,r="")=>{if(!Number.isFinite(t))return null;let e=t>=10*1e3?"error":t>=3*1e3?"warn":null,s=["m","s","ms"].includes(r)?r:"",i=Math.floor(Math.abs(t)*10**6),l=(0,ft.default)(i,s);return x(L(l,5),e)},"prettyTime"),Zt=o((t,r="")=>{if(!Number.isFinite(t))return null;let e=(0,at.default)(t,{maximumFractionDigits:1}).split(" "),n=e[1];return`${+e[0]>=100?Math.round(+e[0]):+e[0]}${r}${n}`},"prettySize"),pt=o((t,r)=>[...t,r].filter(Boolean).map(String).map(n=>P(n,n)).join(":"),"prettyNs");function jt(t){let r=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],e=r[M(t)%r.length];return P(e,String(t))}o(jt,"prettyMarker");var $=o(t=>{let r=Vt==="short"?(t[0]||"").toLowerCase():L(t,5);return r=`[${r}]`,x(r,t)},"prettyLevel"),qt=/\[[^"\]]+]/gm,ut=o((...t)=>{let r=[];return t.forEach(e=>{if(typeof e=="string"){let n=0;r.push(e.replace(qt,s=>(0,it.colorize)(s,R[n++%R.length])))}else r.push(e)}),r},"prettyContent"),tr=o(t=>ct(t.status)||W(t)?"debug":"trace","getUrlLevel"),mt=o(t=>{let r=W(t),e=tr(t);return[$(e),[jt(t.reqId),Qt(t.method)].join(""),Yt(t.url),Kt(t.reqId),r&&t.method!=="WS"?Ht(t.status):null,!r&&"\u29D7\u29D6\u29D7",r&&Xt(t.duration),r&&t.method!=="WS"?Zt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function rr(t,r){let e=0;return t.forEach((n,s)=>{s===e&&r(n)&&(e+=1)}),e}o(rr,"countInRow");function er(...t){let r=rr(t,e=>typeof e=="string");return[t.slice(0,r).join(" "),...t.slice(r)]}o(er,"concatFirstStrings");function y(t,...r){let e=t?.ns,n=t?.name,s=t?.level||"log",i=r;if(u(t))return[mt(t)];let l=(e||"").split(":").filter(Boolean).map(String),f=[$(s)];return(l.length||n)&&f.push(pt(l,n)),er(...f,...ut(...i))}o(y,"prettyFormat");function D(t,r){Array.isArray(t)||(t=[t]);for(let e=0;e<t.length;e++)if(t[e].test(r))return!0;return!1}o(D,"anyRegExps");var b=class{prefix;ns;name;format=E;level="trace";on=[];off=[];constructor(r={}){typeof r=="string"?this.setProps({name:r,...w()}):this.setProps(r)}setProps({prefix:r,ns:e,name:n,level:s,format:i,on:l=[],off:f=[]}){if(r&&(this.prefix=r),e&&(this.ns=e),l&&(this.on=l),f&&(this.off=f),n&&(this.name=n),i&&(this.format=i),s){if(!B[s])throw new Error(`Incorrect level: ${this.level}`);this.level=s}this.level||(this.level="trace"),this.level||(this.level="trace"),this.format||(this.format="lsk"),this.off||(this.off=[]),this.on||(this.on=[])}static create(r){return new this(r)}createChild(...r){let e=[this.ns,this.name].filter(Boolean).join(".");return new this.constructor(this,{colors:null,ns:e},...r)}getLevelPriority(r){return B[r]||0}canLog(r){let e=this.getLevelPriority(r),n=this.getLevelPriority(this.level);return this.ns&&D(this.off,this.ns)?!1:this.ns&&D(this.on,this.ns)?!0:e>=n}fatal(...r){this.canLog("fatal")&&this.__log("fatal",...r)}error(...r){this.canLog("error")&&this.__log("error",...r)}warn(...r){this.canLog("warn")&&this.__log("warn",...r)}debug(...r){this.canLog("debug")&&this.__log("debug",...r)}info(...r){this.canLog("info")&&this.__log("info",...r)}trace(...r){this.canLog("trace")&&this.__log("trace",...r)}log(...r){console._log?console._log(...r):console.log(...r)}__log(r,...e){let[n,...s]=e,i={name:this.name,ns:this.ns,level:r,time:new Date},l=e;if(u(n)&&(i={...i,...n},l=s),this.format==="none")return;let f=(0,gt.omitNull)(i);if(this.format==="pretty"){this.log(...y(f,...l));return}this.log(ot(this.format||"lsk",f,...l))}};o(b,"Logger");var ht=o((t={},r={})=>{let e={...typeof t=="string"?{name:t}:t,...w(),...r},n=[e.ns,e.name].filter(Boolean).join(":");return e.on?.some(s=>s.test(n))&&(e.level="trace"),e.off?.some(s=>s.test(n))&&(e.level="fatal"),new b(e)},"createLogger");var T=ht();var xt=require("@lskjs/env");var dt=require("@lskjs/algos");var or=require("logfmt"),yt=o((t,r=t)=>{try{if(typeof t!="string")return t;if(!t.trim())return r;let e=or.parse(t);return Object.keys(e).includes("")||Object.keys(e).length<2||(0,dt.count)(e,n=>n===!0)>=Object.keys(e).length/2?r:e}catch{return r}},"tryLogfmtParse");var z=o((t,r)=>{let e,n;if(typeof r=="string"&&(!e&&r.trim()&&(e=(0,xt.tryJSONparse)(r,null),e!==null&&(n="json")),!e&&r.trim()&&(e=yt(r,null),e!==null&&(n="logfmt"))),e===null&&(e=null,n="raw"),!e){t.log(...y({},r));return}if(typeof e!="object"){t.log(...y({},e));return}let{meta:s,args:i=[]}=nt(e);t.log(...y(s,...i))},"prettyRawLog");process.env.LSK_LOG_READLINE!=="0"?Lt.default.createInterface({input:process.stdin}).on("line",t=>{z(T,t)}):process.stdin.pipe((0,bt.default)()).pipe((0,vt.default)(function(t){if(!t){this.emit("data",`${t} | ||
"use strict";var Wt=Object.create;var b=Object.defineProperty;var At=Object.getOwnPropertyDescriptor;var Mt=Object.getOwnPropertyNames;var Ot=Object.getPrototypeOf,Pt=Object.prototype.hasOwnProperty;var o=(t,r)=>b(t,"name",{value:r,configurable:!0});var Nt=(t,r)=>{for(var e in r)b(t,e,{get:r[e],enumerable:!0})},_=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of Mt(r))!Pt.call(t,s)&&s!==e&&b(t,s,{get:()=>r[s],enumerable:!(n=At(r,s))||n.enumerable});return t},v=(t,r,e)=>(_(t,r,"default"),e&&_(e,r,"default")),m=(t,r,e)=>(e=t!=null?Wt(Ot(t)):{},_(r||!t||!t.__esModule?b(e,"default",{value:t,enumerable:!0}):e,t));var bt=m(require("readline")),vt=m(require("split")),kt=m(require("through"));var V=require("@lskjs/algos"),c=require("@lskjs/env");function U(t=""){let r=[],e=[],n,s=(typeof t=="string"?t:"").split(/[\s,]+/);for(n=0;n<s.length;n++){if(!s[n])continue;let i=s[n].replace(/\*/g,".*?");i[0]==="-"?e.push(new RegExp(`^${i.slice(1)}$`)):r.push(new RegExp(`^${i}$`))}return{on:r,off:e}}o(U,"parseNs");var E=c.isDev||c.isClient?"pretty":"lsk",k=o(()=>{let t=(0,c.getEnvVar)("DEBUG","")||"",r=process.argv?.includes("--silent"),e=t.startsWith("lsk")||t.startsWith("*"),n=(0,c.getEnvVar)("LOG_FORMAT",(0,c.getEnvVar)("DEBUG_FORMAT",E)),{on:s,off:i}=U(t),f=(0,c.getEnvVar)("LOG_LEVEL",(0,c.getEnvVar)("DEBUG_LEVEL",r?"error":e?"trace":"debug"));return(0,V.omitNull)({format:n,level:f,on:s,off:i})},"getEnvConfig");var ht=require("@lskjs/algos");var B={start:99,log:99,fatal:60,error:50,warn:40,success:35,info:30,debug:20,trace:10},J={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},C=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],R=[["bold","white"],["bold","cyan"],["bold","green"],["white"]];var a;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(a||(a={}));var g=require("@lskjs/err");var d={};Nt(d,{default:()=>Y.default,stringify:()=>w.default});v(d,require("fast-safe-stringify"));var w=m(require("fast-safe-stringify")),Y=m(require("fast-safe-stringify"));var p=o((t,r=null,e=0)=>typeof t=="object"?(0,w.default)(t,r,e):String(t),"toString");var H=o(t=>t.map(r=>(0,g.isError)(r)?(0,g.getCode)(r):null).filter(Boolean)[0],"getErrCode"),K=o(t=>t.length?t.map(r=>(0,g.isError)(r)?(0,g.getMessage)(r):p(r)).join(" "):null,"createMsg");var Q=require("@lskjs/env");var h=o((t,r)=>{let e=[];return t!==null&&e.push((0,Q.tryJSONparse)(t)),Object.keys(r).length&&e.push(r),e},"parseArgs");var $t={10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"},Dt={log:10,trace:10,debug:20,info:30,warn:40,error:50,fatal:60},X=o(t=>!!(t.name&&t.hostname&&t.pid&&t.msg&&t.time),"isBunyan"),Z=o(t=>{let{level:r,time:e,msg:n,hostname:s,pid:i,v:l,...f}=t;return{format:a.bunyan,meta:{level:$t[r],time:new Date(e)},args:h(n,f)}},"parseBunyan"),j=o(t=>{let{level:r,time:e,...n}=t;return p({level:Dt[r],time:e.toISOString(),...n})},"stringifyBunyan");var Tt=["trace","debug","info","warning","error","fatal","panic"],zt={trace:"trace",debug:"debug",info:"info",warning:"warn",error:"error",fatal:"fatal",panic:"fatal"},Gt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"},F=o(t=>!!(t.msg&&Tt.includes(t.level)),"isLogrus"),q=o(t=>{let{level:r,time:e,msg:n,...s}=t;return{format:a.logrus,meta:{level:zt[r],time:new Date(e)},args:h(n,s)}},"parseLogrus"),tt=o(t=>{let{level:r,time:e,...n}=t;return p({level:Gt[r],time:e.toISOString(),...n})},"stringifyLogrus");var rt=["trace","debug","info","warn","error","fatal"];var et=o(t=>!!(rt.includes(t.level)&&t.ns),"isLsklog"),I=o(t=>!!rt.includes(t.level),"isLskLikelog"),u=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),W=o(t=>!!(u(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal"),A=o(t=>{let{level:r,time:e,msg:n,ns:s,name:i,...l}=t,f={level:r,time:e,msg:n,ns:s,name:i};if(!u(t))return{format:a.lsklogweb,meta:f,args:h(n,l)};let{reqId:G,method:wt,host:St,ua:_t,ip:Et,url:Bt,status:Ct,length:Rt,duration:Ft,...It}=l;return{format:a.lsklog,meta:{...f,method:wt,host:St,reqId:G,ua:_t,ip:Et,url:Bt,status:Ct,duration:Ft,length:Rt},args:h(n,It)}},"parseLsklog"),ot=o(t=>{let{level:r,time:e,...n}=t;return p({level:r,time:+e,...n})},"stringifyLsklog");function Ut(t){return X(t)?a.bunyan:et(t)?a.lsklog:u(t)?a.lsklogweb:F(t)&&I(t)&&t?.name?a.lsklog:F(t)?a.logrus:I(t)?a.lsklog:null}o(Ut,"detectFormat");function nt(t,r,...e){let n=H(e),s=K(e),i={code:n,...r,msg:s};return t==="bunyan"?j(i):t==="logrus"?tt(i):ot(i)}o(nt,"stringify");function st(t){let r=Ut(t);return r==="bunyan"?Z(t):r==="lsklogweb"?A(t):r==="lsklog"?A(t):r==="logrus"?q(t):{format:r,meta:{},args:[t]}}o(st,"parse");var lt=require("@lskjs/colors"),at=require("@lskjs/env"),ft=m(require("pretty-bytes")),ct=m(require("pretty-time"));var O=require("@lskjs/colors");var M=o(t=>typeof t=="number"?t:Math.abs(String(t).split("").reduce((r,e)=>{let n=(r<<5)-r+e.charCodeAt(0);return n&n},0)-48),"hashCode"),it=M;function P(t,r){let e=C[it(r||"")%C.length]||[];return(0,O.colorize)(t,e)}o(P,"themeizeRandom");function x(t,r){let e=r?J[r]:[];return(0,O.colorize)(t,e)}o(x,"themeize");var Vt=(0,at.getEnvVar)("LOG_VIEW","short"),L=o((t,r)=>String(t).padStart(r),"leftPad"),Jt=o((t,r)=>String(t).padEnd(r),"rightPad"),N=20,Yt=o((t,r=0)=>(N=Math.max(t&&t.length||0,N,r),Jt(t,N)),"prettyPath"),pt=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),Ht=o(t=>{let r=pt(t);return r||(r=t!==200?"log":null),x(L(String(t),3),r)},"prettyStatus"),Kt=o(t=>L(`#${t}`,3),"prettyReqId"),Qt=o(t=>{let r=t==="REMOVE"?"error":t==="WS"?"debug":null;return x(L(t,4),r)},"prettyMethod"),Xt=o((t,r="")=>{if(!Number.isFinite(t))return null;let e=t>=10*1e3?"error":t>=3*1e3?"warn":null,s=["m","s","ms"].includes(r)?r:"",i=Math.floor(Math.abs(t)*10**6),l=(0,ct.default)(i,s);return x(L(l,5),e)},"prettyTime"),Zt=o((t,r="")=>{if(!Number.isFinite(t))return null;let e=(0,ft.default)(t,{maximumFractionDigits:1}).split(" "),n=e[1];return`${+e[0]>=100?Math.round(+e[0]):+e[0]}${r}${n}`},"prettySize"),ut=o((t,r)=>[...t,r].filter(Boolean).map(String).map(n=>P(n,n)).join(":"),"prettyNs");function jt(t){let r=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],e=r[M(t)%r.length];return P(e,String(t))}o(jt,"prettyMarker");var $=o(t=>{let r=Vt==="short"?(t[0]||"").toLowerCase():L(t,5);return r=`[${r}]`,x(r,t)},"prettyLevel"),qt=/\[[^"\]]+]/gm,mt=o((...t)=>{let r=[];return t.forEach(e=>{if(typeof e=="string"){let n=0;r.push(e.replace(qt,s=>(0,lt.colorize)(s,R[n++%R.length])))}else r.push(e)}),r},"prettyContent"),tr=o(t=>pt(t.status)||W(t)?"debug":"trace","getUrlLevel"),gt=o(t=>{let r=W(t),e=tr(t);return[$(e),[jt(t.reqId),Qt(t.method)].join(""),Yt(t.url),Kt(t.reqId),r&&t.method!=="WS"?Ht(t.status):null,!r&&"\u29D7\u29D6\u29D7",r&&Xt(t.duration),r&&t.method!=="WS"?Zt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function rr(t,r){let e=0;return t.forEach((n,s)=>{s===e&&r(n)&&(e+=1)}),e}o(rr,"countInRow");function er(...t){let r=rr(t,e=>typeof e=="string");return[t.slice(0,r).join(" "),...t.slice(r)]}o(er,"concatFirstStrings");function y(t,...r){let e=t?.ns,n=t?.name,s=t?.level||"log",i=r;if(u(t))return[gt(t)];let l=(e||"").split(":").filter(Boolean).map(String),f=[$(s)];return(l.length||n)&&f.push(ut(l,n)),er(...f,...mt(...i))}o(y,"prettyFormat");function D(t,r){Array.isArray(t)||(t=[t]);for(let e=0;e<t.length;e++)if(t[e].test(r))return!0;return!1}o(D,"anyRegExps");var S=class{static{o(this,"Logger")}prefix;ns;name;format=E;level="trace";on=[];off=[];constructor(r={}){typeof r=="string"?this.setProps({name:r,...k()}):this.setProps(r)}setProps({prefix:r,ns:e,name:n,level:s,format:i,on:l=[],off:f=[]}){if(r&&(this.prefix=r),e&&(this.ns=e),l&&(this.on=l),f&&(this.off=f),n&&(this.name=n),i&&(this.format=i),s){if(!B[s])throw new Error(`Incorrect level: ${this.level}`);this.level=s}this.level||(this.level="trace"),this.level||(this.level="trace"),this.format||(this.format="lsk"),this.off||(this.off=[]),this.on||(this.on=[])}static create(r){return new this(r)}createChild(...r){let e=[this.ns,this.name].filter(Boolean).join(".");return new this.constructor(this,{colors:null,ns:e},...r)}getLevelPriority(r){return B[r]||0}canLog(r){let e=this.getLevelPriority(r),n=this.getLevelPriority(this.level);return this.ns&&D(this.off,this.ns)?!1:this.ns&&D(this.on,this.ns)?!0:e>=n}fatal(...r){this.canLog("fatal")&&this.__log("fatal",...r)}error(...r){this.canLog("error")&&this.__log("error",...r)}warn(...r){this.canLog("warn")&&this.__log("warn",...r)}debug(...r){this.canLog("debug")&&this.__log("debug",...r)}info(...r){this.canLog("info")&&this.__log("info",...r)}trace(...r){this.canLog("trace")&&this.__log("trace",...r)}log(...r){console._log?console._log(...r):console.log(...r)}__log(r,...e){let[n,...s]=e,i={name:this.name,ns:this.ns,level:r,time:new Date},l=e;if(u(n)&&(i={...i,...n},l=s),this.format==="none")return;let f=(0,ht.omitNull)(i);if(this.format==="pretty"){this.log(...y(f,...l));return}this.log(nt(this.format||"lsk",f,...l))}};var dt=o((t={},r={})=>{let e=k(),n={...typeof t=="string"?{name:t}:t,...e,...r},s=[n.ns,n.name].filter(Boolean).join(":");return n.on?.some(i=>i.test(s))&&(n.level="trace"),n.off?.some(i=>i.test(s))&&(n.level="fatal"),new S(n)},"createLogger");var T=dt();var Lt=require("@lskjs/env");var yt=require("@lskjs/algos");var or=require("logfmt"),xt=o((t,r=t)=>{try{if(typeof t!="string")return t;if(!t.trim())return r;let e=or.parse(t);return Object.keys(e).includes("")||Object.keys(e).length<2||(0,yt.count)(e,n=>n===!0)>=Object.keys(e).length/2?r:e}catch{return r}},"tryLogfmtParse");var z=o((t,r)=>{let e,n;if(typeof r=="string"&&(!e&&r.trim()&&(e=(0,Lt.tryJSONparse)(r,null),e!==null&&(n="json")),!e&&r.trim()&&(e=xt(r,null),e!==null&&(n="logfmt"))),e===null&&(e=null,n="raw"),!e){t.log(...y({},r));return}if(typeof e!="object"){t.log(...y({},e));return}let{meta:s,args:i=[]}=st(e);t.log(...y(s,...i))},"prettyRawLog");process.env.LSK_LOG_READLINE!=="0"?bt.default.createInterface({input:process.stdin}).on("line",t=>{z(T,t)}):process.stdin.pipe((0,vt.default)()).pipe((0,kt.default)(function(t){if(!t){this.emit("data",`${t} | ||
`);return}z(T,t)})).pipe(process.stdout); | ||
//# sourceMappingURL=cli.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var st=Object.create;var d=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,ft=Object.prototype.hasOwnProperty;var o=(t,e)=>d(t,"name",{value:e,configurable:!0});var $=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},L=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of lt(e))!ft.call(t,s)&&s!==r&&d(t,s,{get:()=>e[s],enumerable:!(n=it(e,s))||n.enumerable});return t},b=(t,e,r)=>(L(t,e,"default"),r&&L(r,e,"default")),v=(t,e,r)=>(r=t!=null?st(at(t)):{},L(e||!t||!t.__esModule?d(r,"default",{value:t,enumerable:!0}):r,t)),ct=t=>L(d({},"__esModule",{value:!0}),t);var Et={};$(Et,{Logger:()=>p,default:()=>C});module.exports=ct(Et);var nt=require("@lskjs/algos");var w={start:99,log:99,fatal:60,error:50,warn:40,success:35,info:30,debug:20,trace:10},N={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},S=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],_=[["bold","white"],["bold","cyan"],["bold","green"],["white"]];var T=require("@lskjs/algos"),f=require("@lskjs/env");function O(t=""){let e=[],r=[],n,s=(typeof t=="string"?t:"").split(/[\s,]+/);for(n=0;n<s.length;n++){if(!s[n])continue;let i=s[n].replace(/\*/g,".*?");i[0]==="-"?r.push(new RegExp(`^${i.slice(1)}$`)):e.push(new RegExp(`^${i}$`))}return{on:e,off:r}}o(O,"parseNs");var B=f.isDev||f.isClient?"pretty":"lsk",E=o(()=>{let t=(0,f.getEnvVar)("DEBUG","")||"",e=process.argv?.includes("--silent"),r=t.startsWith("lsk")||t.startsWith("*"),n=(0,f.getEnvVar)("LOG_FORMAT",(0,f.getEnvVar)("DEBUG_FORMAT",B)),{on:s,off:i}=O(t),a=(0,f.getEnvVar)("LOG_LEVEL",(0,f.getEnvVar)("DEBUG_LEVEL",e?"error":r?"trace":"debug"));return(0,T.omitNull)({format:n,level:a,on:s,off:i})},"getEnvConfig");var g;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(g||(g={}));var u=require("@lskjs/err");var m={};$(m,{default:()=>z.default,stringify:()=>k.default});b(m,require("fast-safe-stringify"));var k=v(require("fast-safe-stringify")),z=v(require("fast-safe-stringify"));var c=o((t,e=null,r=0)=>typeof t=="object"?(0,k.default)(t,e,r):String(t),"toString");var D=o(t=>t.map(e=>(0,u.isError)(e)?(0,u.getCode)(e):null).filter(Boolean)[0],"getErrCode"),G=o(t=>t.length?t.map(e=>(0,u.isError)(e)?(0,u.getMessage)(e):c(e)).join(" "):null,"createMsg");var ut=require("@lskjs/env");var gt={log:10,trace:10,debug:20,info:30,warn:40,error:50,fatal:60};var V=o(t=>{let{level:e,time:r,...n}=t;return c({level:gt[e],time:r.toISOString(),...n})},"stringifyBunyan");var mt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"};var J=o(t=>{let{level:e,time:r,...n}=t;return c({level:mt[e],time:r.toISOString(),...n})},"stringifyLogrus");var h=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),F=o(t=>!!(h(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal");var Y=o(t=>{let{level:e,time:r,...n}=t;return c({level:e,time:+r,...n})},"stringifyLsklog");function H(t,e,...r){let n=D(r),s=G(r),i={code:n,...e,msg:s};return t==="bunyan"?V(i):t==="logrus"?J(i):Y(i)}o(H,"stringify");var X=require("@lskjs/colors"),Z=require("@lskjs/env"),K=v(require("pretty-bytes")),j=v(require("pretty-time"));var M=require("@lskjs/colors");var W=o(t=>typeof t=="number"?t:Math.abs(String(t).split("").reduce((e,r)=>{let n=(e<<5)-e+r.charCodeAt(0);return n&n},0)-48),"hashCode"),Q=W;function R(t,e){let r=S[Q(e||"")%S.length]||[];return(0,M.colorize)(t,r)}o(R,"themeizeRandom");function x(t,e){let r=e?N[e]:[];return(0,M.colorize)(t,r)}o(x,"themeize");var pt=(0,Z.getEnvVar)("LOG_VIEW","short"),y=o((t,e)=>String(t).padStart(e),"leftPad"),ht=o((t,e)=>String(t).padEnd(e),"rightPad"),A=20,dt=o((t,e=0)=>(A=Math.max(t&&t.length||0,A,e),ht(t,A)),"prettyPath"),q=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),xt=o(t=>{let e=q(t);return e||(e=t!==200?"log":null),x(y(String(t),3),e)},"prettyStatus"),yt=o(t=>y(`#${t}`,3),"prettyReqId"),Lt=o(t=>{let e=t==="REMOVE"?"error":t==="WS"?"debug":null;return x(y(t,4),e)},"prettyMethod"),bt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=t>=10*1e3?"error":t>=3*1e3?"warn":null,s=["m","s","ms"].includes(e)?e:"",i=Math.floor(Math.abs(t)*10**6),l=(0,j.default)(i,s);return x(y(l,5),r)},"prettyTime"),vt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=(0,K.default)(t,{maximumFractionDigits:1}).split(" "),n=r[1];return`${+r[0]>=100?Math.round(+r[0]):+r[0]}${e}${n}`},"prettySize"),tt=o((t,e)=>[...t,e].filter(Boolean).map(String).map(n=>R(n,n)).join(":"),"prettyNs");function kt(t){let e=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],r=e[W(t)%e.length];return R(r,String(t))}o(kt,"prettyMarker");var I=o(t=>{let e=pt==="short"?(t[0]||"").toLowerCase():y(t,5);return e=`[${e}]`,x(e,t)},"prettyLevel"),wt=/\[[^"\]]+]/gm,et=o((...t)=>{let e=[];return t.forEach(r=>{if(typeof r=="string"){let n=0;e.push(r.replace(wt,s=>(0,X.colorize)(s,_[n++%_.length])))}else e.push(r)}),e},"prettyContent"),St=o(t=>q(t.status)||F(t)?"debug":"trace","getUrlLevel"),rt=o(t=>{let e=F(t),r=St(t);return[I(r),[kt(t.reqId),Lt(t.method)].join(""),dt(t.url),yt(t.reqId),e&&t.method!=="WS"?xt(t.status):null,!e&&"\u29D7\u29D6\u29D7",e&&bt(t.duration),e&&t.method!=="WS"?vt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function _t(t,e){let r=0;return t.forEach((n,s)=>{s===r&&e(n)&&(r+=1)}),r}o(_t,"countInRow");function Bt(...t){let e=_t(t,r=>typeof r=="string");return[t.slice(0,e).join(" "),...t.slice(e)]}o(Bt,"concatFirstStrings");function ot(t,...e){let r=t?.ns,n=t?.name,s=t?.level||"log",i=e;if(h(t))return[rt(t)];let l=(r||"").split(":").filter(Boolean).map(String),a=[I(s)];return(l.length||n)&&a.push(tt(l,n)),Bt(...a,...et(...i))}o(ot,"prettyFormat");function P(t,e){Array.isArray(t)||(t=[t]);for(let r=0;r<t.length;r++)if(t[r].test(e))return!0;return!1}o(P,"anyRegExps");var p=class{prefix;ns;name;format=B;level="trace";on=[];off=[];constructor(e={}){typeof e=="string"?this.setProps({name:e,...E()}):this.setProps(e)}setProps({prefix:e,ns:r,name:n,level:s,format:i,on:l=[],off:a=[]}){if(e&&(this.prefix=e),r&&(this.ns=r),l&&(this.on=l),a&&(this.off=a),n&&(this.name=n),i&&(this.format=i),s){if(!w[s])throw new Error(`Incorrect level: ${this.level}`);this.level=s}this.level||(this.level="trace"),this.level||(this.level="trace"),this.format||(this.format="lsk"),this.off||(this.off=[]),this.on||(this.on=[])}static create(e){return new this(e)}createChild(...e){let r=[this.ns,this.name].filter(Boolean).join(".");return new this.constructor(this,{colors:null,ns:r},...e)}getLevelPriority(e){return w[e]||0}canLog(e){let r=this.getLevelPriority(e),n=this.getLevelPriority(this.level);return this.ns&&P(this.off,this.ns)?!1:this.ns&&P(this.on,this.ns)?!0:r>=n}fatal(...e){this.canLog("fatal")&&this.__log("fatal",...e)}error(...e){this.canLog("error")&&this.__log("error",...e)}warn(...e){this.canLog("warn")&&this.__log("warn",...e)}debug(...e){this.canLog("debug")&&this.__log("debug",...e)}info(...e){this.canLog("info")&&this.__log("info",...e)}trace(...e){this.canLog("trace")&&this.__log("trace",...e)}log(...e){console._log?console._log(...e):console.log(...e)}__log(e,...r){let[n,...s]=r,i={name:this.name,ns:this.ns,level:e,time:new Date},l=r;if(h(n)&&(i={...i,...n},l=s),this.format==="none")return;let a=(0,nt.omitNull)(i);if(this.format==="pretty"){this.log(...ot(a,...l));return}this.log(H(this.format||"lsk",a,...l))}};o(p,"Logger");var C=p;0&&(module.exports={Logger}); | ||
"use strict";var st=Object.create;var h=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,ft=Object.prototype.hasOwnProperty;var o=(t,e)=>h(t,"name",{value:e,configurable:!0});var $=(t,e)=>{for(var r in e)h(t,r,{get:e[r],enumerable:!0})},L=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of lt(e))!ft.call(t,s)&&s!==r&&h(t,s,{get:()=>e[s],enumerable:!(n=it(e,s))||n.enumerable});return t},b=(t,e,r)=>(L(t,e,"default"),r&&L(r,e,"default")),v=(t,e,r)=>(r=t!=null?st(at(t)):{},L(e||!t||!t.__esModule?h(r,"default",{value:t,enumerable:!0}):r,t)),ct=t=>L(h({},"__esModule",{value:!0}),t);var Et={};$(Et,{Logger:()=>d,default:()=>C});module.exports=ct(Et);var nt=require("@lskjs/algos");var w={start:99,log:99,fatal:60,error:50,warn:40,success:35,info:30,debug:20,trace:10},N={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},S=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],_=[["bold","white"],["bold","cyan"],["bold","green"],["white"]];var T=require("@lskjs/algos"),f=require("@lskjs/env");function O(t=""){let e=[],r=[],n,s=(typeof t=="string"?t:"").split(/[\s,]+/);for(n=0;n<s.length;n++){if(!s[n])continue;let i=s[n].replace(/\*/g,".*?");i[0]==="-"?r.push(new RegExp(`^${i.slice(1)}$`)):e.push(new RegExp(`^${i}$`))}return{on:e,off:r}}o(O,"parseNs");var B=f.isDev||f.isClient?"pretty":"lsk",E=o(()=>{let t=(0,f.getEnvVar)("DEBUG","")||"",e=process.argv?.includes("--silent"),r=t.startsWith("lsk")||t.startsWith("*"),n=(0,f.getEnvVar)("LOG_FORMAT",(0,f.getEnvVar)("DEBUG_FORMAT",B)),{on:s,off:i}=O(t),a=(0,f.getEnvVar)("LOG_LEVEL",(0,f.getEnvVar)("DEBUG_LEVEL",e?"error":r?"trace":"debug"));return(0,T.omitNull)({format:n,level:a,on:s,off:i})},"getEnvConfig");var g;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(g||(g={}));var u=require("@lskjs/err");var m={};$(m,{default:()=>z.default,stringify:()=>k.default});b(m,require("fast-safe-stringify"));var k=v(require("fast-safe-stringify")),z=v(require("fast-safe-stringify"));var c=o((t,e=null,r=0)=>typeof t=="object"?(0,k.default)(t,e,r):String(t),"toString");var D=o(t=>t.map(e=>(0,u.isError)(e)?(0,u.getCode)(e):null).filter(Boolean)[0],"getErrCode"),G=o(t=>t.length?t.map(e=>(0,u.isError)(e)?(0,u.getMessage)(e):c(e)).join(" "):null,"createMsg");var ut=require("@lskjs/env");var gt={log:10,trace:10,debug:20,info:30,warn:40,error:50,fatal:60};var V=o(t=>{let{level:e,time:r,...n}=t;return c({level:gt[e],time:r.toISOString(),...n})},"stringifyBunyan");var mt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"};var J=o(t=>{let{level:e,time:r,...n}=t;return c({level:mt[e],time:r.toISOString(),...n})},"stringifyLogrus");var p=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),F=o(t=>!!(p(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal");var Y=o(t=>{let{level:e,time:r,...n}=t;return c({level:e,time:+r,...n})},"stringifyLsklog");function H(t,e,...r){let n=D(r),s=G(r),i={code:n,...e,msg:s};return t==="bunyan"?V(i):t==="logrus"?J(i):Y(i)}o(H,"stringify");var X=require("@lskjs/colors"),Z=require("@lskjs/env"),K=v(require("pretty-bytes")),j=v(require("pretty-time"));var M=require("@lskjs/colors");var W=o(t=>typeof t=="number"?t:Math.abs(String(t).split("").reduce((e,r)=>{let n=(e<<5)-e+r.charCodeAt(0);return n&n},0)-48),"hashCode"),Q=W;function R(t,e){let r=S[Q(e||"")%S.length]||[];return(0,M.colorize)(t,r)}o(R,"themeizeRandom");function x(t,e){let r=e?N[e]:[];return(0,M.colorize)(t,r)}o(x,"themeize");var pt=(0,Z.getEnvVar)("LOG_VIEW","short"),y=o((t,e)=>String(t).padStart(e),"leftPad"),ht=o((t,e)=>String(t).padEnd(e),"rightPad"),A=20,dt=o((t,e=0)=>(A=Math.max(t&&t.length||0,A,e),ht(t,A)),"prettyPath"),q=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),xt=o(t=>{let e=q(t);return e||(e=t!==200?"log":null),x(y(String(t),3),e)},"prettyStatus"),yt=o(t=>y(`#${t}`,3),"prettyReqId"),Lt=o(t=>{let e=t==="REMOVE"?"error":t==="WS"?"debug":null;return x(y(t,4),e)},"prettyMethod"),bt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=t>=10*1e3?"error":t>=3*1e3?"warn":null,s=["m","s","ms"].includes(e)?e:"",i=Math.floor(Math.abs(t)*10**6),l=(0,j.default)(i,s);return x(y(l,5),r)},"prettyTime"),vt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=(0,K.default)(t,{maximumFractionDigits:1}).split(" "),n=r[1];return`${+r[0]>=100?Math.round(+r[0]):+r[0]}${e}${n}`},"prettySize"),tt=o((t,e)=>[...t,e].filter(Boolean).map(String).map(n=>R(n,n)).join(":"),"prettyNs");function kt(t){let e=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],r=e[W(t)%e.length];return R(r,String(t))}o(kt,"prettyMarker");var I=o(t=>{let e=pt==="short"?(t[0]||"").toLowerCase():y(t,5);return e=`[${e}]`,x(e,t)},"prettyLevel"),wt=/\[[^"\]]+]/gm,et=o((...t)=>{let e=[];return t.forEach(r=>{if(typeof r=="string"){let n=0;e.push(r.replace(wt,s=>(0,X.colorize)(s,_[n++%_.length])))}else e.push(r)}),e},"prettyContent"),St=o(t=>q(t.status)||F(t)?"debug":"trace","getUrlLevel"),rt=o(t=>{let e=F(t),r=St(t);return[I(r),[kt(t.reqId),Lt(t.method)].join(""),dt(t.url),yt(t.reqId),e&&t.method!=="WS"?xt(t.status):null,!e&&"\u29D7\u29D6\u29D7",e&&bt(t.duration),e&&t.method!=="WS"?vt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function _t(t,e){let r=0;return t.forEach((n,s)=>{s===r&&e(n)&&(r+=1)}),r}o(_t,"countInRow");function Bt(...t){let e=_t(t,r=>typeof r=="string");return[t.slice(0,e).join(" "),...t.slice(e)]}o(Bt,"concatFirstStrings");function ot(t,...e){let r=t?.ns,n=t?.name,s=t?.level||"log",i=e;if(p(t))return[rt(t)];let l=(r||"").split(":").filter(Boolean).map(String),a=[I(s)];return(l.length||n)&&a.push(tt(l,n)),Bt(...a,...et(...i))}o(ot,"prettyFormat");function P(t,e){Array.isArray(t)||(t=[t]);for(let r=0;r<t.length;r++)if(t[r].test(e))return!0;return!1}o(P,"anyRegExps");var d=class{static{o(this,"Logger")}prefix;ns;name;format=B;level="trace";on=[];off=[];constructor(e={}){typeof e=="string"?this.setProps({name:e,...E()}):this.setProps(e)}setProps({prefix:e,ns:r,name:n,level:s,format:i,on:l=[],off:a=[]}){if(e&&(this.prefix=e),r&&(this.ns=r),l&&(this.on=l),a&&(this.off=a),n&&(this.name=n),i&&(this.format=i),s){if(!w[s])throw new Error(`Incorrect level: ${this.level}`);this.level=s}this.level||(this.level="trace"),this.level||(this.level="trace"),this.format||(this.format="lsk"),this.off||(this.off=[]),this.on||(this.on=[])}static create(e){return new this(e)}createChild(...e){let r=[this.ns,this.name].filter(Boolean).join(".");return new this.constructor(this,{colors:null,ns:r},...e)}getLevelPriority(e){return w[e]||0}canLog(e){let r=this.getLevelPriority(e),n=this.getLevelPriority(this.level);return this.ns&&P(this.off,this.ns)?!1:this.ns&&P(this.on,this.ns)?!0:r>=n}fatal(...e){this.canLog("fatal")&&this.__log("fatal",...e)}error(...e){this.canLog("error")&&this.__log("error",...e)}warn(...e){this.canLog("warn")&&this.__log("warn",...e)}debug(...e){this.canLog("debug")&&this.__log("debug",...e)}info(...e){this.canLog("info")&&this.__log("info",...e)}trace(...e){this.canLog("trace")&&this.__log("trace",...e)}log(...e){console._log?console._log(...e):console.log(...e)}__log(e,...r){let[n,...s]=r,i={name:this.name,ns:this.ns,level:e,time:new Date},l=r;if(p(n)&&(i={...i,...n},l=s),this.format==="none")return;let a=(0,nt.omitNull)(i);if(this.format==="pretty"){this.log(...ot(a,...l));return}this.log(H(this.format||"lsk",a,...l))}},C=d;0&&(module.exports={Logger}); | ||
//# sourceMappingURL=client.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var nt=Object.create;var h=Object.defineProperty;var st=Object.getOwnPropertyDescriptor;var it=Object.getOwnPropertyNames;var lt=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty;var o=(t,e)=>h(t,"name",{value:e,configurable:!0});var P=(t,e)=>{for(var r in e)h(t,r,{get:e[r],enumerable:!0})},L=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of it(e))!at.call(t,s)&&s!==r&&h(t,s,{get:()=>e[s],enumerable:!(n=st(e,s))||n.enumerable});return t},b=(t,e,r)=>(L(t,e,"default"),r&&L(r,e,"default")),v=(t,e,r)=>(r=t!=null?nt(lt(t)):{},L(e||!t||!t.__esModule?h(r,"default",{value:t,enumerable:!0}):r,t)),ft=t=>L(h({},"__esModule",{value:!0}),t);var Et={};P(Et,{createLogger:()=>Bt});module.exports=ft(Et);var N=require("@lskjs/algos"),f=require("@lskjs/env");function $(t=""){let e=[],r=[],n,s=(typeof t=="string"?t:"").split(/[\s,]+/);for(n=0;n<s.length;n++){if(!s[n])continue;let i=s[n].replace(/\*/g,".*?");i[0]==="-"?r.push(new RegExp(`^${i.slice(1)}$`)):e.push(new RegExp(`^${i}$`))}return{on:e,off:r}}o($,"parseNs");var S=f.isDev||f.isClient?"pretty":"lsk",k=o(()=>{let t=(0,f.getEnvVar)("DEBUG","")||"",e=process.argv?.includes("--silent"),r=t.startsWith("lsk")||t.startsWith("*"),n=(0,f.getEnvVar)("LOG_FORMAT",(0,f.getEnvVar)("DEBUG_FORMAT",S)),{on:s,off:i}=$(t),a=(0,f.getEnvVar)("LOG_LEVEL",(0,f.getEnvVar)("DEBUG_LEVEL",e?"error":r?"trace":"debug"));return(0,N.omitNull)({format:n,level:a,on:s,off:i})},"getEnvConfig");var ot=require("@lskjs/algos");var _={start:99,log:99,fatal:60,error:50,warn:40,success:35,info:30,debug:20,trace:10},O={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},B=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],E=[["bold","white"],["bold","cyan"],["bold","green"],["white"]];var g;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(g||(g={}));var u=require("@lskjs/err");var m={};P(m,{default:()=>T.default,stringify:()=>w.default});b(m,require("fast-safe-stringify"));var w=v(require("fast-safe-stringify")),T=v(require("fast-safe-stringify"));var c=o((t,e=null,r=0)=>typeof t=="object"?(0,w.default)(t,e,r):String(t),"toString");var z=o(t=>t.map(e=>(0,u.isError)(e)?(0,u.getCode)(e):null).filter(Boolean)[0],"getErrCode"),D=o(t=>t.length?t.map(e=>(0,u.isError)(e)?(0,u.getMessage)(e):c(e)).join(" "):null,"createMsg");var ct=require("@lskjs/env");var ut={log:10,trace:10,debug:20,info:30,warn:40,error:50,fatal:60};var U=o(t=>{let{level:e,time:r,...n}=t;return c({level:ut[e],time:r.toISOString(),...n})},"stringifyBunyan");var gt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"};var V=o(t=>{let{level:e,time:r,...n}=t;return c({level:gt[e],time:r.toISOString(),...n})},"stringifyLogrus");var p=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),C=o(t=>!!(p(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal");var J=o(t=>{let{level:e,time:r,...n}=t;return c({level:e,time:+r,...n})},"stringifyLsklog");function Y(t,e,...r){let n=z(r),s=D(r),i={code:n,...e,msg:s};return t==="bunyan"?U(i):t==="logrus"?V(i):J(i)}o(Y,"stringify");var Q=require("@lskjs/colors"),X=require("@lskjs/env"),Z=v(require("pretty-bytes")),K=v(require("pretty-time"));var W=require("@lskjs/colors");var F=o(t=>typeof t=="number"?t:Math.abs(String(t).split("").reduce((e,r)=>{let n=(e<<5)-e+r.charCodeAt(0);return n&n},0)-48),"hashCode"),H=F;function M(t,e){let r=B[H(e||"")%B.length]||[];return(0,W.colorize)(t,r)}o(M,"themeizeRandom");function d(t,e){let r=e?O[e]:[];return(0,W.colorize)(t,r)}o(d,"themeize");var mt=(0,X.getEnvVar)("LOG_VIEW","short"),x=o((t,e)=>String(t).padStart(e),"leftPad"),pt=o((t,e)=>String(t).padEnd(e),"rightPad"),R=20,ht=o((t,e=0)=>(R=Math.max(t&&t.length||0,R,e),pt(t,R)),"prettyPath"),j=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),dt=o(t=>{let e=j(t);return e||(e=t!==200?"log":null),d(x(String(t),3),e)},"prettyStatus"),xt=o(t=>x(`#${t}`,3),"prettyReqId"),yt=o(t=>{let e=t==="REMOVE"?"error":t==="WS"?"debug":null;return d(x(t,4),e)},"prettyMethod"),Lt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=t>=10*1e3?"error":t>=3*1e3?"warn":null,s=["m","s","ms"].includes(e)?e:"",i=Math.floor(Math.abs(t)*10**6),l=(0,K.default)(i,s);return d(x(l,5),r)},"prettyTime"),bt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=(0,Z.default)(t,{maximumFractionDigits:1}).split(" "),n=r[1];return`${+r[0]>=100?Math.round(+r[0]):+r[0]}${e}${n}`},"prettySize"),q=o((t,e)=>[...t,e].filter(Boolean).map(String).map(n=>M(n,n)).join(":"),"prettyNs");function vt(t){let e=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],r=e[F(t)%e.length];return M(r,String(t))}o(vt,"prettyMarker");var A=o(t=>{let e=mt==="short"?(t[0]||"").toLowerCase():x(t,5);return e=`[${e}]`,d(e,t)},"prettyLevel"),kt=/\[[^"\]]+]/gm,tt=o((...t)=>{let e=[];return t.forEach(r=>{if(typeof r=="string"){let n=0;e.push(r.replace(kt,s=>(0,Q.colorize)(s,E[n++%E.length])))}else e.push(r)}),e},"prettyContent"),wt=o(t=>j(t.status)||C(t)?"debug":"trace","getUrlLevel"),et=o(t=>{let e=C(t),r=wt(t);return[A(r),[vt(t.reqId),yt(t.method)].join(""),ht(t.url),xt(t.reqId),e&&t.method!=="WS"?dt(t.status):null,!e&&"\u29D7\u29D6\u29D7",e&&Lt(t.duration),e&&t.method!=="WS"?bt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function St(t,e){let r=0;return t.forEach((n,s)=>{s===r&&e(n)&&(r+=1)}),r}o(St,"countInRow");function _t(...t){let e=St(t,r=>typeof r=="string");return[t.slice(0,e).join(" "),...t.slice(e)]}o(_t,"concatFirstStrings");function rt(t,...e){let r=t?.ns,n=t?.name,s=t?.level||"log",i=e;if(p(t))return[et(t)];let l=(r||"").split(":").filter(Boolean).map(String),a=[A(s)];return(l.length||n)&&a.push(q(l,n)),_t(...a,...tt(...i))}o(rt,"prettyFormat");function I(t,e){Array.isArray(t)||(t=[t]);for(let r=0;r<t.length;r++)if(t[r].test(e))return!0;return!1}o(I,"anyRegExps");var y=class{prefix;ns;name;format=S;level="trace";on=[];off=[];constructor(e={}){typeof e=="string"?this.setProps({name:e,...k()}):this.setProps(e)}setProps({prefix:e,ns:r,name:n,level:s,format:i,on:l=[],off:a=[]}){if(e&&(this.prefix=e),r&&(this.ns=r),l&&(this.on=l),a&&(this.off=a),n&&(this.name=n),i&&(this.format=i),s){if(!_[s])throw new Error(`Incorrect level: ${this.level}`);this.level=s}this.level||(this.level="trace"),this.level||(this.level="trace"),this.format||(this.format="lsk"),this.off||(this.off=[]),this.on||(this.on=[])}static create(e){return new this(e)}createChild(...e){let r=[this.ns,this.name].filter(Boolean).join(".");return new this.constructor(this,{colors:null,ns:r},...e)}getLevelPriority(e){return _[e]||0}canLog(e){let r=this.getLevelPriority(e),n=this.getLevelPriority(this.level);return this.ns&&I(this.off,this.ns)?!1:this.ns&&I(this.on,this.ns)?!0:r>=n}fatal(...e){this.canLog("fatal")&&this.__log("fatal",...e)}error(...e){this.canLog("error")&&this.__log("error",...e)}warn(...e){this.canLog("warn")&&this.__log("warn",...e)}debug(...e){this.canLog("debug")&&this.__log("debug",...e)}info(...e){this.canLog("info")&&this.__log("info",...e)}trace(...e){this.canLog("trace")&&this.__log("trace",...e)}log(...e){console._log?console._log(...e):console.log(...e)}__log(e,...r){let[n,...s]=r,i={name:this.name,ns:this.ns,level:e,time:new Date},l=r;if(p(n)&&(i={...i,...n},l=s),this.format==="none")return;let a=(0,ot.omitNull)(i);if(this.format==="pretty"){this.log(...rt(a,...l));return}this.log(Y(this.format||"lsk",a,...l))}};o(y,"Logger");var Bt=o((t={},e={})=>{let r={...typeof t=="string"?{name:t}:t,...k(),...e},n=[r.ns,r.name].filter(Boolean).join(":");return r.on?.some(s=>s.test(n))&&(r.level="trace"),r.off?.some(s=>s.test(n))&&(r.level="fatal"),new y(r)},"createLogger");0&&(module.exports={createLogger}); | ||
"use strict";var nt=Object.create;var h=Object.defineProperty;var st=Object.getOwnPropertyDescriptor;var it=Object.getOwnPropertyNames;var lt=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty;var o=(t,e)=>h(t,"name",{value:e,configurable:!0});var P=(t,e)=>{for(var r in e)h(t,r,{get:e[r],enumerable:!0})},y=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of it(e))!at.call(t,s)&&s!==r&&h(t,s,{get:()=>e[s],enumerable:!(n=st(e,s))||n.enumerable});return t},L=(t,e,r)=>(y(t,e,"default"),r&&y(r,e,"default")),b=(t,e,r)=>(r=t!=null?nt(lt(t)):{},y(e||!t||!t.__esModule?h(r,"default",{value:t,enumerable:!0}):r,t)),ft=t=>y(h({},"__esModule",{value:!0}),t);var Et={};P(Et,{createLogger:()=>Bt});module.exports=ft(Et);var N=require("@lskjs/algos"),f=require("@lskjs/env");function $(t=""){let e=[],r=[],n,s=(typeof t=="string"?t:"").split(/[\s,]+/);for(n=0;n<s.length;n++){if(!s[n])continue;let i=s[n].replace(/\*/g,".*?");i[0]==="-"?r.push(new RegExp(`^${i.slice(1)}$`)):e.push(new RegExp(`^${i}$`))}return{on:e,off:r}}o($,"parseNs");var S=f.isDev||f.isClient?"pretty":"lsk",v=o(()=>{let t=(0,f.getEnvVar)("DEBUG","")||"",e=process.argv?.includes("--silent"),r=t.startsWith("lsk")||t.startsWith("*"),n=(0,f.getEnvVar)("LOG_FORMAT",(0,f.getEnvVar)("DEBUG_FORMAT",S)),{on:s,off:i}=$(t),a=(0,f.getEnvVar)("LOG_LEVEL",(0,f.getEnvVar)("DEBUG_LEVEL",e?"error":r?"trace":"debug"));return(0,N.omitNull)({format:n,level:a,on:s,off:i})},"getEnvConfig");var ot=require("@lskjs/algos");var _={start:99,log:99,fatal:60,error:50,warn:40,success:35,info:30,debug:20,trace:10},O={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},B=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],E=[["bold","white"],["bold","cyan"],["bold","green"],["white"]];var g;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(g||(g={}));var u=require("@lskjs/err");var m={};P(m,{default:()=>T.default,stringify:()=>k.default});L(m,require("fast-safe-stringify"));var k=b(require("fast-safe-stringify")),T=b(require("fast-safe-stringify"));var c=o((t,e=null,r=0)=>typeof t=="object"?(0,k.default)(t,e,r):String(t),"toString");var z=o(t=>t.map(e=>(0,u.isError)(e)?(0,u.getCode)(e):null).filter(Boolean)[0],"getErrCode"),D=o(t=>t.length?t.map(e=>(0,u.isError)(e)?(0,u.getMessage)(e):c(e)).join(" "):null,"createMsg");var ct=require("@lskjs/env");var ut={log:10,trace:10,debug:20,info:30,warn:40,error:50,fatal:60};var U=o(t=>{let{level:e,time:r,...n}=t;return c({level:ut[e],time:r.toISOString(),...n})},"stringifyBunyan");var gt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"};var V=o(t=>{let{level:e,time:r,...n}=t;return c({level:gt[e],time:r.toISOString(),...n})},"stringifyLogrus");var p=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),C=o(t=>!!(p(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal");var J=o(t=>{let{level:e,time:r,...n}=t;return c({level:e,time:+r,...n})},"stringifyLsklog");function Y(t,e,...r){let n=z(r),s=D(r),i={code:n,...e,msg:s};return t==="bunyan"?U(i):t==="logrus"?V(i):J(i)}o(Y,"stringify");var Q=require("@lskjs/colors"),X=require("@lskjs/env"),Z=b(require("pretty-bytes")),K=b(require("pretty-time"));var W=require("@lskjs/colors");var F=o(t=>typeof t=="number"?t:Math.abs(String(t).split("").reduce((e,r)=>{let n=(e<<5)-e+r.charCodeAt(0);return n&n},0)-48),"hashCode"),H=F;function M(t,e){let r=B[H(e||"")%B.length]||[];return(0,W.colorize)(t,r)}o(M,"themeizeRandom");function d(t,e){let r=e?O[e]:[];return(0,W.colorize)(t,r)}o(d,"themeize");var mt=(0,X.getEnvVar)("LOG_VIEW","short"),x=o((t,e)=>String(t).padStart(e),"leftPad"),pt=o((t,e)=>String(t).padEnd(e),"rightPad"),R=20,ht=o((t,e=0)=>(R=Math.max(t&&t.length||0,R,e),pt(t,R)),"prettyPath"),j=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),dt=o(t=>{let e=j(t);return e||(e=t!==200?"log":null),d(x(String(t),3),e)},"prettyStatus"),xt=o(t=>x(`#${t}`,3),"prettyReqId"),yt=o(t=>{let e=t==="REMOVE"?"error":t==="WS"?"debug":null;return d(x(t,4),e)},"prettyMethod"),Lt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=t>=10*1e3?"error":t>=3*1e3?"warn":null,s=["m","s","ms"].includes(e)?e:"",i=Math.floor(Math.abs(t)*10**6),l=(0,K.default)(i,s);return d(x(l,5),r)},"prettyTime"),bt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=(0,Z.default)(t,{maximumFractionDigits:1}).split(" "),n=r[1];return`${+r[0]>=100?Math.round(+r[0]):+r[0]}${e}${n}`},"prettySize"),q=o((t,e)=>[...t,e].filter(Boolean).map(String).map(n=>M(n,n)).join(":"),"prettyNs");function vt(t){let e=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],r=e[F(t)%e.length];return M(r,String(t))}o(vt,"prettyMarker");var A=o(t=>{let e=mt==="short"?(t[0]||"").toLowerCase():x(t,5);return e=`[${e}]`,d(e,t)},"prettyLevel"),kt=/\[[^"\]]+]/gm,tt=o((...t)=>{let e=[];return t.forEach(r=>{if(typeof r=="string"){let n=0;e.push(r.replace(kt,s=>(0,Q.colorize)(s,E[n++%E.length])))}else e.push(r)}),e},"prettyContent"),wt=o(t=>j(t.status)||C(t)?"debug":"trace","getUrlLevel"),et=o(t=>{let e=C(t),r=wt(t);return[A(r),[vt(t.reqId),yt(t.method)].join(""),ht(t.url),xt(t.reqId),e&&t.method!=="WS"?dt(t.status):null,!e&&"\u29D7\u29D6\u29D7",e&&Lt(t.duration),e&&t.method!=="WS"?bt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function St(t,e){let r=0;return t.forEach((n,s)=>{s===r&&e(n)&&(r+=1)}),r}o(St,"countInRow");function _t(...t){let e=St(t,r=>typeof r=="string");return[t.slice(0,e).join(" "),...t.slice(e)]}o(_t,"concatFirstStrings");function rt(t,...e){let r=t?.ns,n=t?.name,s=t?.level||"log",i=e;if(p(t))return[et(t)];let l=(r||"").split(":").filter(Boolean).map(String),a=[A(s)];return(l.length||n)&&a.push(q(l,n)),_t(...a,...tt(...i))}o(rt,"prettyFormat");function I(t,e){Array.isArray(t)||(t=[t]);for(let r=0;r<t.length;r++)if(t[r].test(e))return!0;return!1}o(I,"anyRegExps");var w=class{static{o(this,"Logger")}prefix;ns;name;format=S;level="trace";on=[];off=[];constructor(e={}){typeof e=="string"?this.setProps({name:e,...v()}):this.setProps(e)}setProps({prefix:e,ns:r,name:n,level:s,format:i,on:l=[],off:a=[]}){if(e&&(this.prefix=e),r&&(this.ns=r),l&&(this.on=l),a&&(this.off=a),n&&(this.name=n),i&&(this.format=i),s){if(!_[s])throw new Error(`Incorrect level: ${this.level}`);this.level=s}this.level||(this.level="trace"),this.level||(this.level="trace"),this.format||(this.format="lsk"),this.off||(this.off=[]),this.on||(this.on=[])}static create(e){return new this(e)}createChild(...e){let r=[this.ns,this.name].filter(Boolean).join(".");return new this.constructor(this,{colors:null,ns:r},...e)}getLevelPriority(e){return _[e]||0}canLog(e){let r=this.getLevelPriority(e),n=this.getLevelPriority(this.level);return this.ns&&I(this.off,this.ns)?!1:this.ns&&I(this.on,this.ns)?!0:r>=n}fatal(...e){this.canLog("fatal")&&this.__log("fatal",...e)}error(...e){this.canLog("error")&&this.__log("error",...e)}warn(...e){this.canLog("warn")&&this.__log("warn",...e)}debug(...e){this.canLog("debug")&&this.__log("debug",...e)}info(...e){this.canLog("info")&&this.__log("info",...e)}trace(...e){this.canLog("trace")&&this.__log("trace",...e)}log(...e){console._log?console._log(...e):console.log(...e)}__log(e,...r){let[n,...s]=r,i={name:this.name,ns:this.ns,level:e,time:new Date},l=r;if(p(n)&&(i={...i,...n},l=s),this.format==="none")return;let a=(0,ot.omitNull)(i);if(this.format==="pretty"){this.log(...rt(a,...l));return}this.log(Y(this.format||"lsk",a,...l))}};var Bt=o((t={},e={})=>{let r=v(),n={...typeof t=="string"?{name:t}:t,...r,...e},s=[n.ns,n.name].filter(Boolean).join(":");return n.on?.some(i=>i.test(s))&&(n.level="trace"),n.off?.some(i=>i.test(s))&&(n.level="fatal"),new w(n)},"createLogger");0&&(module.exports={createLogger}); | ||
//# sourceMappingURL=createLogger.js.map |
@@ -1,6 +0,6 @@ | ||
import * as _lskjs_algos_lib_types from '@lskjs/algos/lib/types'; | ||
import { ObjectLike } from '@lskjs/algos/types'; | ||
declare const defaultFormat: string; | ||
declare const getEnvConfig: () => _lskjs_algos_lib_types.ObjectLike<string | RegExp[] | null>; | ||
declare const getEnvConfig: () => ObjectLike<string | RegExp[]>; | ||
export { getEnvConfig as default, defaultFormat, getEnvConfig }; |
@@ -1,2 +0,2 @@ | ||
"use strict";var l=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var c=(t,e)=>l(t,"name",{value:e,configurable:!0});var L=(t,e)=>{for(var n in e)l(t,n,{get:e[n],enumerable:!0})},v=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of E(e))!d.call(t,s)&&s!==n&&l(t,s,{get:()=>e[s],enumerable:!(o=m(e,s))||o.enumerable});return t};var x=t=>v(l({},"__esModule",{value:!0}),t);var G={};L(G,{default:()=>h,defaultFormat:()=>a,getEnvConfig:()=>u});module.exports=x(G);var f=require("@lskjs/algos"),r=require("@lskjs/env");function p(t=""){let e=[],n=[],o,s=(typeof t=="string"?t:"").split(/[\s,]+/);for(o=0;o<s.length;o++){if(!s[o])continue;let i=s[o].replace(/\*/g,".*?");i[0]==="-"?n.push(new RegExp(`^${i.slice(1)}$`)):e.push(new RegExp(`^${i}$`))}return{on:e,off:n}}c(p,"parseNs");var a=r.isDev||r.isClient?"pretty":"lsk",u=c(()=>{let t=(0,r.getEnvVar)("DEBUG","")||"",e=process.argv?.includes("--silent"),n=t.startsWith("lsk")||t.startsWith("*"),o=(0,r.getEnvVar)("LOG_FORMAT",(0,r.getEnvVar)("DEBUG_FORMAT",a)),{on:s,off:i}=p(t),g=(0,r.getEnvVar)("LOG_LEVEL",(0,r.getEnvVar)("DEBUG_LEVEL",e?"error":n?"trace":"debug"));return(0,f.omitNull)({format:o,level:g,on:s,off:i})},"getEnvConfig"),h=u;0&&(module.exports={defaultFormat,getEnvConfig}); | ||
"use strict";var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var l=(t,e)=>c(t,"name",{value:e,configurable:!0});var L=(t,e)=>{for(var n in e)c(t,n,{get:e[n],enumerable:!0})},v=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of E(e))!d.call(t,s)&&s!==n&&c(t,s,{get:()=>e[s],enumerable:!(o=m(e,s))||o.enumerable});return t};var x=t=>v(c({},"__esModule",{value:!0}),t);var G={};L(G,{default:()=>h,defaultFormat:()=>a,getEnvConfig:()=>u});module.exports=x(G);var f=require("@lskjs/algos"),r=require("@lskjs/env");function p(t=""){let e=[],n=[],o,s=(typeof t=="string"?t:"").split(/[\s,]+/);for(o=0;o<s.length;o++){if(!s[o])continue;let i=s[o].replace(/\*/g,".*?");i[0]==="-"?n.push(new RegExp(`^${i.slice(1)}$`)):e.push(new RegExp(`^${i}$`))}return{on:e,off:n}}l(p,"parseNs");var a=r.isDev||r.isClient?"pretty":"lsk",u=l(()=>{let t=(0,r.getEnvVar)("DEBUG","")||"",e=process.argv?.includes("--silent"),n=t.startsWith("lsk")||t.startsWith("*"),o=(0,r.getEnvVar)("LOG_FORMAT",(0,r.getEnvVar)("DEBUG_FORMAT",a)),{on:s,off:i}=p(t),g=(0,r.getEnvVar)("LOG_LEVEL",(0,r.getEnvVar)("DEBUG_LEVEL",e?"error":n?"trace":"debug"));return(0,f.omitNull)({format:o,level:g,on:s,off:i})},"getEnvConfig"),h=u;0&&(module.exports={defaultFormat,getEnvConfig}); | ||
//# sourceMappingURL=getEnvConfig.js.map |
@@ -6,2 +6,2 @@ export { ILogger, ILoggerInternalMessage, ILoggerInternalMessageFormat, ILoggerMessage, ILoggerMeta, ILoggerProps, LoggerLevelType, Theme, ThemeKey } from './types.js'; | ||
import '@lskjs/colors'; | ||
import '@lskjs/algos/lib/types'; | ||
import '@lskjs/algos/types'; |
@@ -1,2 +0,2 @@ | ||
"use strict";var st=Object.create;var d=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,ft=Object.prototype.hasOwnProperty;var o=(t,e)=>d(t,"name",{value:e,configurable:!0});var P=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},b=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of lt(e))!ft.call(t,s)&&s!==r&&d(t,s,{get:()=>e[s],enumerable:!(n=it(e,s))||n.enumerable});return t},v=(t,e,r)=>(b(t,e,"default"),r&&b(r,e,"default")),k=(t,e,r)=>(r=t!=null?st(at(t)):{},b(e||!t||!t.__esModule?d(r,"default",{value:t,enumerable:!0}):r,t)),ct=t=>b(d({},"__esModule",{value:!0}),t);var Ct={};P(Ct,{ILoggerInternalMessageFormat:()=>u,Logger:()=>m,createLogger:()=>Et,default:()=>nt,defaultFormat:()=>w,getEnvConfig:()=>x});module.exports=ct(Ct);var u;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(u||(u={}));var ot=require("@lskjs/algos");var _={start:99,log:99,fatal:60,error:50,warn:40,success:35,info:30,debug:20,trace:10},$={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},B=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],E=[["bold","white"],["bold","cyan"],["bold","green"],["white"]];var O=require("@lskjs/algos"),f=require("@lskjs/env");function N(t=""){let e=[],r=[],n,s=(typeof t=="string"?t:"").split(/[\s,]+/);for(n=0;n<s.length;n++){if(!s[n])continue;let i=s[n].replace(/\*/g,".*?");i[0]==="-"?r.push(new RegExp(`^${i.slice(1)}$`)):e.push(new RegExp(`^${i}$`))}return{on:e,off:r}}o(N,"parseNs");var w=f.isDev||f.isClient?"pretty":"lsk",x=o(()=>{let t=(0,f.getEnvVar)("DEBUG","")||"",e=process.argv?.includes("--silent"),r=t.startsWith("lsk")||t.startsWith("*"),n=(0,f.getEnvVar)("LOG_FORMAT",(0,f.getEnvVar)("DEBUG_FORMAT",w)),{on:s,off:i}=N(t),a=(0,f.getEnvVar)("LOG_LEVEL",(0,f.getEnvVar)("DEBUG_LEVEL",e?"error":r?"trace":"debug"));return(0,O.omitNull)({format:n,level:a,on:s,off:i})},"getEnvConfig");var g=require("@lskjs/err");var p={};P(p,{default:()=>T.default,stringify:()=>S.default});v(p,require("fast-safe-stringify"));var S=k(require("fast-safe-stringify")),T=k(require("fast-safe-stringify"));var c=o((t,e=null,r=0)=>typeof t=="object"?(0,S.default)(t,e,r):String(t),"toString");var z=o(t=>t.map(e=>(0,g.isError)(e)?(0,g.getCode)(e):null).filter(Boolean)[0],"getErrCode"),D=o(t=>t.length?t.map(e=>(0,g.isError)(e)?(0,g.getMessage)(e):c(e)).join(" "):null,"createMsg");var ut=require("@lskjs/env");var gt={log:10,trace:10,debug:20,info:30,warn:40,error:50,fatal:60};var U=o(t=>{let{level:e,time:r,...n}=t;return c({level:gt[e],time:r.toISOString(),...n})},"stringifyBunyan");var mt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"};var V=o(t=>{let{level:e,time:r,...n}=t;return c({level:mt[e],time:r.toISOString(),...n})},"stringifyLogrus");var h=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),C=o(t=>!!(h(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal");var J=o(t=>{let{level:e,time:r,...n}=t;return c({level:e,time:+r,...n})},"stringifyLsklog");function Y(t,e,...r){let n=z(r),s=D(r),i={code:n,...e,msg:s};return t==="bunyan"?U(i):t==="logrus"?V(i):J(i)}o(Y,"stringify");var Q=require("@lskjs/colors"),X=require("@lskjs/env"),Z=k(require("pretty-bytes")),K=k(require("pretty-time"));var W=require("@lskjs/colors");var F=o(t=>typeof t=="number"?t:Math.abs(String(t).split("").reduce((e,r)=>{let n=(e<<5)-e+r.charCodeAt(0);return n&n},0)-48),"hashCode"),H=F;function M(t,e){let r=B[H(e||"")%B.length]||[];return(0,W.colorize)(t,r)}o(M,"themeizeRandom");function y(t,e){let r=e?$[e]:[];return(0,W.colorize)(t,r)}o(y,"themeize");var pt=(0,X.getEnvVar)("LOG_VIEW","short"),L=o((t,e)=>String(t).padStart(e),"leftPad"),ht=o((t,e)=>String(t).padEnd(e),"rightPad"),R=20,dt=o((t,e=0)=>(R=Math.max(t&&t.length||0,R,e),ht(t,R)),"prettyPath"),j=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),xt=o(t=>{let e=j(t);return e||(e=t!==200?"log":null),y(L(String(t),3),e)},"prettyStatus"),yt=o(t=>L(`#${t}`,3),"prettyReqId"),Lt=o(t=>{let e=t==="REMOVE"?"error":t==="WS"?"debug":null;return y(L(t,4),e)},"prettyMethod"),bt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=t>=10*1e3?"error":t>=3*1e3?"warn":null,s=["m","s","ms"].includes(e)?e:"",i=Math.floor(Math.abs(t)*10**6),l=(0,K.default)(i,s);return y(L(l,5),r)},"prettyTime"),vt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=(0,Z.default)(t,{maximumFractionDigits:1}).split(" "),n=r[1];return`${+r[0]>=100?Math.round(+r[0]):+r[0]}${e}${n}`},"prettySize"),q=o((t,e)=>[...t,e].filter(Boolean).map(String).map(n=>M(n,n)).join(":"),"prettyNs");function kt(t){let e=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],r=e[F(t)%e.length];return M(r,String(t))}o(kt,"prettyMarker");var A=o(t=>{let e=pt==="short"?(t[0]||"").toLowerCase():L(t,5);return e=`[${e}]`,y(e,t)},"prettyLevel"),wt=/\[[^"\]]+]/gm,tt=o((...t)=>{let e=[];return t.forEach(r=>{if(typeof r=="string"){let n=0;e.push(r.replace(wt,s=>(0,Q.colorize)(s,E[n++%E.length])))}else e.push(r)}),e},"prettyContent"),St=o(t=>j(t.status)||C(t)?"debug":"trace","getUrlLevel"),et=o(t=>{let e=C(t),r=St(t);return[A(r),[kt(t.reqId),Lt(t.method)].join(""),dt(t.url),yt(t.reqId),e&&t.method!=="WS"?xt(t.status):null,!e&&"\u29D7\u29D6\u29D7",e&&bt(t.duration),e&&t.method!=="WS"?vt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function _t(t,e){let r=0;return t.forEach((n,s)=>{s===r&&e(n)&&(r+=1)}),r}o(_t,"countInRow");function Bt(...t){let e=_t(t,r=>typeof r=="string");return[t.slice(0,e).join(" "),...t.slice(e)]}o(Bt,"concatFirstStrings");function rt(t,...e){let r=t?.ns,n=t?.name,s=t?.level||"log",i=e;if(h(t))return[et(t)];let l=(r||"").split(":").filter(Boolean).map(String),a=[A(s)];return(l.length||n)&&a.push(q(l,n)),Bt(...a,...tt(...i))}o(rt,"prettyFormat");function I(t,e){Array.isArray(t)||(t=[t]);for(let r=0;r<t.length;r++)if(t[r].test(e))return!0;return!1}o(I,"anyRegExps");var m=class{prefix;ns;name;format=w;level="trace";on=[];off=[];constructor(e={}){typeof e=="string"?this.setProps({name:e,...x()}):this.setProps(e)}setProps({prefix:e,ns:r,name:n,level:s,format:i,on:l=[],off:a=[]}){if(e&&(this.prefix=e),r&&(this.ns=r),l&&(this.on=l),a&&(this.off=a),n&&(this.name=n),i&&(this.format=i),s){if(!_[s])throw new Error(`Incorrect level: ${this.level}`);this.level=s}this.level||(this.level="trace"),this.level||(this.level="trace"),this.format||(this.format="lsk"),this.off||(this.off=[]),this.on||(this.on=[])}static create(e){return new this(e)}createChild(...e){let r=[this.ns,this.name].filter(Boolean).join(".");return new this.constructor(this,{colors:null,ns:r},...e)}getLevelPriority(e){return _[e]||0}canLog(e){let r=this.getLevelPriority(e),n=this.getLevelPriority(this.level);return this.ns&&I(this.off,this.ns)?!1:this.ns&&I(this.on,this.ns)?!0:r>=n}fatal(...e){this.canLog("fatal")&&this.__log("fatal",...e)}error(...e){this.canLog("error")&&this.__log("error",...e)}warn(...e){this.canLog("warn")&&this.__log("warn",...e)}debug(...e){this.canLog("debug")&&this.__log("debug",...e)}info(...e){this.canLog("info")&&this.__log("info",...e)}trace(...e){this.canLog("trace")&&this.__log("trace",...e)}log(...e){console._log?console._log(...e):console.log(...e)}__log(e,...r){let[n,...s]=r,i={name:this.name,ns:this.ns,level:e,time:new Date},l=r;if(h(n)&&(i={...i,...n},l=s),this.format==="none")return;let a=(0,ot.omitNull)(i);if(this.format==="pretty"){this.log(...rt(a,...l));return}this.log(Y(this.format||"lsk",a,...l))}};o(m,"Logger");var nt=m;var Et=o((t={},e={})=>{let r={...typeof t=="string"?{name:t}:t,...x(),...e},n=[r.ns,r.name].filter(Boolean).join(":");return r.on?.some(s=>s.test(n))&&(r.level="trace"),r.off?.some(s=>s.test(n))&&(r.level="fatal"),new m(r)},"createLogger");0&&(module.exports={ILoggerInternalMessageFormat,Logger,createLogger,defaultFormat,getEnvConfig}); | ||
"use strict";var st=Object.create;var d=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,ft=Object.prototype.hasOwnProperty;var o=(t,e)=>d(t,"name",{value:e,configurable:!0});var P=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},b=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of lt(e))!ft.call(t,s)&&s!==r&&d(t,s,{get:()=>e[s],enumerable:!(n=it(e,s))||n.enumerable});return t},v=(t,e,r)=>(b(t,e,"default"),r&&b(r,e,"default")),k=(t,e,r)=>(r=t!=null?st(at(t)):{},b(e||!t||!t.__esModule?d(r,"default",{value:t,enumerable:!0}):r,t)),ct=t=>b(d({},"__esModule",{value:!0}),t);var Ct={};P(Ct,{ILoggerInternalMessageFormat:()=>u,Logger:()=>h,createLogger:()=>Et,default:()=>nt,defaultFormat:()=>w,getEnvConfig:()=>x});module.exports=ct(Ct);var u;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(u||(u={}));var ot=require("@lskjs/algos");var _={start:99,log:99,fatal:60,error:50,warn:40,success:35,info:30,debug:20,trace:10},$={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},B=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],E=[["bold","white"],["bold","cyan"],["bold","green"],["white"]];var O=require("@lskjs/algos"),f=require("@lskjs/env");function N(t=""){let e=[],r=[],n,s=(typeof t=="string"?t:"").split(/[\s,]+/);for(n=0;n<s.length;n++){if(!s[n])continue;let i=s[n].replace(/\*/g,".*?");i[0]==="-"?r.push(new RegExp(`^${i.slice(1)}$`)):e.push(new RegExp(`^${i}$`))}return{on:e,off:r}}o(N,"parseNs");var w=f.isDev||f.isClient?"pretty":"lsk",x=o(()=>{let t=(0,f.getEnvVar)("DEBUG","")||"",e=process.argv?.includes("--silent"),r=t.startsWith("lsk")||t.startsWith("*"),n=(0,f.getEnvVar)("LOG_FORMAT",(0,f.getEnvVar)("DEBUG_FORMAT",w)),{on:s,off:i}=N(t),a=(0,f.getEnvVar)("LOG_LEVEL",(0,f.getEnvVar)("DEBUG_LEVEL",e?"error":r?"trace":"debug"));return(0,O.omitNull)({format:n,level:a,on:s,off:i})},"getEnvConfig");var g=require("@lskjs/err");var m={};P(m,{default:()=>T.default,stringify:()=>S.default});v(m,require("fast-safe-stringify"));var S=k(require("fast-safe-stringify")),T=k(require("fast-safe-stringify"));var c=o((t,e=null,r=0)=>typeof t=="object"?(0,S.default)(t,e,r):String(t),"toString");var z=o(t=>t.map(e=>(0,g.isError)(e)?(0,g.getCode)(e):null).filter(Boolean)[0],"getErrCode"),D=o(t=>t.length?t.map(e=>(0,g.isError)(e)?(0,g.getMessage)(e):c(e)).join(" "):null,"createMsg");var ut=require("@lskjs/env");var gt={log:10,trace:10,debug:20,info:30,warn:40,error:50,fatal:60};var U=o(t=>{let{level:e,time:r,...n}=t;return c({level:gt[e],time:r.toISOString(),...n})},"stringifyBunyan");var mt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"};var V=o(t=>{let{level:e,time:r,...n}=t;return c({level:mt[e],time:r.toISOString(),...n})},"stringifyLogrus");var p=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),C=o(t=>!!(p(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal");var J=o(t=>{let{level:e,time:r,...n}=t;return c({level:e,time:+r,...n})},"stringifyLsklog");function Y(t,e,...r){let n=z(r),s=D(r),i={code:n,...e,msg:s};return t==="bunyan"?U(i):t==="logrus"?V(i):J(i)}o(Y,"stringify");var Q=require("@lskjs/colors"),X=require("@lskjs/env"),Z=k(require("pretty-bytes")),K=k(require("pretty-time"));var W=require("@lskjs/colors");var F=o(t=>typeof t=="number"?t:Math.abs(String(t).split("").reduce((e,r)=>{let n=(e<<5)-e+r.charCodeAt(0);return n&n},0)-48),"hashCode"),H=F;function M(t,e){let r=B[H(e||"")%B.length]||[];return(0,W.colorize)(t,r)}o(M,"themeizeRandom");function y(t,e){let r=e?$[e]:[];return(0,W.colorize)(t,r)}o(y,"themeize");var pt=(0,X.getEnvVar)("LOG_VIEW","short"),L=o((t,e)=>String(t).padStart(e),"leftPad"),ht=o((t,e)=>String(t).padEnd(e),"rightPad"),R=20,dt=o((t,e=0)=>(R=Math.max(t&&t.length||0,R,e),ht(t,R)),"prettyPath"),j=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),xt=o(t=>{let e=j(t);return e||(e=t!==200?"log":null),y(L(String(t),3),e)},"prettyStatus"),yt=o(t=>L(`#${t}`,3),"prettyReqId"),Lt=o(t=>{let e=t==="REMOVE"?"error":t==="WS"?"debug":null;return y(L(t,4),e)},"prettyMethod"),bt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=t>=10*1e3?"error":t>=3*1e3?"warn":null,s=["m","s","ms"].includes(e)?e:"",i=Math.floor(Math.abs(t)*10**6),l=(0,K.default)(i,s);return y(L(l,5),r)},"prettyTime"),vt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=(0,Z.default)(t,{maximumFractionDigits:1}).split(" "),n=r[1];return`${+r[0]>=100?Math.round(+r[0]):+r[0]}${e}${n}`},"prettySize"),q=o((t,e)=>[...t,e].filter(Boolean).map(String).map(n=>M(n,n)).join(":"),"prettyNs");function kt(t){let e=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],r=e[F(t)%e.length];return M(r,String(t))}o(kt,"prettyMarker");var A=o(t=>{let e=pt==="short"?(t[0]||"").toLowerCase():L(t,5);return e=`[${e}]`,y(e,t)},"prettyLevel"),wt=/\[[^"\]]+]/gm,tt=o((...t)=>{let e=[];return t.forEach(r=>{if(typeof r=="string"){let n=0;e.push(r.replace(wt,s=>(0,Q.colorize)(s,E[n++%E.length])))}else e.push(r)}),e},"prettyContent"),St=o(t=>j(t.status)||C(t)?"debug":"trace","getUrlLevel"),et=o(t=>{let e=C(t),r=St(t);return[A(r),[kt(t.reqId),Lt(t.method)].join(""),dt(t.url),yt(t.reqId),e&&t.method!=="WS"?xt(t.status):null,!e&&"\u29D7\u29D6\u29D7",e&&bt(t.duration),e&&t.method!=="WS"?vt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function _t(t,e){let r=0;return t.forEach((n,s)=>{s===r&&e(n)&&(r+=1)}),r}o(_t,"countInRow");function Bt(...t){let e=_t(t,r=>typeof r=="string");return[t.slice(0,e).join(" "),...t.slice(e)]}o(Bt,"concatFirstStrings");function rt(t,...e){let r=t?.ns,n=t?.name,s=t?.level||"log",i=e;if(p(t))return[et(t)];let l=(r||"").split(":").filter(Boolean).map(String),a=[A(s)];return(l.length||n)&&a.push(q(l,n)),Bt(...a,...tt(...i))}o(rt,"prettyFormat");function I(t,e){Array.isArray(t)||(t=[t]);for(let r=0;r<t.length;r++)if(t[r].test(e))return!0;return!1}o(I,"anyRegExps");var h=class{static{o(this,"Logger")}prefix;ns;name;format=w;level="trace";on=[];off=[];constructor(e={}){typeof e=="string"?this.setProps({name:e,...x()}):this.setProps(e)}setProps({prefix:e,ns:r,name:n,level:s,format:i,on:l=[],off:a=[]}){if(e&&(this.prefix=e),r&&(this.ns=r),l&&(this.on=l),a&&(this.off=a),n&&(this.name=n),i&&(this.format=i),s){if(!_[s])throw new Error(`Incorrect level: ${this.level}`);this.level=s}this.level||(this.level="trace"),this.level||(this.level="trace"),this.format||(this.format="lsk"),this.off||(this.off=[]),this.on||(this.on=[])}static create(e){return new this(e)}createChild(...e){let r=[this.ns,this.name].filter(Boolean).join(".");return new this.constructor(this,{colors:null,ns:r},...e)}getLevelPriority(e){return _[e]||0}canLog(e){let r=this.getLevelPriority(e),n=this.getLevelPriority(this.level);return this.ns&&I(this.off,this.ns)?!1:this.ns&&I(this.on,this.ns)?!0:r>=n}fatal(...e){this.canLog("fatal")&&this.__log("fatal",...e)}error(...e){this.canLog("error")&&this.__log("error",...e)}warn(...e){this.canLog("warn")&&this.__log("warn",...e)}debug(...e){this.canLog("debug")&&this.__log("debug",...e)}info(...e){this.canLog("info")&&this.__log("info",...e)}trace(...e){this.canLog("trace")&&this.__log("trace",...e)}log(...e){console._log?console._log(...e):console.log(...e)}__log(e,...r){let[n,...s]=r,i={name:this.name,ns:this.ns,level:e,time:new Date},l=r;if(p(n)&&(i={...i,...n},l=s),this.format==="none")return;let a=(0,ot.omitNull)(i);if(this.format==="pretty"){this.log(...rt(a,...l));return}this.log(Y(this.format||"lsk",a,...l))}},nt=h;var Et=o((t={},e={})=>{let r=x(),n={...typeof t=="string"?{name:t}:t,...r,...e},s=[n.ns,n.name].filter(Boolean).join(":");return n.on?.some(i=>i.test(s))&&(n.level="trace"),n.off?.some(i=>i.test(s))&&(n.level="fatal"),new h(n)},"createLogger");0&&(module.exports={ILoggerInternalMessageFormat,Logger,createLogger,defaultFormat,getEnvConfig}); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var it=Object.create;var h=Object.defineProperty;var lt=Object.getOwnPropertyDescriptor;var at=Object.getOwnPropertyNames;var ft=Object.getPrototypeOf,ct=Object.prototype.hasOwnProperty;var o=(t,e)=>h(t,"name",{value:e,configurable:!0});var P=(t,e)=>{for(var r in e)h(t,r,{get:e[r],enumerable:!0})},L=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of at(e))!ct.call(t,s)&&s!==r&&h(t,s,{get:()=>e[s],enumerable:!(n=lt(e,s))||n.enumerable});return t},b=(t,e,r)=>(L(t,e,"default"),r&&L(r,e,"default")),v=(t,e,r)=>(r=t!=null?it(ft(t)):{},L(e||!t||!t.__esModule?h(r,"default",{value:t,enumerable:!0}):r,t)),ut=t=>L(h({},"__esModule",{value:!0}),t);var Ft={};P(Ft,{default:()=>Ct,log:()=>st});module.exports=ut(Ft);var N=require("@lskjs/algos"),f=require("@lskjs/env");function $(t=""){let e=[],r=[],n,s=(typeof t=="string"?t:"").split(/[\s,]+/);for(n=0;n<s.length;n++){if(!s[n])continue;let i=s[n].replace(/\*/g,".*?");i[0]==="-"?r.push(new RegExp(`^${i.slice(1)}$`)):e.push(new RegExp(`^${i}$`))}return{on:e,off:r}}o($,"parseNs");var S=f.isDev||f.isClient?"pretty":"lsk",k=o(()=>{let t=(0,f.getEnvVar)("DEBUG","")||"",e=process.argv?.includes("--silent"),r=t.startsWith("lsk")||t.startsWith("*"),n=(0,f.getEnvVar)("LOG_FORMAT",(0,f.getEnvVar)("DEBUG_FORMAT",S)),{on:s,off:i}=$(t),a=(0,f.getEnvVar)("LOG_LEVEL",(0,f.getEnvVar)("DEBUG_LEVEL",e?"error":r?"trace":"debug"));return(0,N.omitNull)({format:n,level:a,on:s,off:i})},"getEnvConfig");var ot=require("@lskjs/algos");var _={start:99,log:99,fatal:60,error:50,warn:40,success:35,info:30,debug:20,trace:10},O={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},B=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],E=[["bold","white"],["bold","cyan"],["bold","green"],["white"]];var g;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(g||(g={}));var u=require("@lskjs/err");var m={};P(m,{default:()=>T.default,stringify:()=>w.default});b(m,require("fast-safe-stringify"));var w=v(require("fast-safe-stringify")),T=v(require("fast-safe-stringify"));var c=o((t,e=null,r=0)=>typeof t=="object"?(0,w.default)(t,e,r):String(t),"toString");var z=o(t=>t.map(e=>(0,u.isError)(e)?(0,u.getCode)(e):null).filter(Boolean)[0],"getErrCode"),D=o(t=>t.length?t.map(e=>(0,u.isError)(e)?(0,u.getMessage)(e):c(e)).join(" "):null,"createMsg");var gt=require("@lskjs/env");var mt={log:10,trace:10,debug:20,info:30,warn:40,error:50,fatal:60};var U=o(t=>{let{level:e,time:r,...n}=t;return c({level:mt[e],time:r.toISOString(),...n})},"stringifyBunyan");var pt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"};var V=o(t=>{let{level:e,time:r,...n}=t;return c({level:pt[e],time:r.toISOString(),...n})},"stringifyLogrus");var p=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),C=o(t=>!!(p(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal");var J=o(t=>{let{level:e,time:r,...n}=t;return c({level:e,time:+r,...n})},"stringifyLsklog");function Y(t,e,...r){let n=z(r),s=D(r),i={code:n,...e,msg:s};return t==="bunyan"?U(i):t==="logrus"?V(i):J(i)}o(Y,"stringify");var Q=require("@lskjs/colors"),X=require("@lskjs/env"),Z=v(require("pretty-bytes")),K=v(require("pretty-time"));var W=require("@lskjs/colors");var F=o(t=>typeof t=="number"?t:Math.abs(String(t).split("").reduce((e,r)=>{let n=(e<<5)-e+r.charCodeAt(0);return n&n},0)-48),"hashCode"),H=F;function M(t,e){let r=B[H(e||"")%B.length]||[];return(0,W.colorize)(t,r)}o(M,"themeizeRandom");function d(t,e){let r=e?O[e]:[];return(0,W.colorize)(t,r)}o(d,"themeize");var ht=(0,X.getEnvVar)("LOG_VIEW","short"),x=o((t,e)=>String(t).padStart(e),"leftPad"),dt=o((t,e)=>String(t).padEnd(e),"rightPad"),R=20,xt=o((t,e=0)=>(R=Math.max(t&&t.length||0,R,e),dt(t,R)),"prettyPath"),j=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),yt=o(t=>{let e=j(t);return e||(e=t!==200?"log":null),d(x(String(t),3),e)},"prettyStatus"),Lt=o(t=>x(`#${t}`,3),"prettyReqId"),bt=o(t=>{let e=t==="REMOVE"?"error":t==="WS"?"debug":null;return d(x(t,4),e)},"prettyMethod"),vt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=t>=10*1e3?"error":t>=3*1e3?"warn":null,s=["m","s","ms"].includes(e)?e:"",i=Math.floor(Math.abs(t)*10**6),l=(0,K.default)(i,s);return d(x(l,5),r)},"prettyTime"),kt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=(0,Z.default)(t,{maximumFractionDigits:1}).split(" "),n=r[1];return`${+r[0]>=100?Math.round(+r[0]):+r[0]}${e}${n}`},"prettySize"),q=o((t,e)=>[...t,e].filter(Boolean).map(String).map(n=>M(n,n)).join(":"),"prettyNs");function wt(t){let e=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],r=e[F(t)%e.length];return M(r,String(t))}o(wt,"prettyMarker");var A=o(t=>{let e=ht==="short"?(t[0]||"").toLowerCase():x(t,5);return e=`[${e}]`,d(e,t)},"prettyLevel"),St=/\[[^"\]]+]/gm,tt=o((...t)=>{let e=[];return t.forEach(r=>{if(typeof r=="string"){let n=0;e.push(r.replace(St,s=>(0,Q.colorize)(s,E[n++%E.length])))}else e.push(r)}),e},"prettyContent"),_t=o(t=>j(t.status)||C(t)?"debug":"trace","getUrlLevel"),et=o(t=>{let e=C(t),r=_t(t);return[A(r),[wt(t.reqId),bt(t.method)].join(""),xt(t.url),Lt(t.reqId),e&&t.method!=="WS"?yt(t.status):null,!e&&"\u29D7\u29D6\u29D7",e&&vt(t.duration),e&&t.method!=="WS"?kt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function Bt(t,e){let r=0;return t.forEach((n,s)=>{s===r&&e(n)&&(r+=1)}),r}o(Bt,"countInRow");function Et(...t){let e=Bt(t,r=>typeof r=="string");return[t.slice(0,e).join(" "),...t.slice(e)]}o(Et,"concatFirstStrings");function rt(t,...e){let r=t?.ns,n=t?.name,s=t?.level||"log",i=e;if(p(t))return[et(t)];let l=(r||"").split(":").filter(Boolean).map(String),a=[A(s)];return(l.length||n)&&a.push(q(l,n)),Et(...a,...tt(...i))}o(rt,"prettyFormat");function I(t,e){Array.isArray(t)||(t=[t]);for(let r=0;r<t.length;r++)if(t[r].test(e))return!0;return!1}o(I,"anyRegExps");var y=class{prefix;ns;name;format=S;level="trace";on=[];off=[];constructor(e={}){typeof e=="string"?this.setProps({name:e,...k()}):this.setProps(e)}setProps({prefix:e,ns:r,name:n,level:s,format:i,on:l=[],off:a=[]}){if(e&&(this.prefix=e),r&&(this.ns=r),l&&(this.on=l),a&&(this.off=a),n&&(this.name=n),i&&(this.format=i),s){if(!_[s])throw new Error(`Incorrect level: ${this.level}`);this.level=s}this.level||(this.level="trace"),this.level||(this.level="trace"),this.format||(this.format="lsk"),this.off||(this.off=[]),this.on||(this.on=[])}static create(e){return new this(e)}createChild(...e){let r=[this.ns,this.name].filter(Boolean).join(".");return new this.constructor(this,{colors:null,ns:r},...e)}getLevelPriority(e){return _[e]||0}canLog(e){let r=this.getLevelPriority(e),n=this.getLevelPriority(this.level);return this.ns&&I(this.off,this.ns)?!1:this.ns&&I(this.on,this.ns)?!0:r>=n}fatal(...e){this.canLog("fatal")&&this.__log("fatal",...e)}error(...e){this.canLog("error")&&this.__log("error",...e)}warn(...e){this.canLog("warn")&&this.__log("warn",...e)}debug(...e){this.canLog("debug")&&this.__log("debug",...e)}info(...e){this.canLog("info")&&this.__log("info",...e)}trace(...e){this.canLog("trace")&&this.__log("trace",...e)}log(...e){console._log?console._log(...e):console.log(...e)}__log(e,...r){let[n,...s]=r,i={name:this.name,ns:this.ns,level:e,time:new Date},l=r;if(p(n)&&(i={...i,...n},l=s),this.format==="none")return;let a=(0,ot.omitNull)(i);if(this.format==="pretty"){this.log(...rt(a,...l));return}this.log(Y(this.format||"lsk",a,...l))}};o(y,"Logger");var nt=o((t={},e={})=>{let r={...typeof t=="string"?{name:t}:t,...k(),...e},n=[r.ns,r.name].filter(Boolean).join(":");return r.on?.some(s=>s.test(n))&&(r.level="trace"),r.off?.some(s=>s.test(n))&&(r.level="fatal"),new y(r)},"createLogger");var st=nt(),Ct=st;0&&(module.exports={log}); | ||
"use strict";var it=Object.create;var h=Object.defineProperty;var lt=Object.getOwnPropertyDescriptor;var at=Object.getOwnPropertyNames;var ft=Object.getPrototypeOf,ct=Object.prototype.hasOwnProperty;var o=(t,e)=>h(t,"name",{value:e,configurable:!0});var P=(t,e)=>{for(var r in e)h(t,r,{get:e[r],enumerable:!0})},y=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of at(e))!ct.call(t,s)&&s!==r&&h(t,s,{get:()=>e[s],enumerable:!(n=lt(e,s))||n.enumerable});return t},L=(t,e,r)=>(y(t,e,"default"),r&&y(r,e,"default")),b=(t,e,r)=>(r=t!=null?it(ft(t)):{},y(e||!t||!t.__esModule?h(r,"default",{value:t,enumerable:!0}):r,t)),ut=t=>y(h({},"__esModule",{value:!0}),t);var Ft={};P(Ft,{default:()=>Ct,log:()=>st});module.exports=ut(Ft);var N=require("@lskjs/algos"),f=require("@lskjs/env");function $(t=""){let e=[],r=[],n,s=(typeof t=="string"?t:"").split(/[\s,]+/);for(n=0;n<s.length;n++){if(!s[n])continue;let i=s[n].replace(/\*/g,".*?");i[0]==="-"?r.push(new RegExp(`^${i.slice(1)}$`)):e.push(new RegExp(`^${i}$`))}return{on:e,off:r}}o($,"parseNs");var S=f.isDev||f.isClient?"pretty":"lsk",v=o(()=>{let t=(0,f.getEnvVar)("DEBUG","")||"",e=process.argv?.includes("--silent"),r=t.startsWith("lsk")||t.startsWith("*"),n=(0,f.getEnvVar)("LOG_FORMAT",(0,f.getEnvVar)("DEBUG_FORMAT",S)),{on:s,off:i}=$(t),a=(0,f.getEnvVar)("LOG_LEVEL",(0,f.getEnvVar)("DEBUG_LEVEL",e?"error":r?"trace":"debug"));return(0,N.omitNull)({format:n,level:a,on:s,off:i})},"getEnvConfig");var ot=require("@lskjs/algos");var _={start:99,log:99,fatal:60,error:50,warn:40,success:35,info:30,debug:20,trace:10},O={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},B=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],E=[["bold","white"],["bold","cyan"],["bold","green"],["white"]];var g;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(g||(g={}));var u=require("@lskjs/err");var m={};P(m,{default:()=>T.default,stringify:()=>k.default});L(m,require("fast-safe-stringify"));var k=b(require("fast-safe-stringify")),T=b(require("fast-safe-stringify"));var c=o((t,e=null,r=0)=>typeof t=="object"?(0,k.default)(t,e,r):String(t),"toString");var z=o(t=>t.map(e=>(0,u.isError)(e)?(0,u.getCode)(e):null).filter(Boolean)[0],"getErrCode"),D=o(t=>t.length?t.map(e=>(0,u.isError)(e)?(0,u.getMessage)(e):c(e)).join(" "):null,"createMsg");var gt=require("@lskjs/env");var mt={log:10,trace:10,debug:20,info:30,warn:40,error:50,fatal:60};var U=o(t=>{let{level:e,time:r,...n}=t;return c({level:mt[e],time:r.toISOString(),...n})},"stringifyBunyan");var pt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"};var V=o(t=>{let{level:e,time:r,...n}=t;return c({level:pt[e],time:r.toISOString(),...n})},"stringifyLogrus");var p=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),C=o(t=>!!(p(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal");var J=o(t=>{let{level:e,time:r,...n}=t;return c({level:e,time:+r,...n})},"stringifyLsklog");function Y(t,e,...r){let n=z(r),s=D(r),i={code:n,...e,msg:s};return t==="bunyan"?U(i):t==="logrus"?V(i):J(i)}o(Y,"stringify");var Q=require("@lskjs/colors"),X=require("@lskjs/env"),Z=b(require("pretty-bytes")),K=b(require("pretty-time"));var W=require("@lskjs/colors");var F=o(t=>typeof t=="number"?t:Math.abs(String(t).split("").reduce((e,r)=>{let n=(e<<5)-e+r.charCodeAt(0);return n&n},0)-48),"hashCode"),H=F;function M(t,e){let r=B[H(e||"")%B.length]||[];return(0,W.colorize)(t,r)}o(M,"themeizeRandom");function d(t,e){let r=e?O[e]:[];return(0,W.colorize)(t,r)}o(d,"themeize");var ht=(0,X.getEnvVar)("LOG_VIEW","short"),x=o((t,e)=>String(t).padStart(e),"leftPad"),dt=o((t,e)=>String(t).padEnd(e),"rightPad"),R=20,xt=o((t,e=0)=>(R=Math.max(t&&t.length||0,R,e),dt(t,R)),"prettyPath"),j=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),yt=o(t=>{let e=j(t);return e||(e=t!==200?"log":null),d(x(String(t),3),e)},"prettyStatus"),Lt=o(t=>x(`#${t}`,3),"prettyReqId"),bt=o(t=>{let e=t==="REMOVE"?"error":t==="WS"?"debug":null;return d(x(t,4),e)},"prettyMethod"),vt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=t>=10*1e3?"error":t>=3*1e3?"warn":null,s=["m","s","ms"].includes(e)?e:"",i=Math.floor(Math.abs(t)*10**6),l=(0,K.default)(i,s);return d(x(l,5),r)},"prettyTime"),kt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=(0,Z.default)(t,{maximumFractionDigits:1}).split(" "),n=r[1];return`${+r[0]>=100?Math.round(+r[0]):+r[0]}${e}${n}`},"prettySize"),q=o((t,e)=>[...t,e].filter(Boolean).map(String).map(n=>M(n,n)).join(":"),"prettyNs");function wt(t){let e=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],r=e[F(t)%e.length];return M(r,String(t))}o(wt,"prettyMarker");var A=o(t=>{let e=ht==="short"?(t[0]||"").toLowerCase():x(t,5);return e=`[${e}]`,d(e,t)},"prettyLevel"),St=/\[[^"\]]+]/gm,tt=o((...t)=>{let e=[];return t.forEach(r=>{if(typeof r=="string"){let n=0;e.push(r.replace(St,s=>(0,Q.colorize)(s,E[n++%E.length])))}else e.push(r)}),e},"prettyContent"),_t=o(t=>j(t.status)||C(t)?"debug":"trace","getUrlLevel"),et=o(t=>{let e=C(t),r=_t(t);return[A(r),[wt(t.reqId),bt(t.method)].join(""),xt(t.url),Lt(t.reqId),e&&t.method!=="WS"?yt(t.status):null,!e&&"\u29D7\u29D6\u29D7",e&&vt(t.duration),e&&t.method!=="WS"?kt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function Bt(t,e){let r=0;return t.forEach((n,s)=>{s===r&&e(n)&&(r+=1)}),r}o(Bt,"countInRow");function Et(...t){let e=Bt(t,r=>typeof r=="string");return[t.slice(0,e).join(" "),...t.slice(e)]}o(Et,"concatFirstStrings");function rt(t,...e){let r=t?.ns,n=t?.name,s=t?.level||"log",i=e;if(p(t))return[et(t)];let l=(r||"").split(":").filter(Boolean).map(String),a=[A(s)];return(l.length||n)&&a.push(q(l,n)),Et(...a,...tt(...i))}o(rt,"prettyFormat");function I(t,e){Array.isArray(t)||(t=[t]);for(let r=0;r<t.length;r++)if(t[r].test(e))return!0;return!1}o(I,"anyRegExps");var w=class{static{o(this,"Logger")}prefix;ns;name;format=S;level="trace";on=[];off=[];constructor(e={}){typeof e=="string"?this.setProps({name:e,...v()}):this.setProps(e)}setProps({prefix:e,ns:r,name:n,level:s,format:i,on:l=[],off:a=[]}){if(e&&(this.prefix=e),r&&(this.ns=r),l&&(this.on=l),a&&(this.off=a),n&&(this.name=n),i&&(this.format=i),s){if(!_[s])throw new Error(`Incorrect level: ${this.level}`);this.level=s}this.level||(this.level="trace"),this.level||(this.level="trace"),this.format||(this.format="lsk"),this.off||(this.off=[]),this.on||(this.on=[])}static create(e){return new this(e)}createChild(...e){let r=[this.ns,this.name].filter(Boolean).join(".");return new this.constructor(this,{colors:null,ns:r},...e)}getLevelPriority(e){return _[e]||0}canLog(e){let r=this.getLevelPriority(e),n=this.getLevelPriority(this.level);return this.ns&&I(this.off,this.ns)?!1:this.ns&&I(this.on,this.ns)?!0:r>=n}fatal(...e){this.canLog("fatal")&&this.__log("fatal",...e)}error(...e){this.canLog("error")&&this.__log("error",...e)}warn(...e){this.canLog("warn")&&this.__log("warn",...e)}debug(...e){this.canLog("debug")&&this.__log("debug",...e)}info(...e){this.canLog("info")&&this.__log("info",...e)}trace(...e){this.canLog("trace")&&this.__log("trace",...e)}log(...e){console._log?console._log(...e):console.log(...e)}__log(e,...r){let[n,...s]=r,i={name:this.name,ns:this.ns,level:e,time:new Date},l=r;if(p(n)&&(i={...i,...n},l=s),this.format==="none")return;let a=(0,ot.omitNull)(i);if(this.format==="pretty"){this.log(...rt(a,...l));return}this.log(Y(this.format||"lsk",a,...l))}};var nt=o((t={},e={})=>{let r=v(),n={...typeof t=="string"?{name:t}:t,...r,...e},s=[n.ns,n.name].filter(Boolean).join(":");return n.on?.some(i=>i.test(s))&&(n.level="trace"),n.off?.some(i=>i.test(s))&&(n.level="fatal"),new w(n)},"createLogger");var st=nt(),Ct=st;0&&(module.exports={log}); | ||
//# sourceMappingURL=log.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var st=Object.create;var d=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,ft=Object.prototype.hasOwnProperty;var o=(t,e)=>d(t,"name",{value:e,configurable:!0});var P=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},L=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of lt(e))!ft.call(t,s)&&s!==r&&d(t,s,{get:()=>e[s],enumerable:!(n=it(e,s))||n.enumerable});return t},b=(t,e,r)=>(L(t,e,"default"),r&&L(r,e,"default")),v=(t,e,r)=>(r=t!=null?st(at(t)):{},L(e||!t||!t.__esModule?d(r,"default",{value:t,enumerable:!0}):r,t)),ct=t=>L(d({},"__esModule",{value:!0}),t);var Et={};P(Et,{Logger:()=>p,default:()=>G});module.exports=ct(Et);var nt=require("@lskjs/algos");var w={start:99,log:99,fatal:60,error:50,warn:40,success:35,info:30,debug:20,trace:10},$={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},S=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],_=[["bold","white"],["bold","cyan"],["bold","green"],["white"]];var O=require("@lskjs/algos"),f=require("@lskjs/env");function N(t=""){let e=[],r=[],n,s=(typeof t=="string"?t:"").split(/[\s,]+/);for(n=0;n<s.length;n++){if(!s[n])continue;let i=s[n].replace(/\*/g,".*?");i[0]==="-"?r.push(new RegExp(`^${i.slice(1)}$`)):e.push(new RegExp(`^${i}$`))}return{on:e,off:r}}o(N,"parseNs");var B=f.isDev||f.isClient?"pretty":"lsk",E=o(()=>{let t=(0,f.getEnvVar)("DEBUG","")||"",e=process.argv?.includes("--silent"),r=t.startsWith("lsk")||t.startsWith("*"),n=(0,f.getEnvVar)("LOG_FORMAT",(0,f.getEnvVar)("DEBUG_FORMAT",B)),{on:s,off:i}=N(t),a=(0,f.getEnvVar)("LOG_LEVEL",(0,f.getEnvVar)("DEBUG_LEVEL",e?"error":r?"trace":"debug"));return(0,O.omitNull)({format:n,level:a,on:s,off:i})},"getEnvConfig");var g;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(g||(g={}));var u=require("@lskjs/err");var m={};P(m,{default:()=>T.default,stringify:()=>k.default});b(m,require("fast-safe-stringify"));var k=v(require("fast-safe-stringify")),T=v(require("fast-safe-stringify"));var c=o((t,e=null,r=0)=>typeof t=="object"?(0,k.default)(t,e,r):String(t),"toString");var z=o(t=>t.map(e=>(0,u.isError)(e)?(0,u.getCode)(e):null).filter(Boolean)[0],"getErrCode"),D=o(t=>t.length?t.map(e=>(0,u.isError)(e)?(0,u.getMessage)(e):c(e)).join(" "):null,"createMsg");var ut=require("@lskjs/env");var gt={log:10,trace:10,debug:20,info:30,warn:40,error:50,fatal:60};var V=o(t=>{let{level:e,time:r,...n}=t;return c({level:gt[e],time:r.toISOString(),...n})},"stringifyBunyan");var mt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"};var J=o(t=>{let{level:e,time:r,...n}=t;return c({level:mt[e],time:r.toISOString(),...n})},"stringifyLogrus");var h=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),C=o(t=>!!(h(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal");var Y=o(t=>{let{level:e,time:r,...n}=t;return c({level:e,time:+r,...n})},"stringifyLsklog");function H(t,e,...r){let n=z(r),s=D(r),i={code:n,...e,msg:s};return t==="bunyan"?V(i):t==="logrus"?J(i):Y(i)}o(H,"stringify");var X=require("@lskjs/colors"),Z=require("@lskjs/env"),K=v(require("pretty-bytes")),j=v(require("pretty-time"));var W=require("@lskjs/colors");var F=o(t=>typeof t=="number"?t:Math.abs(String(t).split("").reduce((e,r)=>{let n=(e<<5)-e+r.charCodeAt(0);return n&n},0)-48),"hashCode"),Q=F;function M(t,e){let r=S[Q(e||"")%S.length]||[];return(0,W.colorize)(t,r)}o(M,"themeizeRandom");function x(t,e){let r=e?$[e]:[];return(0,W.colorize)(t,r)}o(x,"themeize");var pt=(0,Z.getEnvVar)("LOG_VIEW","short"),y=o((t,e)=>String(t).padStart(e),"leftPad"),ht=o((t,e)=>String(t).padEnd(e),"rightPad"),R=20,dt=o((t,e=0)=>(R=Math.max(t&&t.length||0,R,e),ht(t,R)),"prettyPath"),q=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),xt=o(t=>{let e=q(t);return e||(e=t!==200?"log":null),x(y(String(t),3),e)},"prettyStatus"),yt=o(t=>y(`#${t}`,3),"prettyReqId"),Lt=o(t=>{let e=t==="REMOVE"?"error":t==="WS"?"debug":null;return x(y(t,4),e)},"prettyMethod"),bt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=t>=10*1e3?"error":t>=3*1e3?"warn":null,s=["m","s","ms"].includes(e)?e:"",i=Math.floor(Math.abs(t)*10**6),l=(0,j.default)(i,s);return x(y(l,5),r)},"prettyTime"),vt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=(0,K.default)(t,{maximumFractionDigits:1}).split(" "),n=r[1];return`${+r[0]>=100?Math.round(+r[0]):+r[0]}${e}${n}`},"prettySize"),tt=o((t,e)=>[...t,e].filter(Boolean).map(String).map(n=>M(n,n)).join(":"),"prettyNs");function kt(t){let e=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],r=e[F(t)%e.length];return M(r,String(t))}o(kt,"prettyMarker");var A=o(t=>{let e=pt==="short"?(t[0]||"").toLowerCase():y(t,5);return e=`[${e}]`,x(e,t)},"prettyLevel"),wt=/\[[^"\]]+]/gm,et=o((...t)=>{let e=[];return t.forEach(r=>{if(typeof r=="string"){let n=0;e.push(r.replace(wt,s=>(0,X.colorize)(s,_[n++%_.length])))}else e.push(r)}),e},"prettyContent"),St=o(t=>q(t.status)||C(t)?"debug":"trace","getUrlLevel"),rt=o(t=>{let e=C(t),r=St(t);return[A(r),[kt(t.reqId),Lt(t.method)].join(""),dt(t.url),yt(t.reqId),e&&t.method!=="WS"?xt(t.status):null,!e&&"\u29D7\u29D6\u29D7",e&&bt(t.duration),e&&t.method!=="WS"?vt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function _t(t,e){let r=0;return t.forEach((n,s)=>{s===r&&e(n)&&(r+=1)}),r}o(_t,"countInRow");function Bt(...t){let e=_t(t,r=>typeof r=="string");return[t.slice(0,e).join(" "),...t.slice(e)]}o(Bt,"concatFirstStrings");function ot(t,...e){let r=t?.ns,n=t?.name,s=t?.level||"log",i=e;if(h(t))return[rt(t)];let l=(r||"").split(":").filter(Boolean).map(String),a=[A(s)];return(l.length||n)&&a.push(tt(l,n)),Bt(...a,...et(...i))}o(ot,"prettyFormat");function I(t,e){Array.isArray(t)||(t=[t]);for(let r=0;r<t.length;r++)if(t[r].test(e))return!0;return!1}o(I,"anyRegExps");var p=class{prefix;ns;name;format=B;level="trace";on=[];off=[];constructor(e={}){typeof e=="string"?this.setProps({name:e,...E()}):this.setProps(e)}setProps({prefix:e,ns:r,name:n,level:s,format:i,on:l=[],off:a=[]}){if(e&&(this.prefix=e),r&&(this.ns=r),l&&(this.on=l),a&&(this.off=a),n&&(this.name=n),i&&(this.format=i),s){if(!w[s])throw new Error(`Incorrect level: ${this.level}`);this.level=s}this.level||(this.level="trace"),this.level||(this.level="trace"),this.format||(this.format="lsk"),this.off||(this.off=[]),this.on||(this.on=[])}static create(e){return new this(e)}createChild(...e){let r=[this.ns,this.name].filter(Boolean).join(".");return new this.constructor(this,{colors:null,ns:r},...e)}getLevelPriority(e){return w[e]||0}canLog(e){let r=this.getLevelPriority(e),n=this.getLevelPriority(this.level);return this.ns&&I(this.off,this.ns)?!1:this.ns&&I(this.on,this.ns)?!0:r>=n}fatal(...e){this.canLog("fatal")&&this.__log("fatal",...e)}error(...e){this.canLog("error")&&this.__log("error",...e)}warn(...e){this.canLog("warn")&&this.__log("warn",...e)}debug(...e){this.canLog("debug")&&this.__log("debug",...e)}info(...e){this.canLog("info")&&this.__log("info",...e)}trace(...e){this.canLog("trace")&&this.__log("trace",...e)}log(...e){console._log?console._log(...e):console.log(...e)}__log(e,...r){let[n,...s]=r,i={name:this.name,ns:this.ns,level:e,time:new Date},l=r;if(h(n)&&(i={...i,...n},l=s),this.format==="none")return;let a=(0,nt.omitNull)(i);if(this.format==="pretty"){this.log(...ot(a,...l));return}this.log(H(this.format||"lsk",a,...l))}};o(p,"Logger");var G=p;0&&(module.exports={Logger}); | ||
"use strict";var st=Object.create;var h=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,ft=Object.prototype.hasOwnProperty;var o=(t,e)=>h(t,"name",{value:e,configurable:!0});var P=(t,e)=>{for(var r in e)h(t,r,{get:e[r],enumerable:!0})},L=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of lt(e))!ft.call(t,s)&&s!==r&&h(t,s,{get:()=>e[s],enumerable:!(n=it(e,s))||n.enumerable});return t},b=(t,e,r)=>(L(t,e,"default"),r&&L(r,e,"default")),v=(t,e,r)=>(r=t!=null?st(at(t)):{},L(e||!t||!t.__esModule?h(r,"default",{value:t,enumerable:!0}):r,t)),ct=t=>L(h({},"__esModule",{value:!0}),t);var Et={};P(Et,{Logger:()=>d,default:()=>G});module.exports=ct(Et);var nt=require("@lskjs/algos");var w={start:99,log:99,fatal:60,error:50,warn:40,success:35,info:30,debug:20,trace:10},$={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},S=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],_=[["bold","white"],["bold","cyan"],["bold","green"],["white"]];var O=require("@lskjs/algos"),f=require("@lskjs/env");function N(t=""){let e=[],r=[],n,s=(typeof t=="string"?t:"").split(/[\s,]+/);for(n=0;n<s.length;n++){if(!s[n])continue;let i=s[n].replace(/\*/g,".*?");i[0]==="-"?r.push(new RegExp(`^${i.slice(1)}$`)):e.push(new RegExp(`^${i}$`))}return{on:e,off:r}}o(N,"parseNs");var B=f.isDev||f.isClient?"pretty":"lsk",E=o(()=>{let t=(0,f.getEnvVar)("DEBUG","")||"",e=process.argv?.includes("--silent"),r=t.startsWith("lsk")||t.startsWith("*"),n=(0,f.getEnvVar)("LOG_FORMAT",(0,f.getEnvVar)("DEBUG_FORMAT",B)),{on:s,off:i}=N(t),a=(0,f.getEnvVar)("LOG_LEVEL",(0,f.getEnvVar)("DEBUG_LEVEL",e?"error":r?"trace":"debug"));return(0,O.omitNull)({format:n,level:a,on:s,off:i})},"getEnvConfig");var g;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(g||(g={}));var u=require("@lskjs/err");var m={};P(m,{default:()=>T.default,stringify:()=>k.default});b(m,require("fast-safe-stringify"));var k=v(require("fast-safe-stringify")),T=v(require("fast-safe-stringify"));var c=o((t,e=null,r=0)=>typeof t=="object"?(0,k.default)(t,e,r):String(t),"toString");var z=o(t=>t.map(e=>(0,u.isError)(e)?(0,u.getCode)(e):null).filter(Boolean)[0],"getErrCode"),D=o(t=>t.length?t.map(e=>(0,u.isError)(e)?(0,u.getMessage)(e):c(e)).join(" "):null,"createMsg");var ut=require("@lskjs/env");var gt={log:10,trace:10,debug:20,info:30,warn:40,error:50,fatal:60};var V=o(t=>{let{level:e,time:r,...n}=t;return c({level:gt[e],time:r.toISOString(),...n})},"stringifyBunyan");var mt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"};var J=o(t=>{let{level:e,time:r,...n}=t;return c({level:mt[e],time:r.toISOString(),...n})},"stringifyLogrus");var p=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),C=o(t=>!!(p(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal");var Y=o(t=>{let{level:e,time:r,...n}=t;return c({level:e,time:+r,...n})},"stringifyLsklog");function H(t,e,...r){let n=z(r),s=D(r),i={code:n,...e,msg:s};return t==="bunyan"?V(i):t==="logrus"?J(i):Y(i)}o(H,"stringify");var X=require("@lskjs/colors"),Z=require("@lskjs/env"),K=v(require("pretty-bytes")),j=v(require("pretty-time"));var W=require("@lskjs/colors");var F=o(t=>typeof t=="number"?t:Math.abs(String(t).split("").reduce((e,r)=>{let n=(e<<5)-e+r.charCodeAt(0);return n&n},0)-48),"hashCode"),Q=F;function M(t,e){let r=S[Q(e||"")%S.length]||[];return(0,W.colorize)(t,r)}o(M,"themeizeRandom");function x(t,e){let r=e?$[e]:[];return(0,W.colorize)(t,r)}o(x,"themeize");var pt=(0,Z.getEnvVar)("LOG_VIEW","short"),y=o((t,e)=>String(t).padStart(e),"leftPad"),ht=o((t,e)=>String(t).padEnd(e),"rightPad"),R=20,dt=o((t,e=0)=>(R=Math.max(t&&t.length||0,R,e),ht(t,R)),"prettyPath"),q=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),xt=o(t=>{let e=q(t);return e||(e=t!==200?"log":null),x(y(String(t),3),e)},"prettyStatus"),yt=o(t=>y(`#${t}`,3),"prettyReqId"),Lt=o(t=>{let e=t==="REMOVE"?"error":t==="WS"?"debug":null;return x(y(t,4),e)},"prettyMethod"),bt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=t>=10*1e3?"error":t>=3*1e3?"warn":null,s=["m","s","ms"].includes(e)?e:"",i=Math.floor(Math.abs(t)*10**6),l=(0,j.default)(i,s);return x(y(l,5),r)},"prettyTime"),vt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=(0,K.default)(t,{maximumFractionDigits:1}).split(" "),n=r[1];return`${+r[0]>=100?Math.round(+r[0]):+r[0]}${e}${n}`},"prettySize"),tt=o((t,e)=>[...t,e].filter(Boolean).map(String).map(n=>M(n,n)).join(":"),"prettyNs");function kt(t){let e=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],r=e[F(t)%e.length];return M(r,String(t))}o(kt,"prettyMarker");var A=o(t=>{let e=pt==="short"?(t[0]||"").toLowerCase():y(t,5);return e=`[${e}]`,x(e,t)},"prettyLevel"),wt=/\[[^"\]]+]/gm,et=o((...t)=>{let e=[];return t.forEach(r=>{if(typeof r=="string"){let n=0;e.push(r.replace(wt,s=>(0,X.colorize)(s,_[n++%_.length])))}else e.push(r)}),e},"prettyContent"),St=o(t=>q(t.status)||C(t)?"debug":"trace","getUrlLevel"),rt=o(t=>{let e=C(t),r=St(t);return[A(r),[kt(t.reqId),Lt(t.method)].join(""),dt(t.url),yt(t.reqId),e&&t.method!=="WS"?xt(t.status):null,!e&&"\u29D7\u29D6\u29D7",e&&bt(t.duration),e&&t.method!=="WS"?vt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function _t(t,e){let r=0;return t.forEach((n,s)=>{s===r&&e(n)&&(r+=1)}),r}o(_t,"countInRow");function Bt(...t){let e=_t(t,r=>typeof r=="string");return[t.slice(0,e).join(" "),...t.slice(e)]}o(Bt,"concatFirstStrings");function ot(t,...e){let r=t?.ns,n=t?.name,s=t?.level||"log",i=e;if(p(t))return[rt(t)];let l=(r||"").split(":").filter(Boolean).map(String),a=[A(s)];return(l.length||n)&&a.push(tt(l,n)),Bt(...a,...et(...i))}o(ot,"prettyFormat");function I(t,e){Array.isArray(t)||(t=[t]);for(let r=0;r<t.length;r++)if(t[r].test(e))return!0;return!1}o(I,"anyRegExps");var d=class{static{o(this,"Logger")}prefix;ns;name;format=B;level="trace";on=[];off=[];constructor(e={}){typeof e=="string"?this.setProps({name:e,...E()}):this.setProps(e)}setProps({prefix:e,ns:r,name:n,level:s,format:i,on:l=[],off:a=[]}){if(e&&(this.prefix=e),r&&(this.ns=r),l&&(this.on=l),a&&(this.off=a),n&&(this.name=n),i&&(this.format=i),s){if(!w[s])throw new Error(`Incorrect level: ${this.level}`);this.level=s}this.level||(this.level="trace"),this.level||(this.level="trace"),this.format||(this.format="lsk"),this.off||(this.off=[]),this.on||(this.on=[])}static create(e){return new this(e)}createChild(...e){let r=[this.ns,this.name].filter(Boolean).join(".");return new this.constructor(this,{colors:null,ns:r},...e)}getLevelPriority(e){return w[e]||0}canLog(e){let r=this.getLevelPriority(e),n=this.getLevelPriority(this.level);return this.ns&&I(this.off,this.ns)?!1:this.ns&&I(this.on,this.ns)?!0:r>=n}fatal(...e){this.canLog("fatal")&&this.__log("fatal",...e)}error(...e){this.canLog("error")&&this.__log("error",...e)}warn(...e){this.canLog("warn")&&this.__log("warn",...e)}debug(...e){this.canLog("debug")&&this.__log("debug",...e)}info(...e){this.canLog("info")&&this.__log("info",...e)}trace(...e){this.canLog("trace")&&this.__log("trace",...e)}log(...e){console._log?console._log(...e):console.log(...e)}__log(e,...r){let[n,...s]=r,i={name:this.name,ns:this.ns,level:e,time:new Date},l=r;if(p(n)&&(i={...i,...n},l=s),this.format==="none")return;let a=(0,nt.omitNull)(i);if(this.format==="pretty"){this.log(...ot(a,...l));return}this.log(H(this.format||"lsk",a,...l))}},G=d;0&&(module.exports={Logger}); | ||
//# sourceMappingURL=Logger.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var wt=Object.create;var g=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var _t=Object.getOwnPropertyNames;var Bt=Object.getPrototypeOf,Et=Object.prototype.hasOwnProperty;var o=(t,r)=>g(t,"name",{value:r,configurable:!0});var T=(t,r)=>{for(var e in r)g(t,e,{get:r[e],enumerable:!0})},y=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of _t(r))!Et.call(t,s)&&s!==e&&g(t,s,{get:()=>r[s],enumerable:!(n=St(r,s))||n.enumerable});return t},x=(t,r,e)=>(y(t,r,"default"),e&&y(e,r,"default")),b=(t,r,e)=>(e=t!=null?wt(Bt(t)):{},y(r||!t||!t.__esModule?g(e,"default",{value:t,enumerable:!0}):e,t)),Ct=t=>y(g({},"__esModule",{value:!0}),t);var Dt={};T(Dt,{concatFirstStrings:()=>ft,countInRow:()=>at,getStatusLevel:()=>I,getUrlLevel:()=>lt,prettyContent:()=>N,prettyFormat:()=>p,prettyLevel:()=>L,prettyMarker:()=>it,prettyMethod:()=>ot,prettyNs:()=>O,prettyPath:()=>tt,prettyRawLog:()=>zt,prettyReqId:()=>et,prettySize:()=>st,prettyStatus:()=>rt,prettyTime:()=>nt,prettyUrl:()=>$});module.exports=Ct(Dt);var i;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(i||(i={}));var It=require("@lskjs/algos");var z={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},v=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],k=[["bold","white"],["bold","cyan"],["bold","green"],["white"]];var Ft=require("@lskjs/algos"),w=require("@lskjs/env");var B=require("@lskjs/err");var m={};T(m,{default:()=>D.default,stringify:()=>S.default});x(m,require("fast-safe-stringify"));var S=b(require("fast-safe-stringify")),D=b(require("fast-safe-stringify"));var G=require("@lskjs/env");var u=o((t,r)=>{let e=[];return t!==null&&e.push((0,G.tryJSONparse)(t)),Object.keys(r).length&&e.push(r),e},"parseArgs");var Rt={10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"};var U=o(t=>!!(t.name&&t.hostname&&t.pid&&t.msg&&t.time),"isBunyan"),V=o(t=>{let{level:r,time:e,msg:n,hostname:s,pid:l,v:a,...f}=t;return{format:i.bunyan,meta:{level:Rt[r],time:new Date(e)},args:u(n,f)}},"parseBunyan");var Wt=["trace","debug","info","warning","error","fatal","panic"],Mt={trace:"trace",debug:"debug",info:"info",warning:"warn",error:"error",fatal:"fatal",panic:"fatal"};var E=o(t=>!!(t.msg&&Wt.includes(t.level)),"isLogrus"),J=o(t=>{let{level:r,time:e,msg:n,...s}=t;return{format:i.logrus,meta:{level:Mt[r],time:new Date(e)},args:u(n,s)}},"parseLogrus");function Pt(t){return U(t)?i.bunyan:H(t)?i.lsklog:c(t)?i.lsklogweb:E(t)&&C(t)&&t?.name?i.lsklog:E(t)?i.logrus:C(t)?i.lsklog:null}o(Pt,"detectFormat");function Y(t){let r=Pt(t);return r==="bunyan"?V(t):r==="lsklogweb"?F(t):r==="lsklog"?F(t):r==="logrus"?J(t):{format:r,meta:{},args:[t]}}o(Y,"parse");var Q=["trace","debug","info","warn","error","fatal"];var H=o(t=>!!(Q.includes(t.level)&&t.ns),"isLsklog"),C=o(t=>!!Q.includes(t.level),"isLskLikelog"),c=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),R=o(t=>!!(c(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal"),F=o(t=>{let{level:r,time:e,msg:n,ns:s,name:l,...a}=t,f={level:r,time:e,msg:n,ns:s,name:l};if(!c(t))return{format:i.lsklogweb,meta:f,args:u(n,a)};let{reqId:pt,method:gt,host:ht,ua:dt,ip:yt,url:xt,status:bt,length:Lt,duration:vt,...kt}=a;return{format:i.lsklog,meta:{...f,method:gt,host:ht,reqId:pt,ua:dt,ip:yt,url:xt,status:bt,duration:vt,length:Lt},args:u(n,kt)}},"parseLsklog");var Z=require("@lskjs/colors"),K=require("@lskjs/env"),j=b(require("pretty-bytes")),q=b(require("pretty-time"));var M=require("@lskjs/colors");var W=o(t=>typeof t=="number"?t:Math.abs(String(t).split("").reduce((r,e)=>{let n=(r<<5)-r+e.charCodeAt(0);return n&n},0)-48),"hashCode"),X=W;function P(t,r){let e=v[X(r||"")%v.length]||[];return(0,M.colorize)(t,e)}o(P,"themeizeRandom");function h(t,r){let e=r?z[r]:[];return(0,M.colorize)(t,e)}o(h,"themeize");var Ot=(0,K.getEnvVar)("LOG_VIEW","short"),d=o((t,r)=>String(t).padStart(r),"leftPad"),Nt=o((t,r)=>String(t).padEnd(r),"rightPad"),A=20,tt=o((t,r=0)=>(A=Math.max(t&&t.length||0,A,r),Nt(t,A)),"prettyPath"),I=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),rt=o(t=>{let r=I(t);return r||(r=t!==200?"log":null),h(d(String(t),3),r)},"prettyStatus"),et=o(t=>d(`#${t}`,3),"prettyReqId"),ot=o(t=>{let r=t==="REMOVE"?"error":t==="WS"?"debug":null;return h(d(t,4),r)},"prettyMethod"),nt=o((t,r="")=>{if(!Number.isFinite(t))return null;let e=t>=10*1e3?"error":t>=3*1e3?"warn":null,s=["m","s","ms"].includes(r)?r:"",l=Math.floor(Math.abs(t)*10**6),a=(0,q.default)(l,s);return h(d(a,5),e)},"prettyTime"),st=o((t,r="")=>{if(!Number.isFinite(t))return null;let e=(0,j.default)(t,{maximumFractionDigits:1}).split(" "),n=e[1];return`${+e[0]>=100?Math.round(+e[0]):+e[0]}${r}${n}`},"prettySize"),O=o((t,r)=>[...t,r].filter(Boolean).map(String).map(n=>P(n,n)).join(":"),"prettyNs");function it(t){let r=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],e=r[W(t)%r.length];return P(e,String(t))}o(it,"prettyMarker");var L=o(t=>{let r=Ot==="short"?(t[0]||"").toLowerCase():d(t,5);return r=`[${r}]`,h(r,t)},"prettyLevel"),$t=/\[[^"\]]+]/gm,N=o((...t)=>{let r=[];return t.forEach(e=>{if(typeof e=="string"){let n=0;r.push(e.replace($t,s=>(0,Z.colorize)(s,k[n++%k.length])))}else r.push(e)}),r},"prettyContent"),lt=o(t=>I(t.status)||R(t)?"debug":"trace","getUrlLevel"),$=o(t=>{let r=R(t),e=lt(t);return[L(e),[it(t.reqId),ot(t.method)].join(""),tt(t.url),et(t.reqId),r&&t.method!=="WS"?rt(t.status):null,!r&&"\u29D7\u29D6\u29D7",r&&nt(t.duration),r&&t.method!=="WS"?st(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function at(t,r){let e=0;return t.forEach((n,s)=>{s===e&&r(n)&&(e+=1)}),e}o(at,"countInRow");function ft(...t){let r=at(t,e=>typeof e=="string");return[t.slice(0,r).join(" "),...t.slice(r)]}o(ft,"concatFirstStrings");function p(t,...r){let e=t?.ns,n=t?.name,s=t?.level||"log",l=r;if(c(t))return[$(t)];let a=(e||"").split(":").filter(Boolean).map(String),f=[L(s)];return(a.length||n)&&f.push(O(a,n)),ft(...f,...N(...l))}o(p,"prettyFormat");var mt=require("@lskjs/env");var ut=require("@lskjs/algos");var Tt=require("logfmt"),ct=o((t,r=t)=>{try{if(typeof t!="string")return t;if(!t.trim())return r;let e=Tt.parse(t);return Object.keys(e).includes("")||Object.keys(e).length<2||(0,ut.count)(e,n=>n===!0)>=Object.keys(e).length/2?r:e}catch{return r}},"tryLogfmtParse");var zt=o((t,r)=>{let e,n;if(typeof r=="string"&&(!e&&r.trim()&&(e=(0,mt.tryJSONparse)(r,null),e!==null&&(n="json")),!e&&r.trim()&&(e=ct(r,null),e!==null&&(n="logfmt"))),e===null&&(e=null,n="raw"),!e){t.log(...p({},r));return}if(typeof e!="object"){t.log(...p({},e));return}let{meta:s,args:l=[]}=Y(e);t.log(...p(s,...l))},"prettyRawLog");0&&(module.exports={concatFirstStrings,countInRow,getStatusLevel,getUrlLevel,prettyContent,prettyFormat,prettyLevel,prettyMarker,prettyMethod,prettyNs,prettyPath,prettyRawLog,prettyReqId,prettySize,prettyStatus,prettyTime,prettyUrl}); | ||
"use strict";var wt=Object.create;var g=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var _t=Object.getOwnPropertyNames;var Bt=Object.getPrototypeOf,Et=Object.prototype.hasOwnProperty;var o=(t,r)=>g(t,"name",{value:r,configurable:!0});var T=(t,r)=>{for(var e in r)g(t,e,{get:r[e],enumerable:!0})},y=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of _t(r))!Et.call(t,s)&&s!==e&&g(t,s,{get:()=>r[s],enumerable:!(n=St(r,s))||n.enumerable});return t},x=(t,r,e)=>(y(t,r,"default"),e&&y(e,r,"default")),L=(t,r,e)=>(e=t!=null?wt(Bt(t)):{},y(r||!t||!t.__esModule?g(e,"default",{value:t,enumerable:!0}):e,t)),Ct=t=>y(g({},"__esModule",{value:!0}),t);var Dt={};T(Dt,{concatFirstStrings:()=>ft,countInRow:()=>at,getStatusLevel:()=>I,getUrlLevel:()=>lt,prettyContent:()=>N,prettyFormat:()=>p,prettyLevel:()=>b,prettyMarker:()=>it,prettyMethod:()=>ot,prettyNs:()=>O,prettyPath:()=>tt,prettyRawLog:()=>zt,prettyReqId:()=>et,prettySize:()=>st,prettyStatus:()=>rt,prettyTime:()=>nt,prettyUrl:()=>$});module.exports=Ct(Dt);var i;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(i||(i={}));var It=require("@lskjs/algos");var z={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},v=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],k=[["bold","white"],["bold","cyan"],["bold","green"],["white"]];var Ft=require("@lskjs/algos"),w=require("@lskjs/env");var B=require("@lskjs/err");var m={};T(m,{default:()=>D.default,stringify:()=>S.default});x(m,require("fast-safe-stringify"));var S=L(require("fast-safe-stringify")),D=L(require("fast-safe-stringify"));var G=require("@lskjs/env");var c=o((t,r)=>{let e=[];return t!==null&&e.push((0,G.tryJSONparse)(t)),Object.keys(r).length&&e.push(r),e},"parseArgs");var Rt={10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"};var U=o(t=>!!(t.name&&t.hostname&&t.pid&&t.msg&&t.time),"isBunyan"),V=o(t=>{let{level:r,time:e,msg:n,hostname:s,pid:l,v:a,...f}=t;return{format:i.bunyan,meta:{level:Rt[r],time:new Date(e)},args:c(n,f)}},"parseBunyan");var Wt=["trace","debug","info","warning","error","fatal","panic"],Mt={trace:"trace",debug:"debug",info:"info",warning:"warn",error:"error",fatal:"fatal",panic:"fatal"};var E=o(t=>!!(t.msg&&Wt.includes(t.level)),"isLogrus"),J=o(t=>{let{level:r,time:e,msg:n,...s}=t;return{format:i.logrus,meta:{level:Mt[r],time:new Date(e)},args:c(n,s)}},"parseLogrus");function Pt(t){return U(t)?i.bunyan:H(t)?i.lsklog:u(t)?i.lsklogweb:E(t)&&C(t)&&t?.name?i.lsklog:E(t)?i.logrus:C(t)?i.lsklog:null}o(Pt,"detectFormat");function Y(t){let r=Pt(t);return r==="bunyan"?V(t):r==="lsklogweb"?F(t):r==="lsklog"?F(t):r==="logrus"?J(t):{format:r,meta:{},args:[t]}}o(Y,"parse");var Q=["trace","debug","info","warn","error","fatal"];var H=o(t=>!!(Q.includes(t.level)&&t.ns),"isLsklog"),C=o(t=>!!Q.includes(t.level),"isLskLikelog"),u=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),R=o(t=>!!(u(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal"),F=o(t=>{let{level:r,time:e,msg:n,ns:s,name:l,...a}=t,f={level:r,time:e,msg:n,ns:s,name:l};if(!u(t))return{format:i.lsklogweb,meta:f,args:c(n,a)};let{reqId:pt,method:gt,host:ht,ua:dt,ip:yt,url:xt,status:Lt,length:bt,duration:vt,...kt}=a;return{format:i.lsklog,meta:{...f,method:gt,host:ht,reqId:pt,ua:dt,ip:yt,url:xt,status:Lt,duration:vt,length:bt},args:c(n,kt)}},"parseLsklog");var Z=require("@lskjs/colors"),K=require("@lskjs/env"),j=L(require("pretty-bytes")),q=L(require("pretty-time"));var M=require("@lskjs/colors");var W=o(t=>typeof t=="number"?t:Math.abs(String(t).split("").reduce((r,e)=>{let n=(r<<5)-r+e.charCodeAt(0);return n&n},0)-48),"hashCode"),X=W;function P(t,r){let e=v[X(r||"")%v.length]||[];return(0,M.colorize)(t,e)}o(P,"themeizeRandom");function h(t,r){let e=r?z[r]:[];return(0,M.colorize)(t,e)}o(h,"themeize");var Ot=(0,K.getEnvVar)("LOG_VIEW","short"),d=o((t,r)=>String(t).padStart(r),"leftPad"),Nt=o((t,r)=>String(t).padEnd(r),"rightPad"),A=20,tt=o((t,r=0)=>(A=Math.max(t&&t.length||0,A,r),Nt(t,A)),"prettyPath"),I=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),rt=o(t=>{let r=I(t);return r||(r=t!==200?"log":null),h(d(String(t),3),r)},"prettyStatus"),et=o(t=>d(`#${t}`,3),"prettyReqId"),ot=o(t=>{let r=t==="REMOVE"?"error":t==="WS"?"debug":null;return h(d(t,4),r)},"prettyMethod"),nt=o((t,r="")=>{if(!Number.isFinite(t))return null;let e=t>=10*1e3?"error":t>=3*1e3?"warn":null,s=["m","s","ms"].includes(r)?r:"",l=Math.floor(Math.abs(t)*10**6),a=(0,q.default)(l,s);return h(d(a,5),e)},"prettyTime"),st=o((t,r="")=>{if(!Number.isFinite(t))return null;let e=(0,j.default)(t,{maximumFractionDigits:1}).split(" "),n=e[1];return`${+e[0]>=100?Math.round(+e[0]):+e[0]}${r}${n}`},"prettySize"),O=o((t,r)=>[...t,r].filter(Boolean).map(String).map(n=>P(n,n)).join(":"),"prettyNs");function it(t){let r=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],e=r[W(t)%r.length];return P(e,String(t))}o(it,"prettyMarker");var b=o(t=>{let r=Ot==="short"?(t[0]||"").toLowerCase():d(t,5);return r=`[${r}]`,h(r,t)},"prettyLevel"),$t=/\[[^"\]]+]/gm,N=o((...t)=>{let r=[];return t.forEach(e=>{if(typeof e=="string"){let n=0;r.push(e.replace($t,s=>(0,Z.colorize)(s,k[n++%k.length])))}else r.push(e)}),r},"prettyContent"),lt=o(t=>I(t.status)||R(t)?"debug":"trace","getUrlLevel"),$=o(t=>{let r=R(t),e=lt(t);return[b(e),[it(t.reqId),ot(t.method)].join(""),tt(t.url),et(t.reqId),r&&t.method!=="WS"?rt(t.status):null,!r&&"\u29D7\u29D6\u29D7",r&&nt(t.duration),r&&t.method!=="WS"?st(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function at(t,r){let e=0;return t.forEach((n,s)=>{s===e&&r(n)&&(e+=1)}),e}o(at,"countInRow");function ft(...t){let r=at(t,e=>typeof e=="string");return[t.slice(0,r).join(" "),...t.slice(r)]}o(ft,"concatFirstStrings");function p(t,...r){let e=t?.ns,n=t?.name,s=t?.level||"log",l=r;if(u(t))return[$(t)];let a=(e||"").split(":").filter(Boolean).map(String),f=[b(s)];return(a.length||n)&&f.push(O(a,n)),ft(...f,...N(...l))}o(p,"prettyFormat");var mt=require("@lskjs/env");var ct=require("@lskjs/algos");var Tt=require("logfmt"),ut=o((t,r=t)=>{try{if(typeof t!="string")return t;if(!t.trim())return r;let e=Tt.parse(t);return Object.keys(e).includes("")||Object.keys(e).length<2||(0,ct.count)(e,n=>n===!0)>=Object.keys(e).length/2?r:e}catch{return r}},"tryLogfmtParse");var zt=o((t,r)=>{let e,n;if(typeof r=="string"&&(!e&&r.trim()&&(e=(0,mt.tryJSONparse)(r,null),e!==null&&(n="json")),!e&&r.trim()&&(e=ut(r,null),e!==null&&(n="logfmt"))),e===null&&(e=null,n="raw"),!e){t.log(...p({},r));return}if(typeof e!="object"){t.log(...p({},e));return}let{meta:s,args:l=[]}=Y(e);t.log(...p(s,...l))},"prettyRawLog");0&&(module.exports={concatFirstStrings,countInRow,getStatusLevel,getUrlLevel,prettyContent,prettyFormat,prettyLevel,prettyMarker,prettyMethod,prettyNs,prettyPath,prettyRawLog,prettyReqId,prettySize,prettyStatus,prettyTime,prettyUrl}); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var gt=Object.create;var p=Object.defineProperty;var ht=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var yt=Object.getPrototypeOf,xt=Object.prototype.hasOwnProperty;var o=(t,r)=>p(t,"name",{value:r,configurable:!0});var I=(t,r)=>{for(var e in r)p(t,e,{get:r[e],enumerable:!0})},y=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of dt(r))!xt.call(t,s)&&s!==e&&p(t,s,{get:()=>r[s],enumerable:!(n=ht(r,s))||n.enumerable});return t},x=(t,r,e)=>(y(t,r,"default"),e&&y(e,r,"default")),b=(t,r,e)=>(e=t!=null?gt(yt(t)):{},y(r||!t||!t.__esModule?p(e,"default",{value:t,enumerable:!0}):e,t)),bt=t=>y(p({},"__esModule",{value:!0}),t);var Gt={};I(Gt,{default:()=>Dt,prettyRawLog:()=>ot});module.exports=bt(Gt);var et=require("@lskjs/env");var O=require("@lskjs/algos");var Lt=require("logfmt"),N=o((t,r=t)=>{try{if(typeof t!="string")return t;if(!t.trim())return r;let e=Lt.parse(t);return Object.keys(e).includes("")||Object.keys(e).length<2||(0,O.count)(e,n=>n===!0)>=Object.keys(e).length/2?r:e}catch{return r}},"tryLogfmtParse");var i;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(i||(i={}));var k=require("@lskjs/err");var m={};I(m,{default:()=>$.default,stringify:()=>L.default});x(m,require("fast-safe-stringify"));var L=b(require("fast-safe-stringify")),$=b(require("fast-safe-stringify"));var Ot=require("@lskjs/algos");var T={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},w=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],S=[["bold","white"],["bold","cyan"],["bold","green"],["white"]];var vt=require("@lskjs/algos"),_=require("@lskjs/env");var z=require("@lskjs/env");var u=o((t,r)=>{let e=[];return t!==null&&e.push((0,z.tryJSONparse)(t)),Object.keys(r).length&&e.push(r),e},"parseArgs");var D=["trace","debug","info","warn","error","fatal"];var G=o(t=>!!(D.includes(t.level)&&t.ns),"isLsklog"),B=o(t=>!!D.includes(t.level),"isLskLikelog"),c=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),E=o(t=>!!(c(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal"),C=o(t=>{let{level:r,time:e,msg:n,ns:s,name:l,...a}=t,f={level:r,time:e,msg:n,ns:s,name:l};if(!c(t))return{format:i.lsklogweb,meta:f,args:u(n,a)};let{reqId:nt,method:st,host:it,ua:lt,ip:at,url:ft,status:ut,length:ct,duration:mt,...pt}=a;return{format:i.lsklog,meta:{...f,method:st,host:it,reqId:nt,ua:lt,ip:at,url:ft,status:ut,duration:mt,length:ct},args:u(n,pt)}},"parseLsklog");var V=require("@lskjs/colors"),J=require("@lskjs/env"),Y=b(require("pretty-bytes")),H=b(require("pretty-time"));var R=require("@lskjs/colors");var F=o(t=>typeof t=="number"?t:Math.abs(String(t).split("").reduce((r,e)=>{let n=(r<<5)-r+e.charCodeAt(0);return n&n},0)-48),"hashCode"),U=F;function W(t,r){let e=w[U(r||"")%w.length]||[];return(0,R.colorize)(t,e)}o(W,"themeizeRandom");function g(t,r){let e=r?T[r]:[];return(0,R.colorize)(t,e)}o(g,"themeize");var kt=(0,J.getEnvVar)("LOG_VIEW","short"),h=o((t,r)=>String(t).padStart(r),"leftPad"),wt=o((t,r)=>String(t).padEnd(r),"rightPad"),M=20,St=o((t,r=0)=>(M=Math.max(t&&t.length||0,M,r),wt(t,M)),"prettyPath"),Q=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),_t=o(t=>{let r=Q(t);return r||(r=t!==200?"log":null),g(h(String(t),3),r)},"prettyStatus"),Bt=o(t=>h(`#${t}`,3),"prettyReqId"),Et=o(t=>{let r=t==="REMOVE"?"error":t==="WS"?"debug":null;return g(h(t,4),r)},"prettyMethod"),Ct=o((t,r="")=>{if(!Number.isFinite(t))return null;let e=t>=10*1e3?"error":t>=3*1e3?"warn":null,s=["m","s","ms"].includes(r)?r:"",l=Math.floor(Math.abs(t)*10**6),a=(0,H.default)(l,s);return g(h(a,5),e)},"prettyTime"),Ft=o((t,r="")=>{if(!Number.isFinite(t))return null;let e=(0,Y.default)(t,{maximumFractionDigits:1}).split(" "),n=e[1];return`${+e[0]>=100?Math.round(+e[0]):+e[0]}${r}${n}`},"prettySize"),X=o((t,r)=>[...t,r].filter(Boolean).map(String).map(n=>W(n,n)).join(":"),"prettyNs");function Rt(t){let r=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],e=r[F(t)%r.length];return W(e,String(t))}o(Rt,"prettyMarker");var P=o(t=>{let r=kt==="short"?(t[0]||"").toLowerCase():h(t,5);return r=`[${r}]`,g(r,t)},"prettyLevel"),Wt=/\[[^"\]]+]/gm,Z=o((...t)=>{let r=[];return t.forEach(e=>{if(typeof e=="string"){let n=0;r.push(e.replace(Wt,s=>(0,V.colorize)(s,S[n++%S.length])))}else r.push(e)}),r},"prettyContent"),Mt=o(t=>Q(t.status)||E(t)?"debug":"trace","getUrlLevel"),K=o(t=>{let r=E(t),e=Mt(t);return[P(e),[Rt(t.reqId),Et(t.method)].join(""),St(t.url),Bt(t.reqId),r&&t.method!=="WS"?_t(t.status):null,!r&&"\u29D7\u29D6\u29D7",r&&Ct(t.duration),r&&t.method!=="WS"?Ft(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function Pt(t,r){let e=0;return t.forEach((n,s)=>{s===e&&r(n)&&(e+=1)}),e}o(Pt,"countInRow");function At(...t){let r=Pt(t,e=>typeof e=="string");return[t.slice(0,r).join(" "),...t.slice(r)]}o(At,"concatFirstStrings");function d(t,...r){let e=t?.ns,n=t?.name,s=t?.level||"log",l=r;if(c(t))return[K(t)];let a=(e||"").split(":").filter(Boolean).map(String),f=[P(s)];return(a.length||n)&&f.push(X(a,n)),At(...f,...Z(...l))}o(d,"prettyFormat");var Nt={10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"};var j=o(t=>!!(t.name&&t.hostname&&t.pid&&t.msg&&t.time),"isBunyan"),q=o(t=>{let{level:r,time:e,msg:n,hostname:s,pid:l,v:a,...f}=t;return{format:i.bunyan,meta:{level:Nt[r],time:new Date(e)},args:u(n,f)}},"parseBunyan");var $t=["trace","debug","info","warning","error","fatal","panic"],Tt={trace:"trace",debug:"debug",info:"info",warning:"warn",error:"error",fatal:"fatal",panic:"fatal"};var A=o(t=>!!(t.msg&&$t.includes(t.level)),"isLogrus"),tt=o(t=>{let{level:r,time:e,msg:n,...s}=t;return{format:i.logrus,meta:{level:Tt[r],time:new Date(e)},args:u(n,s)}},"parseLogrus");function zt(t){return j(t)?i.bunyan:G(t)?i.lsklog:c(t)?i.lsklogweb:A(t)&&B(t)&&t?.name?i.lsklog:A(t)?i.logrus:B(t)?i.lsklog:null}o(zt,"detectFormat");function rt(t){let r=zt(t);return r==="bunyan"?q(t):r==="lsklogweb"?C(t):r==="lsklog"?C(t):r==="logrus"?tt(t):{format:r,meta:{},args:[t]}}o(rt,"parse");var ot=o((t,r)=>{let e,n;if(typeof r=="string"&&(!e&&r.trim()&&(e=(0,et.tryJSONparse)(r,null),e!==null&&(n="json")),!e&&r.trim()&&(e=N(r,null),e!==null&&(n="logfmt"))),e===null&&(e=null,n="raw"),!e){t.log(...d({},r));return}if(typeof e!="object"){t.log(...d({},e));return}let{meta:s,args:l=[]}=rt(e);t.log(...d(s,...l))},"prettyRawLog"),Dt=ot;0&&(module.exports={prettyRawLog}); | ||
"use strict";var pt=Object.create;var g=Object.defineProperty;var ht=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var yt=Object.getPrototypeOf,xt=Object.prototype.hasOwnProperty;var o=(t,r)=>g(t,"name",{value:r,configurable:!0});var I=(t,r)=>{for(var e in r)g(t,e,{get:r[e],enumerable:!0})},y=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of dt(r))!xt.call(t,s)&&s!==e&&g(t,s,{get:()=>r[s],enumerable:!(n=ht(r,s))||n.enumerable});return t},x=(t,r,e)=>(y(t,r,"default"),e&&y(e,r,"default")),L=(t,r,e)=>(e=t!=null?pt(yt(t)):{},y(r||!t||!t.__esModule?g(e,"default",{value:t,enumerable:!0}):e,t)),Lt=t=>y(g({},"__esModule",{value:!0}),t);var Gt={};I(Gt,{default:()=>Dt,prettyRawLog:()=>ot});module.exports=Lt(Gt);var et=require("@lskjs/env");var O=require("@lskjs/algos");var bt=require("logfmt"),N=o((t,r=t)=>{try{if(typeof t!="string")return t;if(!t.trim())return r;let e=bt.parse(t);return Object.keys(e).includes("")||Object.keys(e).length<2||(0,O.count)(e,n=>n===!0)>=Object.keys(e).length/2?r:e}catch{return r}},"tryLogfmtParse");var i;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(i||(i={}));var k=require("@lskjs/err");var m={};I(m,{default:()=>$.default,stringify:()=>b.default});x(m,require("fast-safe-stringify"));var b=L(require("fast-safe-stringify")),$=L(require("fast-safe-stringify"));var Ot=require("@lskjs/algos");var T={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},w=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],S=[["bold","white"],["bold","cyan"],["bold","green"],["white"]];var vt=require("@lskjs/algos"),_=require("@lskjs/env");var z=require("@lskjs/env");var c=o((t,r)=>{let e=[];return t!==null&&e.push((0,z.tryJSONparse)(t)),Object.keys(r).length&&e.push(r),e},"parseArgs");var D=["trace","debug","info","warn","error","fatal"];var G=o(t=>!!(D.includes(t.level)&&t.ns),"isLsklog"),B=o(t=>!!D.includes(t.level),"isLskLikelog"),u=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),E=o(t=>!!(u(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal"),C=o(t=>{let{level:r,time:e,msg:n,ns:s,name:l,...a}=t,f={level:r,time:e,msg:n,ns:s,name:l};if(!u(t))return{format:i.lsklogweb,meta:f,args:c(n,a)};let{reqId:nt,method:st,host:it,ua:lt,ip:at,url:ft,status:ct,length:ut,duration:mt,...gt}=a;return{format:i.lsklog,meta:{...f,method:st,host:it,reqId:nt,ua:lt,ip:at,url:ft,status:ct,duration:mt,length:ut},args:c(n,gt)}},"parseLsklog");var V=require("@lskjs/colors"),J=require("@lskjs/env"),Y=L(require("pretty-bytes")),H=L(require("pretty-time"));var R=require("@lskjs/colors");var F=o(t=>typeof t=="number"?t:Math.abs(String(t).split("").reduce((r,e)=>{let n=(r<<5)-r+e.charCodeAt(0);return n&n},0)-48),"hashCode"),U=F;function W(t,r){let e=w[U(r||"")%w.length]||[];return(0,R.colorize)(t,e)}o(W,"themeizeRandom");function p(t,r){let e=r?T[r]:[];return(0,R.colorize)(t,e)}o(p,"themeize");var kt=(0,J.getEnvVar)("LOG_VIEW","short"),h=o((t,r)=>String(t).padStart(r),"leftPad"),wt=o((t,r)=>String(t).padEnd(r),"rightPad"),M=20,St=o((t,r=0)=>(M=Math.max(t&&t.length||0,M,r),wt(t,M)),"prettyPath"),Q=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),_t=o(t=>{let r=Q(t);return r||(r=t!==200?"log":null),p(h(String(t),3),r)},"prettyStatus"),Bt=o(t=>h(`#${t}`,3),"prettyReqId"),Et=o(t=>{let r=t==="REMOVE"?"error":t==="WS"?"debug":null;return p(h(t,4),r)},"prettyMethod"),Ct=o((t,r="")=>{if(!Number.isFinite(t))return null;let e=t>=10*1e3?"error":t>=3*1e3?"warn":null,s=["m","s","ms"].includes(r)?r:"",l=Math.floor(Math.abs(t)*10**6),a=(0,H.default)(l,s);return p(h(a,5),e)},"prettyTime"),Ft=o((t,r="")=>{if(!Number.isFinite(t))return null;let e=(0,Y.default)(t,{maximumFractionDigits:1}).split(" "),n=e[1];return`${+e[0]>=100?Math.round(+e[0]):+e[0]}${r}${n}`},"prettySize"),X=o((t,r)=>[...t,r].filter(Boolean).map(String).map(n=>W(n,n)).join(":"),"prettyNs");function Rt(t){let r=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],e=r[F(t)%r.length];return W(e,String(t))}o(Rt,"prettyMarker");var P=o(t=>{let r=kt==="short"?(t[0]||"").toLowerCase():h(t,5);return r=`[${r}]`,p(r,t)},"prettyLevel"),Wt=/\[[^"\]]+]/gm,Z=o((...t)=>{let r=[];return t.forEach(e=>{if(typeof e=="string"){let n=0;r.push(e.replace(Wt,s=>(0,V.colorize)(s,S[n++%S.length])))}else r.push(e)}),r},"prettyContent"),Mt=o(t=>Q(t.status)||E(t)?"debug":"trace","getUrlLevel"),K=o(t=>{let r=E(t),e=Mt(t);return[P(e),[Rt(t.reqId),Et(t.method)].join(""),St(t.url),Bt(t.reqId),r&&t.method!=="WS"?_t(t.status):null,!r&&"\u29D7\u29D6\u29D7",r&&Ct(t.duration),r&&t.method!=="WS"?Ft(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function Pt(t,r){let e=0;return t.forEach((n,s)=>{s===e&&r(n)&&(e+=1)}),e}o(Pt,"countInRow");function At(...t){let r=Pt(t,e=>typeof e=="string");return[t.slice(0,r).join(" "),...t.slice(r)]}o(At,"concatFirstStrings");function d(t,...r){let e=t?.ns,n=t?.name,s=t?.level||"log",l=r;if(u(t))return[K(t)];let a=(e||"").split(":").filter(Boolean).map(String),f=[P(s)];return(a.length||n)&&f.push(X(a,n)),At(...f,...Z(...l))}o(d,"prettyFormat");var Nt={10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"};var j=o(t=>!!(t.name&&t.hostname&&t.pid&&t.msg&&t.time),"isBunyan"),q=o(t=>{let{level:r,time:e,msg:n,hostname:s,pid:l,v:a,...f}=t;return{format:i.bunyan,meta:{level:Nt[r],time:new Date(e)},args:c(n,f)}},"parseBunyan");var $t=["trace","debug","info","warning","error","fatal","panic"],Tt={trace:"trace",debug:"debug",info:"info",warning:"warn",error:"error",fatal:"fatal",panic:"fatal"};var A=o(t=>!!(t.msg&&$t.includes(t.level)),"isLogrus"),tt=o(t=>{let{level:r,time:e,msg:n,...s}=t;return{format:i.logrus,meta:{level:Tt[r],time:new Date(e)},args:c(n,s)}},"parseLogrus");function zt(t){return j(t)?i.bunyan:G(t)?i.lsklog:u(t)?i.lsklogweb:A(t)&&B(t)&&t?.name?i.lsklog:A(t)?i.logrus:B(t)?i.lsklog:null}o(zt,"detectFormat");function rt(t){let r=zt(t);return r==="bunyan"?q(t):r==="lsklogweb"?C(t):r==="lsklog"?C(t):r==="logrus"?tt(t):{format:r,meta:{},args:[t]}}o(rt,"parse");var ot=o((t,r)=>{let e,n;if(typeof r=="string"&&(!e&&r.trim()&&(e=(0,et.tryJSONparse)(r,null),e!==null&&(n="json")),!e&&r.trim()&&(e=N(r,null),e!==null&&(n="logfmt"))),e===null&&(e=null,n="raw"),!e){t.log(...d({},r));return}if(typeof e!="object"){t.log(...d({},e));return}let{meta:s,args:l=[]}=rt(e);t.log(...d(s,...l))},"prettyRawLog"),Dt=ot;0&&(module.exports={prettyRawLog}); | ||
//# sourceMappingURL=prettyRawLog.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var st=Object.create;var d=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,ft=Object.prototype.hasOwnProperty;var o=(t,e)=>d(t,"name",{value:e,configurable:!0});var $=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},L=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of lt(e))!ft.call(t,s)&&s!==r&&d(t,s,{get:()=>e[s],enumerable:!(n=it(e,s))||n.enumerable});return t},b=(t,e,r)=>(L(t,e,"default"),r&&L(r,e,"default")),v=(t,e,r)=>(r=t!=null?st(at(t)):{},L(e||!t||!t.__esModule?d(r,"default",{value:t,enumerable:!0}):r,t)),ct=t=>L(d({},"__esModule",{value:!0}),t);var Et={};$(Et,{Logger:()=>p,default:()=>C});module.exports=ct(Et);var nt=require("@lskjs/algos");var w={start:99,log:99,fatal:60,error:50,warn:40,success:35,info:30,debug:20,trace:10},N={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},S=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],_=[["bold","white"],["bold","cyan"],["bold","green"],["white"]];var T=require("@lskjs/algos"),f=require("@lskjs/env");function O(t=""){let e=[],r=[],n,s=(typeof t=="string"?t:"").split(/[\s,]+/);for(n=0;n<s.length;n++){if(!s[n])continue;let i=s[n].replace(/\*/g,".*?");i[0]==="-"?r.push(new RegExp(`^${i.slice(1)}$`)):e.push(new RegExp(`^${i}$`))}return{on:e,off:r}}o(O,"parseNs");var B=f.isDev||f.isClient?"pretty":"lsk",E=o(()=>{let t=(0,f.getEnvVar)("DEBUG","")||"",e=process.argv?.includes("--silent"),r=t.startsWith("lsk")||t.startsWith("*"),n=(0,f.getEnvVar)("LOG_FORMAT",(0,f.getEnvVar)("DEBUG_FORMAT",B)),{on:s,off:i}=O(t),a=(0,f.getEnvVar)("LOG_LEVEL",(0,f.getEnvVar)("DEBUG_LEVEL",e?"error":r?"trace":"debug"));return(0,T.omitNull)({format:n,level:a,on:s,off:i})},"getEnvConfig");var g;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(g||(g={}));var u=require("@lskjs/err");var m={};$(m,{default:()=>z.default,stringify:()=>k.default});b(m,require("fast-safe-stringify"));var k=v(require("fast-safe-stringify")),z=v(require("fast-safe-stringify"));var c=o((t,e=null,r=0)=>typeof t=="object"?(0,k.default)(t,e,r):String(t),"toString");var D=o(t=>t.map(e=>(0,u.isError)(e)?(0,u.getCode)(e):null).filter(Boolean)[0],"getErrCode"),G=o(t=>t.length?t.map(e=>(0,u.isError)(e)?(0,u.getMessage)(e):c(e)).join(" "):null,"createMsg");var ut=require("@lskjs/env");var gt={log:10,trace:10,debug:20,info:30,warn:40,error:50,fatal:60};var V=o(t=>{let{level:e,time:r,...n}=t;return c({level:gt[e],time:r.toISOString(),...n})},"stringifyBunyan");var mt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"};var J=o(t=>{let{level:e,time:r,...n}=t;return c({level:mt[e],time:r.toISOString(),...n})},"stringifyLogrus");var h=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),F=o(t=>!!(h(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal");var Y=o(t=>{let{level:e,time:r,...n}=t;return c({level:e,time:+r,...n})},"stringifyLsklog");function H(t,e,...r){let n=D(r),s=G(r),i={code:n,...e,msg:s};return t==="bunyan"?V(i):t==="logrus"?J(i):Y(i)}o(H,"stringify");var X=require("@lskjs/colors"),Z=require("@lskjs/env"),K=v(require("pretty-bytes")),j=v(require("pretty-time"));var M=require("@lskjs/colors");var W=o(t=>typeof t=="number"?t:Math.abs(String(t).split("").reduce((e,r)=>{let n=(e<<5)-e+r.charCodeAt(0);return n&n},0)-48),"hashCode"),Q=W;function R(t,e){let r=S[Q(e||"")%S.length]||[];return(0,M.colorize)(t,r)}o(R,"themeizeRandom");function x(t,e){let r=e?N[e]:[];return(0,M.colorize)(t,r)}o(x,"themeize");var pt=(0,Z.getEnvVar)("LOG_VIEW","short"),y=o((t,e)=>String(t).padStart(e),"leftPad"),ht=o((t,e)=>String(t).padEnd(e),"rightPad"),A=20,dt=o((t,e=0)=>(A=Math.max(t&&t.length||0,A,e),ht(t,A)),"prettyPath"),q=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),xt=o(t=>{let e=q(t);return e||(e=t!==200?"log":null),x(y(String(t),3),e)},"prettyStatus"),yt=o(t=>y(`#${t}`,3),"prettyReqId"),Lt=o(t=>{let e=t==="REMOVE"?"error":t==="WS"?"debug":null;return x(y(t,4),e)},"prettyMethod"),bt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=t>=10*1e3?"error":t>=3*1e3?"warn":null,s=["m","s","ms"].includes(e)?e:"",i=Math.floor(Math.abs(t)*10**6),l=(0,j.default)(i,s);return x(y(l,5),r)},"prettyTime"),vt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=(0,K.default)(t,{maximumFractionDigits:1}).split(" "),n=r[1];return`${+r[0]>=100?Math.round(+r[0]):+r[0]}${e}${n}`},"prettySize"),tt=o((t,e)=>[...t,e].filter(Boolean).map(String).map(n=>R(n,n)).join(":"),"prettyNs");function kt(t){let e=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],r=e[W(t)%e.length];return R(r,String(t))}o(kt,"prettyMarker");var I=o(t=>{let e=pt==="short"?(t[0]||"").toLowerCase():y(t,5);return e=`[${e}]`,x(e,t)},"prettyLevel"),wt=/\[[^"\]]+]/gm,et=o((...t)=>{let e=[];return t.forEach(r=>{if(typeof r=="string"){let n=0;e.push(r.replace(wt,s=>(0,X.colorize)(s,_[n++%_.length])))}else e.push(r)}),e},"prettyContent"),St=o(t=>q(t.status)||F(t)?"debug":"trace","getUrlLevel"),rt=o(t=>{let e=F(t),r=St(t);return[I(r),[kt(t.reqId),Lt(t.method)].join(""),dt(t.url),yt(t.reqId),e&&t.method!=="WS"?xt(t.status):null,!e&&"\u29D7\u29D6\u29D7",e&&bt(t.duration),e&&t.method!=="WS"?vt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function _t(t,e){let r=0;return t.forEach((n,s)=>{s===r&&e(n)&&(r+=1)}),r}o(_t,"countInRow");function Bt(...t){let e=_t(t,r=>typeof r=="string");return[t.slice(0,e).join(" "),...t.slice(e)]}o(Bt,"concatFirstStrings");function ot(t,...e){let r=t?.ns,n=t?.name,s=t?.level||"log",i=e;if(h(t))return[rt(t)];let l=(r||"").split(":").filter(Boolean).map(String),a=[I(s)];return(l.length||n)&&a.push(tt(l,n)),Bt(...a,...et(...i))}o(ot,"prettyFormat");function P(t,e){Array.isArray(t)||(t=[t]);for(let r=0;r<t.length;r++)if(t[r].test(e))return!0;return!1}o(P,"anyRegExps");var p=class{prefix;ns;name;format=B;level="trace";on=[];off=[];constructor(e={}){typeof e=="string"?this.setProps({name:e,...E()}):this.setProps(e)}setProps({prefix:e,ns:r,name:n,level:s,format:i,on:l=[],off:a=[]}){if(e&&(this.prefix=e),r&&(this.ns=r),l&&(this.on=l),a&&(this.off=a),n&&(this.name=n),i&&(this.format=i),s){if(!w[s])throw new Error(`Incorrect level: ${this.level}`);this.level=s}this.level||(this.level="trace"),this.level||(this.level="trace"),this.format||(this.format="lsk"),this.off||(this.off=[]),this.on||(this.on=[])}static create(e){return new this(e)}createChild(...e){let r=[this.ns,this.name].filter(Boolean).join(".");return new this.constructor(this,{colors:null,ns:r},...e)}getLevelPriority(e){return w[e]||0}canLog(e){let r=this.getLevelPriority(e),n=this.getLevelPriority(this.level);return this.ns&&P(this.off,this.ns)?!1:this.ns&&P(this.on,this.ns)?!0:r>=n}fatal(...e){this.canLog("fatal")&&this.__log("fatal",...e)}error(...e){this.canLog("error")&&this.__log("error",...e)}warn(...e){this.canLog("warn")&&this.__log("warn",...e)}debug(...e){this.canLog("debug")&&this.__log("debug",...e)}info(...e){this.canLog("info")&&this.__log("info",...e)}trace(...e){this.canLog("trace")&&this.__log("trace",...e)}log(...e){console._log?console._log(...e):console.log(...e)}__log(e,...r){let[n,...s]=r,i={name:this.name,ns:this.ns,level:e,time:new Date},l=r;if(h(n)&&(i={...i,...n},l=s),this.format==="none")return;let a=(0,nt.omitNull)(i);if(this.format==="pretty"){this.log(...ot(a,...l));return}this.log(H(this.format||"lsk",a,...l))}};o(p,"Logger");var C=p;0&&(module.exports={Logger}); | ||
"use strict";var st=Object.create;var h=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,ft=Object.prototype.hasOwnProperty;var o=(t,e)=>h(t,"name",{value:e,configurable:!0});var $=(t,e)=>{for(var r in e)h(t,r,{get:e[r],enumerable:!0})},L=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of lt(e))!ft.call(t,s)&&s!==r&&h(t,s,{get:()=>e[s],enumerable:!(n=it(e,s))||n.enumerable});return t},b=(t,e,r)=>(L(t,e,"default"),r&&L(r,e,"default")),v=(t,e,r)=>(r=t!=null?st(at(t)):{},L(e||!t||!t.__esModule?h(r,"default",{value:t,enumerable:!0}):r,t)),ct=t=>L(h({},"__esModule",{value:!0}),t);var Et={};$(Et,{Logger:()=>d,default:()=>C});module.exports=ct(Et);var nt=require("@lskjs/algos");var w={start:99,log:99,fatal:60,error:50,warn:40,success:35,info:30,debug:20,trace:10},N={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},S=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],_=[["bold","white"],["bold","cyan"],["bold","green"],["white"]];var T=require("@lskjs/algos"),f=require("@lskjs/env");function O(t=""){let e=[],r=[],n,s=(typeof t=="string"?t:"").split(/[\s,]+/);for(n=0;n<s.length;n++){if(!s[n])continue;let i=s[n].replace(/\*/g,".*?");i[0]==="-"?r.push(new RegExp(`^${i.slice(1)}$`)):e.push(new RegExp(`^${i}$`))}return{on:e,off:r}}o(O,"parseNs");var B=f.isDev||f.isClient?"pretty":"lsk",E=o(()=>{let t=(0,f.getEnvVar)("DEBUG","")||"",e=process.argv?.includes("--silent"),r=t.startsWith("lsk")||t.startsWith("*"),n=(0,f.getEnvVar)("LOG_FORMAT",(0,f.getEnvVar)("DEBUG_FORMAT",B)),{on:s,off:i}=O(t),a=(0,f.getEnvVar)("LOG_LEVEL",(0,f.getEnvVar)("DEBUG_LEVEL",e?"error":r?"trace":"debug"));return(0,T.omitNull)({format:n,level:a,on:s,off:i})},"getEnvConfig");var g;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(g||(g={}));var u=require("@lskjs/err");var m={};$(m,{default:()=>z.default,stringify:()=>k.default});b(m,require("fast-safe-stringify"));var k=v(require("fast-safe-stringify")),z=v(require("fast-safe-stringify"));var c=o((t,e=null,r=0)=>typeof t=="object"?(0,k.default)(t,e,r):String(t),"toString");var D=o(t=>t.map(e=>(0,u.isError)(e)?(0,u.getCode)(e):null).filter(Boolean)[0],"getErrCode"),G=o(t=>t.length?t.map(e=>(0,u.isError)(e)?(0,u.getMessage)(e):c(e)).join(" "):null,"createMsg");var ut=require("@lskjs/env");var gt={log:10,trace:10,debug:20,info:30,warn:40,error:50,fatal:60};var V=o(t=>{let{level:e,time:r,...n}=t;return c({level:gt[e],time:r.toISOString(),...n})},"stringifyBunyan");var mt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"};var J=o(t=>{let{level:e,time:r,...n}=t;return c({level:mt[e],time:r.toISOString(),...n})},"stringifyLogrus");var p=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),F=o(t=>!!(p(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal");var Y=o(t=>{let{level:e,time:r,...n}=t;return c({level:e,time:+r,...n})},"stringifyLsklog");function H(t,e,...r){let n=D(r),s=G(r),i={code:n,...e,msg:s};return t==="bunyan"?V(i):t==="logrus"?J(i):Y(i)}o(H,"stringify");var X=require("@lskjs/colors"),Z=require("@lskjs/env"),K=v(require("pretty-bytes")),j=v(require("pretty-time"));var M=require("@lskjs/colors");var W=o(t=>typeof t=="number"?t:Math.abs(String(t).split("").reduce((e,r)=>{let n=(e<<5)-e+r.charCodeAt(0);return n&n},0)-48),"hashCode"),Q=W;function R(t,e){let r=S[Q(e||"")%S.length]||[];return(0,M.colorize)(t,r)}o(R,"themeizeRandom");function x(t,e){let r=e?N[e]:[];return(0,M.colorize)(t,r)}o(x,"themeize");var pt=(0,Z.getEnvVar)("LOG_VIEW","short"),y=o((t,e)=>String(t).padStart(e),"leftPad"),ht=o((t,e)=>String(t).padEnd(e),"rightPad"),A=20,dt=o((t,e=0)=>(A=Math.max(t&&t.length||0,A,e),ht(t,A)),"prettyPath"),q=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),xt=o(t=>{let e=q(t);return e||(e=t!==200?"log":null),x(y(String(t),3),e)},"prettyStatus"),yt=o(t=>y(`#${t}`,3),"prettyReqId"),Lt=o(t=>{let e=t==="REMOVE"?"error":t==="WS"?"debug":null;return x(y(t,4),e)},"prettyMethod"),bt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=t>=10*1e3?"error":t>=3*1e3?"warn":null,s=["m","s","ms"].includes(e)?e:"",i=Math.floor(Math.abs(t)*10**6),l=(0,j.default)(i,s);return x(y(l,5),r)},"prettyTime"),vt=o((t,e="")=>{if(!Number.isFinite(t))return null;let r=(0,K.default)(t,{maximumFractionDigits:1}).split(" "),n=r[1];return`${+r[0]>=100?Math.round(+r[0]):+r[0]}${e}${n}`},"prettySize"),tt=o((t,e)=>[...t,e].filter(Boolean).map(String).map(n=>R(n,n)).join(":"),"prettyNs");function kt(t){let e=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],r=e[W(t)%e.length];return R(r,String(t))}o(kt,"prettyMarker");var I=o(t=>{let e=pt==="short"?(t[0]||"").toLowerCase():y(t,5);return e=`[${e}]`,x(e,t)},"prettyLevel"),wt=/\[[^"\]]+]/gm,et=o((...t)=>{let e=[];return t.forEach(r=>{if(typeof r=="string"){let n=0;e.push(r.replace(wt,s=>(0,X.colorize)(s,_[n++%_.length])))}else e.push(r)}),e},"prettyContent"),St=o(t=>q(t.status)||F(t)?"debug":"trace","getUrlLevel"),rt=o(t=>{let e=F(t),r=St(t);return[I(r),[kt(t.reqId),Lt(t.method)].join(""),dt(t.url),yt(t.reqId),e&&t.method!=="WS"?xt(t.status):null,!e&&"\u29D7\u29D6\u29D7",e&&bt(t.duration),e&&t.method!=="WS"?vt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function _t(t,e){let r=0;return t.forEach((n,s)=>{s===r&&e(n)&&(r+=1)}),r}o(_t,"countInRow");function Bt(...t){let e=_t(t,r=>typeof r=="string");return[t.slice(0,e).join(" "),...t.slice(e)]}o(Bt,"concatFirstStrings");function ot(t,...e){let r=t?.ns,n=t?.name,s=t?.level||"log",i=e;if(p(t))return[rt(t)];let l=(r||"").split(":").filter(Boolean).map(String),a=[I(s)];return(l.length||n)&&a.push(tt(l,n)),Bt(...a,...et(...i))}o(ot,"prettyFormat");function P(t,e){Array.isArray(t)||(t=[t]);for(let r=0;r<t.length;r++)if(t[r].test(e))return!0;return!1}o(P,"anyRegExps");var d=class{static{o(this,"Logger")}prefix;ns;name;format=B;level="trace";on=[];off=[];constructor(e={}){typeof e=="string"?this.setProps({name:e,...E()}):this.setProps(e)}setProps({prefix:e,ns:r,name:n,level:s,format:i,on:l=[],off:a=[]}){if(e&&(this.prefix=e),r&&(this.ns=r),l&&(this.on=l),a&&(this.off=a),n&&(this.name=n),i&&(this.format=i),s){if(!w[s])throw new Error(`Incorrect level: ${this.level}`);this.level=s}this.level||(this.level="trace"),this.level||(this.level="trace"),this.format||(this.format="lsk"),this.off||(this.off=[]),this.on||(this.on=[])}static create(e){return new this(e)}createChild(...e){let r=[this.ns,this.name].filter(Boolean).join(".");return new this.constructor(this,{colors:null,ns:r},...e)}getLevelPriority(e){return w[e]||0}canLog(e){let r=this.getLevelPriority(e),n=this.getLevelPriority(this.level);return this.ns&&P(this.off,this.ns)?!1:this.ns&&P(this.on,this.ns)?!0:r>=n}fatal(...e){this.canLog("fatal")&&this.__log("fatal",...e)}error(...e){this.canLog("error")&&this.__log("error",...e)}warn(...e){this.canLog("warn")&&this.__log("warn",...e)}debug(...e){this.canLog("debug")&&this.__log("debug",...e)}info(...e){this.canLog("info")&&this.__log("info",...e)}trace(...e){this.canLog("trace")&&this.__log("trace",...e)}log(...e){console._log?console._log(...e):console.log(...e)}__log(e,...r){let[n,...s]=r,i={name:this.name,ns:this.ns,level:e,time:new Date},l=r;if(p(n)&&(i={...i,...n},l=s),this.format==="none")return;let a=(0,nt.omitNull)(i);if(this.format==="pretty"){this.log(...ot(a,...l));return}this.log(H(this.format||"lsk",a,...l))}},C=d;0&&(module.exports={Logger}); | ||
//# sourceMappingURL=server.js.map |
{ | ||
"name": "@lskjs/log", | ||
"version": "3.9.0", | ||
"version": "3.11.0", | ||
"description": "Yet another logger whitch combines the best features of debug, bunyan, logfmt/logrus, morgan/winston", | ||
@@ -10,6 +10,6 @@ "author": "Igor Suvorov <hi@isuvorov.com> (https://github.com/isuvorov)", | ||
"dependencies": { | ||
"@lskjs/algos": "^3.9.0", | ||
"@lskjs/colors": "^3.8.1", | ||
"@lskjs/env": "^3.8.1", | ||
"@lskjs/err": "^3.9.0", | ||
"@lskjs/algos": "^3.11.0", | ||
"@lskjs/colors": "^3.11.0", | ||
"@lskjs/env": "^3.11.0", | ||
"@lskjs/err": "^3.11.0", | ||
"fast-safe-stringify": "2.1.1", | ||
@@ -66,3 +66,3 @@ "pretty-bytes": "5.6.0", | ||
], | ||
"gitHead": "22a143f05ea47becc32b36d58e9445d1fa6099d4" | ||
"gitHead": "150463ce96bcc80a2187339a44762e7807cbf41c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
173
23
15
1294423
1021
Updated@lskjs/algos@^3.11.0
Updated@lskjs/colors@^3.11.0
Updated@lskjs/env@^3.11.0
Updated@lskjs/err@^3.11.0