@lskjs/log
Advanced tools
Comparing version 3.5.2 to 3.5.3
#!/usr/bin/env node | ||
"use strict";var Ot=Object.create;var v=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var Wt=Object.getOwnPropertyNames;var At=Object.getPrototypeOf,Mt=Object.prototype.hasOwnProperty;var o=(t,r)=>v(t,"name",{value:r,configurable:!0});var Pt=(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 Wt(r))!Mt.call(t,s)&&s!==e&&v(t,s,{get:()=>r[s],enumerable:!(n=It(r,s))||n.enumerable});return t},k=(t,r,e)=>(_(t,r,"default"),e&&_(e,r,"default")),m=(t,r,e)=>(e=t!=null?Ot(At(t)):{},_(r||!t||!t.__esModule?v(e,"default",{value:t,enumerable:!0}):e,t));var xt=m(require("readline")),Lt=m(require("split")),bt=m(require("through"));var z=require("@lskjs/algos"),p=require("@lskjs/env");function T(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(T,"parseNs");var E=p.isDev||p.isClient?"pretty":"lsk",w=o(()=>{let t=(0,p.getEnvVar)("DEBUG","")||"",r=process.argv?.includes("--silent"),e=t.startsWith("lsk")||t.startsWith("*"),n=(0,p.getEnvVar)("LOG_FORMAT",(0,p.getEnvVar)("DEBUG_FORMAT",E)),{on:s,off:i}=T(t),a=(0,p.getEnvVar)("LOG_LEVEL",(0,p.getEnvVar)("DEBUG_LEVEL",r?"error":e?"trace":"debug"));return(0,z.omitNull)({format:n,level:a,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},G={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 f;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(f||(f={}));var g=require("@lskjs/err");var d={};Pt(d,{default:()=>U.default,stringify:()=>S.default});k(d,require("fast-safe-stringify"));var S=m(require("fast-safe-stringify")),U=m(require("fast-safe-stringify"));var u=o((t,r=null,e=0)=>typeof t=="object"?(0,S.default)(t,r,e):String(t),"toString");var V=o(t=>t.map(r=>(0,g.isError)(r)?(0,g.getCode)(r):null).filter(Boolean)[0],"getErrCode"),J=o(t=>t.length?t.map(r=>(0,g.isError)(r)?(0,g.getMessage)(r):u(r)).join(" "):null,"createMsg");var Y=require("@lskjs/env");var h=o((t,r)=>{let e=[];return t!==null&&e.push((0,Y.tryJSONparse)(t)),Object.keys(r).length&&e.push(r),e},"parseArgs");var Nt={10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"},$t={log:10,trace:10,debug:20,info:30,warn:40,error:50,fatal:60},H=o(t=>!!(t.name&&t.hostname&&t.pid&&t.msg&&t.time),"isBunyan"),K=o(t=>{let{level:r,time:e,msg:n,hostname:s,pid:i,v:l,...a}=t;return{format:f.bunyan,meta:{level:Nt[r],time:new Date(e)},args:h(n,a)}},"parseBunyan"),Q=o(t=>{let{level:r,time:e,...n}=t;return u({level:$t[r],time:e.toISOString(),...n})},"stringifyBunyan");var Dt=["trace","debug","info","warning","error","fatal","panic"],Tt={trace:"trace",debug:"debug",info:"info",warning:"warn",error:"error",fatal:"fatal",panic:"fatal"},zt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"},X=o(t=>!!(t.msg&&Dt.includes(t.level)),"isLogrus"),Z=o(t=>{let{level:r,time:e,msg:n,...s}=t;return{format:f.logrus,meta:{level:Tt[r],time:new Date(e)},args:h(n,s)}},"parseLogrus"),j=o(t=>{let{level:r,time:e,...n}=t;return u({level:zt[r],time:e.toISOString(),...n})},"stringifyLogrus");var q=["trace","debug","info","warn","error","fatal"];var tt=o(t=>!!(q.includes(t.level)&&t.ns),"isLsklog"),rt=o(t=>!!q.includes(t.level),"isLskLikelog"),c=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),F=o(t=>!!(c(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal"),O=o(t=>{let{level:r,time:e,msg:n,ns:s,name:i,...l}=t,a={level:r,time:e,msg:n,ns:s,name:i};if(!c(t))return{format:f.lsklogweb,meta:a,args:h(n,l)};let{reqId:vt,method:kt,host:wt,ua:St,ip:_t,url:Et,status:Bt,length:Ct,duration:Rt,...Ft}=l;return{format:f.lsklog,meta:{...a,method:kt,host:wt,reqId:vt,ua:St,ip:_t,url:Et,status:Bt,duration:Rt,length:Ct},args:h(n,Ft)}},"parseLsklog"),et=o(t=>{let{level:r,time:e,...n}=t;return u({level:r,time:+e,...n})},"stringifyLsklog");function Gt(t){return H(t)?f.bunyan:tt(t)?f.lsklog:c(t)?f.lsklogweb:X(t)?f.logrus:rt(t)?f.lsklog:null}o(Gt,"detectFormat");function ot(t,r,...e){let n=V(e),s=J(e),i={code:n,...r,msg:s};return t==="bunyan"?Q(i):t==="logrus"?j(i):et(i)}o(ot,"stringify");function nt(t){let r=Gt(t);return r==="bunyan"?K(t):r==="lsklogweb"?O(t):r==="lsklog"?O(t):r==="logrus"?Z(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 W=require("@lskjs/colors");var I=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=I;function A(t,r){let e=C[st(r||"")%C.length]||[];return(0,W.colorize)(t,e)}o(A,"themeizeRandom");function x(t,r){let e=r?G[r]:[];return(0,W.colorize)(t,e)}o(x,"themeize");var Ut=(0,lt.getEnvVar)("LOG_VIEW","short"),L=o((t,r)=>String(t).padStart(r),"leftPad"),Vt=o((t,r)=>String(t).padEnd(r),"rightPad"),M=20,Jt=o((t,r=0)=>(M=Math.max(t&&t.length||0,M,r),Vt(t,M)),"prettyPath"),pt=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),Yt=o(t=>{let r=pt(t);return r||(r=t!==200?"log":null),x(L(String(t),3),r)},"prettyStatus"),Ht=o(t=>L(`#${t}`,3),"prettyReqId"),Kt=o(t=>{let r=t==="REMOVE"?"error":t==="WS"?"debug":null;return x(L(t,4),r)},"prettyMethod"),Qt=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"),Xt=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"),ut=o((t,r)=>[...t,r].filter(Boolean).map(String).map(n=>A(n,n)).join(":"),"prettyNs");function Zt(t){let r=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],e=r[I(t)%r.length];return A(e,String(t))}o(Zt,"prettyMarker");var P=o(t=>{let r=Ut==="short"?(t[0]||"").toLowerCase():L(t,5);return r=`[${r}]`,x(r,t)},"prettyLevel"),jt=/\[[^"\]]+]/gm,ct=o((...t)=>{let r=[];return t.forEach(e=>{if(typeof e=="string"){let n=0;r.push(e.replace(jt,s=>(0,it.colorize)(s,R[n++%R.length])))}else r.push(e)}),r},"prettyContent"),qt=o(t=>pt(t.status)||F(t)?"debug":"trace","getUrlLevel"),mt=o(t=>{let r=F(t),e=qt(t);return[P(e),[Zt(t.reqId),Kt(t.method)].join(""),Jt(t.url),Ht(t.reqId),r&&t.method!=="WS"?Yt(t.status):null,!r&&"\u29D7\u29D6\u29D7",r&&Qt(t.duration),r&&t.method!=="WS"?Xt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function tr(t,r){let e=0;return t.forEach((n,s)=>{s===e&&r(n)&&(e+=1)}),e}o(tr,"countInRow");function rr(...t){let r=tr(t,e=>typeof e=="string");return[t.slice(0,r).join(" "),...t.slice(r)]}o(rr,"concatFirstStrings");function y(t,...r){let e=t?.ns,n=t?.name,s=t?.level||"log",i=r;if(c(t))return[mt(t)];let l=(e||"").split(":").filter(Boolean).map(String),a=[P(s)];return(l.length||n)&&a.push(ut(l,n)),rr(...a,...ct(...i))}o(y,"prettyFormat");function N(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(N,"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:a=[]}){if(r&&(this.prefix=r),e&&(this.ns=e),l&&(this.on=l),a&&(this.off=a),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&&N(this.off,this.ns)?!1:this.ns&&N(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(c(n)&&(i={...i,...n},l=s),this.format==="none")return;let a=(0,gt.omitNull)(i);if(this.format==="pretty"){this.log(...y(a,...l));return}this.log(ot(this.format||"lsk",a,...l))}};o(b,"Logger");var $=new b(w());var yt=require("@lskjs/env");var ht=require("@lskjs/algos");var er=require("logfmt"),dt=o((t,r=t)=>{try{if(typeof t!="string")return t;if(!t.trim())return r;let e=er.parse(t);return Object.keys(e).includes("")||Object.keys(e).length<2||(0,ht.count)(e,n=>n===!0)>=Object.keys(e).length/2?r:e}catch{return r}},"tryLogfmtParse");var D=o((t,r)=>{let e,n;if(typeof r=="string"&&(!e&&r.trim()&&(e=(0,yt.tryJSONparse)(r,null),e!==null&&(n="json")),!e&&r.trim()&&(e=dt(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"?xt.default.createInterface({input:process.stdin}).on("line",t=>{D($,t)}):process.stdin.pipe((0,Lt.default)()).pipe((0,bt.default)(function(t){if(!t){this.emit("data",`${t} | ||
`);return}D($,t)})).pipe(process.stdout); | ||
"use strict";var Ot=Object.create;var v=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var Wt=Object.getOwnPropertyNames;var At=Object.getPrototypeOf,Mt=Object.prototype.hasOwnProperty;var o=(t,r)=>v(t,"name",{value:r,configurable:!0});var Pt=(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 Wt(r))!Mt.call(t,s)&&s!==e&&v(t,s,{get:()=>r[s],enumerable:!(n=It(r,s))||n.enumerable});return t},k=(t,r,e)=>(_(t,r,"default"),e&&_(e,r,"default")),m=(t,r,e)=>(e=t!=null?Ot(At(t)):{},_(r||!t||!t.__esModule?v(e,"default",{value:t,enumerable:!0}):e,t));var xt=m(require("readline")),Lt=m(require("split")),bt=m(require("through"));var U=require("@lskjs/algos"),p=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=p.isDev||p.isClient?"pretty":"lsk",w=o(()=>{let t=(0,p.getEnvVar)("DEBUG","")||"",r=process.argv?.includes("--silent"),e=t.startsWith("lsk")||t.startsWith("*"),n=(0,p.getEnvVar)("LOG_FORMAT",(0,p.getEnvVar)("DEBUG_FORMAT",E)),{on:s,off:i}=G(t),f=(0,p.getEnvVar)("LOG_LEVEL",(0,p.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={};Pt(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 u=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):u(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 Nt={10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"},$t={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:Nt[r],time:new Date(e)},args:h(n,f)}},"parseBunyan"),Z=o(t=>{let{level:r,time:e,...n}=t;return u({level:$t[r],time:e.toISOString(),...n})},"stringifyBunyan");var Dt=["trace","debug","info","warning","error","fatal","panic"],Tt={trace:"trace",debug:"debug",info:"info",warning:"warn",error:"error",fatal:"fatal",panic:"fatal"},zt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"},F=o(t=>!!(t.msg&&Dt.includes(t.level)),"isLogrus"),j=o(t=>{let{level:r,time:e,msg:n,...s}=t;return{format:a.logrus,meta:{level:Tt[r],time:new Date(e)},args:h(n,s)}},"parseLogrus"),q=o(t=>{let{level:r,time:e,...n}=t;return u({level:zt[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"),O=o(t=>!!tt.includes(t.level),"isLskLikelog"),c=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),I=o(t=>!!(c(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal"),W=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(!c(t))return{format:a.lsklogweb,meta:f,args:h(n,l)};let{reqId:vt,method:kt,host:wt,ua:St,ip:_t,url:Et,status:Bt,length:Ct,duration:Rt,...Ft}=l;return{format:a.lsklog,meta:{...f,method:kt,host:wt,reqId:vt,ua:St,ip:_t,url:Et,status:Bt,duration:Rt,length:Ct},args:h(n,Ft)}},"parseLsklog"),et=o(t=>{let{level:r,time:e,...n}=t;return u({level:r,time:+e,...n})},"stringifyLsklog");function Gt(t){return Q(t)?a.bunyan:rt(t)?a.lsklog:c(t)?a.lsklogweb:F(t)&&O(t)&&t?.name?a.lsklog:F(t)?a.logrus:O(t)?a.lsklog:null}o(Gt,"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=Gt(t);return r==="bunyan"?X(t):r==="lsklogweb"?W(t):r==="lsklog"?W(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 M=require("@lskjs/colors");var A=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=A;function P(t,r){let e=C[st(r||"")%C.length]||[];return(0,M.colorize)(t,e)}o(P,"themeizeRandom");function x(t,r){let e=r?V[r]:[];return(0,M.colorize)(t,e)}o(x,"themeize");var Ut=(0,lt.getEnvVar)("LOG_VIEW","short"),L=o((t,r)=>String(t).padStart(r),"leftPad"),Vt=o((t,r)=>String(t).padEnd(r),"rightPad"),N=20,Jt=o((t,r=0)=>(N=Math.max(t&&t.length||0,N,r),Vt(t,N)),"prettyPath"),pt=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),Yt=o(t=>{let r=pt(t);return r||(r=t!==200?"log":null),x(L(String(t),3),r)},"prettyStatus"),Ht=o(t=>L(`#${t}`,3),"prettyReqId"),Kt=o(t=>{let r=t==="REMOVE"?"error":t==="WS"?"debug":null;return x(L(t,4),r)},"prettyMethod"),Qt=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"),Xt=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"),ut=o((t,r)=>[...t,r].filter(Boolean).map(String).map(n=>P(n,n)).join(":"),"prettyNs");function Zt(t){let r=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],e=r[A(t)%r.length];return P(e,String(t))}o(Zt,"prettyMarker");var $=o(t=>{let r=Ut==="short"?(t[0]||"").toLowerCase():L(t,5);return r=`[${r}]`,x(r,t)},"prettyLevel"),jt=/\[[^"\]]+]/gm,ct=o((...t)=>{let r=[];return t.forEach(e=>{if(typeof e=="string"){let n=0;r.push(e.replace(jt,s=>(0,it.colorize)(s,R[n++%R.length])))}else r.push(e)}),r},"prettyContent"),qt=o(t=>pt(t.status)||I(t)?"debug":"trace","getUrlLevel"),mt=o(t=>{let r=I(t),e=qt(t);return[$(e),[Zt(t.reqId),Kt(t.method)].join(""),Jt(t.url),Ht(t.reqId),r&&t.method!=="WS"?Yt(t.status):null,!r&&"\u29D7\u29D6\u29D7",r&&Qt(t.duration),r&&t.method!=="WS"?Xt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function tr(t,r){let e=0;return t.forEach((n,s)=>{s===e&&r(n)&&(e+=1)}),e}o(tr,"countInRow");function rr(...t){let r=tr(t,e=>typeof e=="string");return[t.slice(0,r).join(" "),...t.slice(r)]}o(rr,"concatFirstStrings");function y(t,...r){let e=t?.ns,n=t?.name,s=t?.level||"log",i=r;if(c(t))return[mt(t)];let l=(e||"").split(":").filter(Boolean).map(String),f=[$(s)];return(l.length||n)&&f.push(ut(l,n)),rr(...f,...ct(...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(c(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 T=new b(w());var yt=require("@lskjs/env");var ht=require("@lskjs/algos");var er=require("logfmt"),dt=o((t,r=t)=>{try{if(typeof t!="string")return t;if(!t.trim())return r;let e=er.parse(t);return Object.keys(e).includes("")||Object.keys(e).length<2||(0,ht.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,yt.tryJSONparse)(r,null),e!==null&&(n="json")),!e&&r.trim()&&(e=dt(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"?xt.default.createInterface({input:process.stdin}).on("line",t=>{z(T,t)}):process.stdin.pipe((0,Lt.default)()).pipe((0,bt.default)(function(t){if(!t){this.emit("data",`${t} | ||
`);return}z(T,t)})).pipe(process.stdout); | ||
//# sourceMappingURL=cli.js.map |
#!/usr/bin/env node | ||
"use strict";var Ot=Object.create;var v=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var Wt=Object.getOwnPropertyNames;var At=Object.getPrototypeOf,Mt=Object.prototype.hasOwnProperty;var o=(t,r)=>v(t,"name",{value:r,configurable:!0});var Pt=(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 Wt(r))!Mt.call(t,s)&&s!==e&&v(t,s,{get:()=>r[s],enumerable:!(n=It(r,s))||n.enumerable});return t},k=(t,r,e)=>(_(t,r,"default"),e&&_(e,r,"default")),m=(t,r,e)=>(e=t!=null?Ot(At(t)):{},_(r||!t||!t.__esModule?v(e,"default",{value:t,enumerable:!0}):e,t));var xt=m(require("readline")),Lt=m(require("split")),bt=m(require("through"));var z=require("@lskjs/algos"),p=require("@lskjs/env");function T(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(T,"parseNs");var E=p.isDev||p.isClient?"pretty":"lsk",w=o(()=>{let t=(0,p.getEnvVar)("DEBUG","")||"",r=process.argv?.includes("--silent"),e=t.startsWith("lsk")||t.startsWith("*"),n=(0,p.getEnvVar)("LOG_FORMAT",(0,p.getEnvVar)("DEBUG_FORMAT",E)),{on:s,off:i}=T(t),a=(0,p.getEnvVar)("LOG_LEVEL",(0,p.getEnvVar)("DEBUG_LEVEL",r?"error":e?"trace":"debug"));return(0,z.omitNull)({format:n,level:a,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},G={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 f;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(f||(f={}));var g=require("@lskjs/err");var d={};Pt(d,{default:()=>U.default,stringify:()=>S.default});k(d,require("fast-safe-stringify"));var S=m(require("fast-safe-stringify")),U=m(require("fast-safe-stringify"));var u=o((t,r=null,e=0)=>typeof t=="object"?(0,S.default)(t,r,e):String(t),"toString");var V=o(t=>t.map(r=>(0,g.isError)(r)?(0,g.getCode)(r):null).filter(Boolean)[0],"getErrCode"),J=o(t=>t.length?t.map(r=>(0,g.isError)(r)?(0,g.getMessage)(r):u(r)).join(" "):null,"createMsg");var Y=require("@lskjs/env");var h=o((t,r)=>{let e=[];return t!==null&&e.push((0,Y.tryJSONparse)(t)),Object.keys(r).length&&e.push(r),e},"parseArgs");var Nt={10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"},$t={log:10,trace:10,debug:20,info:30,warn:40,error:50,fatal:60},H=o(t=>!!(t.name&&t.hostname&&t.pid&&t.msg&&t.time),"isBunyan"),K=o(t=>{let{level:r,time:e,msg:n,hostname:s,pid:i,v:l,...a}=t;return{format:f.bunyan,meta:{level:Nt[r],time:new Date(e)},args:h(n,a)}},"parseBunyan"),Q=o(t=>{let{level:r,time:e,...n}=t;return u({level:$t[r],time:e.toISOString(),...n})},"stringifyBunyan");var Dt=["trace","debug","info","warning","error","fatal","panic"],Tt={trace:"trace",debug:"debug",info:"info",warning:"warn",error:"error",fatal:"fatal",panic:"fatal"},zt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"},X=o(t=>!!(t.msg&&Dt.includes(t.level)),"isLogrus"),Z=o(t=>{let{level:r,time:e,msg:n,...s}=t;return{format:f.logrus,meta:{level:Tt[r],time:new Date(e)},args:h(n,s)}},"parseLogrus"),j=o(t=>{let{level:r,time:e,...n}=t;return u({level:zt[r],time:e.toISOString(),...n})},"stringifyLogrus");var q=["trace","debug","info","warn","error","fatal"];var tt=o(t=>!!(q.includes(t.level)&&t.ns),"isLsklog"),rt=o(t=>!!q.includes(t.level),"isLskLikelog"),c=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),F=o(t=>!!(c(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal"),O=o(t=>{let{level:r,time:e,msg:n,ns:s,name:i,...l}=t,a={level:r,time:e,msg:n,ns:s,name:i};if(!c(t))return{format:f.lsklogweb,meta:a,args:h(n,l)};let{reqId:vt,method:kt,host:wt,ua:St,ip:_t,url:Et,status:Bt,length:Ct,duration:Rt,...Ft}=l;return{format:f.lsklog,meta:{...a,method:kt,host:wt,reqId:vt,ua:St,ip:_t,url:Et,status:Bt,duration:Rt,length:Ct},args:h(n,Ft)}},"parseLsklog"),et=o(t=>{let{level:r,time:e,...n}=t;return u({level:r,time:+e,...n})},"stringifyLsklog");function Gt(t){return H(t)?f.bunyan:tt(t)?f.lsklog:c(t)?f.lsklogweb:X(t)?f.logrus:rt(t)?f.lsklog:null}o(Gt,"detectFormat");function ot(t,r,...e){let n=V(e),s=J(e),i={code:n,...r,msg:s};return t==="bunyan"?Q(i):t==="logrus"?j(i):et(i)}o(ot,"stringify");function nt(t){let r=Gt(t);return r==="bunyan"?K(t):r==="lsklogweb"?O(t):r==="lsklog"?O(t):r==="logrus"?Z(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 W=require("@lskjs/colors");var I=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=I;function A(t,r){let e=C[st(r||"")%C.length]||[];return(0,W.colorize)(t,e)}o(A,"themeizeRandom");function x(t,r){let e=r?G[r]:[];return(0,W.colorize)(t,e)}o(x,"themeize");var Ut=(0,lt.getEnvVar)("LOG_VIEW","short"),L=o((t,r)=>String(t).padStart(r),"leftPad"),Vt=o((t,r)=>String(t).padEnd(r),"rightPad"),M=20,Jt=o((t,r=0)=>(M=Math.max(t&&t.length||0,M,r),Vt(t,M)),"prettyPath"),pt=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),Yt=o(t=>{let r=pt(t);return r||(r=t!==200?"log":null),x(L(String(t),3),r)},"prettyStatus"),Ht=o(t=>L(`#${t}`,3),"prettyReqId"),Kt=o(t=>{let r=t==="REMOVE"?"error":t==="WS"?"debug":null;return x(L(t,4),r)},"prettyMethod"),Qt=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"),Xt=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"),ut=o((t,r)=>[...t,r].filter(Boolean).map(String).map(n=>A(n,n)).join(":"),"prettyNs");function Zt(t){let r=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],e=r[I(t)%r.length];return A(e,String(t))}o(Zt,"prettyMarker");var P=o(t=>{let r=Ut==="short"?(t[0]||"").toLowerCase():L(t,5);return r=`[${r}]`,x(r,t)},"prettyLevel"),jt=/\[[^"\]]+]/gm,ct=o((...t)=>{let r=[];return t.forEach(e=>{if(typeof e=="string"){let n=0;r.push(e.replace(jt,s=>(0,it.colorize)(s,R[n++%R.length])))}else r.push(e)}),r},"prettyContent"),qt=o(t=>pt(t.status)||F(t)?"debug":"trace","getUrlLevel"),mt=o(t=>{let r=F(t),e=qt(t);return[P(e),[Zt(t.reqId),Kt(t.method)].join(""),Jt(t.url),Ht(t.reqId),r&&t.method!=="WS"?Yt(t.status):null,!r&&"\u29D7\u29D6\u29D7",r&&Qt(t.duration),r&&t.method!=="WS"?Xt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function tr(t,r){let e=0;return t.forEach((n,s)=>{s===e&&r(n)&&(e+=1)}),e}o(tr,"countInRow");function rr(...t){let r=tr(t,e=>typeof e=="string");return[t.slice(0,r).join(" "),...t.slice(r)]}o(rr,"concatFirstStrings");function y(t,...r){let e=t?.ns,n=t?.name,s=t?.level||"log",i=r;if(c(t))return[mt(t)];let l=(e||"").split(":").filter(Boolean).map(String),a=[P(s)];return(l.length||n)&&a.push(ut(l,n)),rr(...a,...ct(...i))}o(y,"prettyFormat");function N(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(N,"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:a=[]}){if(r&&(this.prefix=r),e&&(this.ns=e),l&&(this.on=l),a&&(this.off=a),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&&N(this.off,this.ns)?!1:this.ns&&N(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(c(n)&&(i={...i,...n},l=s),this.format==="none")return;let a=(0,gt.omitNull)(i);if(this.format==="pretty"){this.log(...y(a,...l));return}this.log(ot(this.format||"lsk",a,...l))}};o(b,"Logger");var $=new b(w());var yt=require("@lskjs/env");var ht=require("@lskjs/algos");var er=require("logfmt"),dt=o((t,r=t)=>{try{if(typeof t!="string")return t;if(!t.trim())return r;let e=er.parse(t);return Object.keys(e).includes("")||Object.keys(e).length<2||(0,ht.count)(e,n=>n===!0)>=Object.keys(e).length/2?r:e}catch{return r}},"tryLogfmtParse");var D=o((t,r)=>{let e,n;if(typeof r=="string"&&(!e&&r.trim()&&(e=(0,yt.tryJSONparse)(r,null),e!==null&&(n="json")),!e&&r.trim()&&(e=dt(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"?xt.default.createInterface({input:process.stdin}).on("line",t=>{D($,t)}):process.stdin.pipe((0,Lt.default)()).pipe((0,bt.default)(function(t){if(!t){this.emit("data",`${t} | ||
`);return}D($,t)})).pipe(process.stdout); | ||
"use strict";var Ot=Object.create;var v=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var Wt=Object.getOwnPropertyNames;var At=Object.getPrototypeOf,Mt=Object.prototype.hasOwnProperty;var o=(t,r)=>v(t,"name",{value:r,configurable:!0});var Pt=(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 Wt(r))!Mt.call(t,s)&&s!==e&&v(t,s,{get:()=>r[s],enumerable:!(n=It(r,s))||n.enumerable});return t},k=(t,r,e)=>(_(t,r,"default"),e&&_(e,r,"default")),m=(t,r,e)=>(e=t!=null?Ot(At(t)):{},_(r||!t||!t.__esModule?v(e,"default",{value:t,enumerable:!0}):e,t));var xt=m(require("readline")),Lt=m(require("split")),bt=m(require("through"));var U=require("@lskjs/algos"),p=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=p.isDev||p.isClient?"pretty":"lsk",w=o(()=>{let t=(0,p.getEnvVar)("DEBUG","")||"",r=process.argv?.includes("--silent"),e=t.startsWith("lsk")||t.startsWith("*"),n=(0,p.getEnvVar)("LOG_FORMAT",(0,p.getEnvVar)("DEBUG_FORMAT",E)),{on:s,off:i}=G(t),f=(0,p.getEnvVar)("LOG_LEVEL",(0,p.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={};Pt(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 u=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):u(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 Nt={10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"},$t={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:Nt[r],time:new Date(e)},args:h(n,f)}},"parseBunyan"),Z=o(t=>{let{level:r,time:e,...n}=t;return u({level:$t[r],time:e.toISOString(),...n})},"stringifyBunyan");var Dt=["trace","debug","info","warning","error","fatal","panic"],Tt={trace:"trace",debug:"debug",info:"info",warning:"warn",error:"error",fatal:"fatal",panic:"fatal"},zt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"},F=o(t=>!!(t.msg&&Dt.includes(t.level)),"isLogrus"),j=o(t=>{let{level:r,time:e,msg:n,...s}=t;return{format:a.logrus,meta:{level:Tt[r],time:new Date(e)},args:h(n,s)}},"parseLogrus"),q=o(t=>{let{level:r,time:e,...n}=t;return u({level:zt[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"),O=o(t=>!!tt.includes(t.level),"isLskLikelog"),c=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),I=o(t=>!!(c(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal"),W=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(!c(t))return{format:a.lsklogweb,meta:f,args:h(n,l)};let{reqId:vt,method:kt,host:wt,ua:St,ip:_t,url:Et,status:Bt,length:Ct,duration:Rt,...Ft}=l;return{format:a.lsklog,meta:{...f,method:kt,host:wt,reqId:vt,ua:St,ip:_t,url:Et,status:Bt,duration:Rt,length:Ct},args:h(n,Ft)}},"parseLsklog"),et=o(t=>{let{level:r,time:e,...n}=t;return u({level:r,time:+e,...n})},"stringifyLsklog");function Gt(t){return Q(t)?a.bunyan:rt(t)?a.lsklog:c(t)?a.lsklogweb:F(t)&&O(t)&&t?.name?a.lsklog:F(t)?a.logrus:O(t)?a.lsklog:null}o(Gt,"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=Gt(t);return r==="bunyan"?X(t):r==="lsklogweb"?W(t):r==="lsklog"?W(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 M=require("@lskjs/colors");var A=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=A;function P(t,r){let e=C[st(r||"")%C.length]||[];return(0,M.colorize)(t,e)}o(P,"themeizeRandom");function x(t,r){let e=r?V[r]:[];return(0,M.colorize)(t,e)}o(x,"themeize");var Ut=(0,lt.getEnvVar)("LOG_VIEW","short"),L=o((t,r)=>String(t).padStart(r),"leftPad"),Vt=o((t,r)=>String(t).padEnd(r),"rightPad"),N=20,Jt=o((t,r=0)=>(N=Math.max(t&&t.length||0,N,r),Vt(t,N)),"prettyPath"),pt=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),Yt=o(t=>{let r=pt(t);return r||(r=t!==200?"log":null),x(L(String(t),3),r)},"prettyStatus"),Ht=o(t=>L(`#${t}`,3),"prettyReqId"),Kt=o(t=>{let r=t==="REMOVE"?"error":t==="WS"?"debug":null;return x(L(t,4),r)},"prettyMethod"),Qt=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"),Xt=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"),ut=o((t,r)=>[...t,r].filter(Boolean).map(String).map(n=>P(n,n)).join(":"),"prettyNs");function Zt(t){let r=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],e=r[A(t)%r.length];return P(e,String(t))}o(Zt,"prettyMarker");var $=o(t=>{let r=Ut==="short"?(t[0]||"").toLowerCase():L(t,5);return r=`[${r}]`,x(r,t)},"prettyLevel"),jt=/\[[^"\]]+]/gm,ct=o((...t)=>{let r=[];return t.forEach(e=>{if(typeof e=="string"){let n=0;r.push(e.replace(jt,s=>(0,it.colorize)(s,R[n++%R.length])))}else r.push(e)}),r},"prettyContent"),qt=o(t=>pt(t.status)||I(t)?"debug":"trace","getUrlLevel"),mt=o(t=>{let r=I(t),e=qt(t);return[$(e),[Zt(t.reqId),Kt(t.method)].join(""),Jt(t.url),Ht(t.reqId),r&&t.method!=="WS"?Yt(t.status):null,!r&&"\u29D7\u29D6\u29D7",r&&Qt(t.duration),r&&t.method!=="WS"?Xt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function tr(t,r){let e=0;return t.forEach((n,s)=>{s===e&&r(n)&&(e+=1)}),e}o(tr,"countInRow");function rr(...t){let r=tr(t,e=>typeof e=="string");return[t.slice(0,r).join(" "),...t.slice(r)]}o(rr,"concatFirstStrings");function y(t,...r){let e=t?.ns,n=t?.name,s=t?.level||"log",i=r;if(c(t))return[mt(t)];let l=(e||"").split(":").filter(Boolean).map(String),f=[$(s)];return(l.length||n)&&f.push(ut(l,n)),rr(...f,...ct(...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(c(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 T=new b(w());var yt=require("@lskjs/env");var ht=require("@lskjs/algos");var er=require("logfmt"),dt=o((t,r=t)=>{try{if(typeof t!="string")return t;if(!t.trim())return r;let e=er.parse(t);return Object.keys(e).includes("")||Object.keys(e).length<2||(0,ht.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,yt.tryJSONparse)(r,null),e!==null&&(n="json")),!e&&r.trim()&&(e=dt(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"?xt.default.createInterface({input:process.stdin}).on("line",t=>{z(T,t)}):process.stdin.pipe((0,Lt.default)()).pipe((0,bt.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 h=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,ft=Object.prototype.hasOwnProperty;var o=(t,r)=>h(t,"name",{value:r,configurable:!0});var P=(t,r)=>{for(var e in r)h(t,e,{get:r[e],enumerable:!0})},b=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of lt(r))!ft.call(t,s)&&s!==e&&h(t,s,{get:()=>r[s],enumerable:!(n=it(r,s))||n.enumerable});return t},L=(t,r,e)=>(b(t,r,"default"),e&&b(e,r,"default")),v=(t,r,e)=>(e=t!=null?st(at(t)):{},b(r||!t||!t.__esModule?h(e,"default",{value:t,enumerable:!0}):e,t)),ut=t=>b(h({},"__esModule",{value:!0}),t);var Ct={};P(Ct,{default:()=>Bt,log:()=>nt});module.exports=ut(Ct);var O=require("@lskjs/algos"),f=require("@lskjs/env");function N(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(N,"parseNs");var S=f.isDev||f.isClient?"pretty":"lsk",k=o(()=>{let t=(0,f.getEnvVar)("DEBUG","")||"",r=process.argv?.includes("--silent"),e=t.startsWith("lsk")||t.startsWith("*"),n=(0,f.getEnvVar)("LOG_FORMAT",(0,f.getEnvVar)("DEBUG_FORMAT",S)),{on:s,off:i}=N(t),a=(0,f.getEnvVar)("LOG_LEVEL",(0,f.getEnvVar)("DEBUG_LEVEL",r?"error":e?"trace":"debug"));return(0,O.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},$={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},E=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],B=[["bold","white"],["bold","cyan"],["bold","green"],["white"]];var p;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(p||(p={}));var c=require("@lskjs/err");var g={};P(g,{default:()=>T.default,stringify:()=>w.default});L(g,require("fast-safe-stringify"));var w=v(require("fast-safe-stringify")),T=v(require("fast-safe-stringify"));var u=o((t,r=null,e=0)=>typeof t=="object"?(0,w.default)(t,r,e):String(t),"toString");var z=o(t=>t.map(r=>(0,c.isError)(r)?(0,c.getCode)(r):null).filter(Boolean)[0],"getErrCode"),D=o(t=>t.length?t.map(r=>(0,c.isError)(r)?(0,c.getMessage)(r):u(r)).join(" "):null,"createMsg");var ct=require("@lskjs/env");var pt={log:10,trace:10,debug:20,info:30,warn:40,error:50,fatal:60};var U=o(t=>{let{level:r,time:e,...n}=t;return u({level:pt[r],time:e.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:r,time:e,...n}=t;return u({level:gt[r],time:e.toISOString(),...n})},"stringifyLogrus");var m=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),C=o(t=>!!(m(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal");var J=o(t=>{let{level:r,time:e,...n}=t;return u({level:r,time:+e,...n})},"stringifyLsklog");function Y(t,r,...e){let n=z(e),s=D(e),i={code:n,...r,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((r,e)=>{let n=(r<<5)-r+e.charCodeAt(0);return n&n},0)-48),"hashCode"),H=F;function M(t,r){let e=E[H(r||"")%E.length]||[];return(0,W.colorize)(t,e)}o(M,"themeizeRandom");function d(t,r){let e=r?$[r]:[];return(0,W.colorize)(t,e)}o(d,"themeize");var mt=(0,X.getEnvVar)("LOG_VIEW","short"),x=o((t,r)=>String(t).padStart(r),"leftPad"),ht=o((t,r)=>String(t).padEnd(r),"rightPad"),R=20,dt=o((t,r=0)=>(R=Math.max(t&&t.length||0,R,r),ht(t,R)),"prettyPath"),j=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),xt=o(t=>{let r=j(t);return r||(r=t!==200?"log":null),d(x(String(t),3),r)},"prettyStatus"),yt=o(t=>x(`#${t}`,3),"prettyReqId"),bt=o(t=>{let r=t==="REMOVE"?"error":t==="WS"?"debug":null;return d(x(t,4),r)},"prettyMethod"),Lt=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,K.default)(i,s);return d(x(l,5),e)},"prettyTime"),vt=o((t,r="")=>{if(!Number.isFinite(t))return null;let e=(0,Z.default)(t,{maximumFractionDigits:1}).split(" "),n=e[1];return`${+e[0]>=100?Math.round(+e[0]):+e[0]}${r}${n}`},"prettySize"),q=o((t,r)=>[...t,r].filter(Boolean).map(String).map(n=>M(n,n)).join(":"),"prettyNs");function kt(t){let r=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],e=r[F(t)%r.length];return M(e,String(t))}o(kt,"prettyMarker");var A=o(t=>{let r=mt==="short"?(t[0]||"").toLowerCase():x(t,5);return r=`[${r}]`,d(r,t)},"prettyLevel"),wt=/\[[^"\]]+]/gm,tt=o((...t)=>{let r=[];return t.forEach(e=>{if(typeof e=="string"){let n=0;r.push(e.replace(wt,s=>(0,Q.colorize)(s,B[n++%B.length])))}else r.push(e)}),r},"prettyContent"),St=o(t=>j(t.status)||C(t)?"debug":"trace","getUrlLevel"),rt=o(t=>{let r=C(t),e=St(t);return[A(e),[kt(t.reqId),bt(t.method)].join(""),dt(t.url),yt(t.reqId),r&&t.method!=="WS"?xt(t.status):null,!r&&"\u29D7\u29D6\u29D7",r&&Lt(t.duration),r&&t.method!=="WS"?vt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function _t(t,r){let e=0;return t.forEach((n,s)=>{s===e&&r(n)&&(e+=1)}),e}o(_t,"countInRow");function Et(...t){let r=_t(t,e=>typeof e=="string");return[t.slice(0,r).join(" "),...t.slice(r)]}o(Et,"concatFirstStrings");function et(t,...r){let e=t?.ns,n=t?.name,s=t?.level||"log",i=r;if(m(t))return[rt(t)];let l=(e||"").split(":").filter(Boolean).map(String),a=[A(s)];return(l.length||n)&&a.push(q(l,n)),Et(...a,...tt(...i))}o(et,"prettyFormat");function I(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(I,"anyRegExps");var y=class{prefix;ns;name;format=S;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:a=[]}){if(r&&(this.prefix=r),e&&(this.ns=e),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(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 _[r]||0}canLog(r){let e=this.getLevelPriority(r),n=this.getLevelPriority(this.level);return this.ns&&I(this.off,this.ns)?!1:this.ns&&I(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(m(n)&&(i={...i,...n},l=s),this.format==="none")return;let a=(0,ot.omitNull)(i);if(this.format==="pretty"){this.log(...et(a,...l));return}this.log(Y(this.format||"lsk",a,...l))}};o(y,"Logger");var nt=new y(k()),Bt=nt;0&&(module.exports={log}); | ||
"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,r)=>h(t,"name",{value:r,configurable:!0});var P=(t,r)=>{for(var e in r)h(t,e,{get:r[e],enumerable:!0})},b=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of lt(r))!ft.call(t,s)&&s!==e&&h(t,s,{get:()=>r[s],enumerable:!(n=it(r,s))||n.enumerable});return t},L=(t,r,e)=>(b(t,r,"default"),e&&b(e,r,"default")),v=(t,r,e)=>(e=t!=null?st(at(t)):{},b(r||!t||!t.__esModule?h(e,"default",{value:t,enumerable:!0}):e,t)),ut=t=>b(h({},"__esModule",{value:!0}),t);var Ct={};P(Ct,{default:()=>Bt,log:()=>nt});module.exports=ut(Ct);var O=require("@lskjs/algos"),f=require("@lskjs/env");function N(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(N,"parseNs");var S=f.isDev||f.isClient?"pretty":"lsk",k=o(()=>{let t=(0,f.getEnvVar)("DEBUG","")||"",r=process.argv?.includes("--silent"),e=t.startsWith("lsk")||t.startsWith("*"),n=(0,f.getEnvVar)("LOG_FORMAT",(0,f.getEnvVar)("DEBUG_FORMAT",S)),{on:s,off:i}=N(t),a=(0,f.getEnvVar)("LOG_LEVEL",(0,f.getEnvVar)("DEBUG_LEVEL",r?"error":e?"trace":"debug"));return(0,O.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},$={fatal:["bgRed"],error:["bold","bgRed"],warn:["bgYellow"],debug:["bold","cyan"],info:["bold","green"],trace:["gray"],log:["bgWhite"]},E=[["red"],["green"],["yellow"],["blue"],["magenta"],["cyan"],["bold","red"],["bold","green"],["bold","yellow"],["bold","blue"],["bold","magenta"],["bold","cyan"]],B=[["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 c=require("@lskjs/err");var p={};P(p,{default:()=>T.default,stringify:()=>w.default});L(p,require("fast-safe-stringify"));var w=v(require("fast-safe-stringify")),T=v(require("fast-safe-stringify"));var u=o((t,r=null,e=0)=>typeof t=="object"?(0,w.default)(t,r,e):String(t),"toString");var z=o(t=>t.map(r=>(0,c.isError)(r)?(0,c.getCode)(r):null).filter(Boolean)[0],"getErrCode"),D=o(t=>t.length?t.map(r=>(0,c.isError)(r)?(0,c.getMessage)(r):u(r)).join(" "):null,"createMsg");var ct=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:r,time:e,...n}=t;return u({level:gt[r],time:e.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:r,time:e,...n}=t;return u({level:pt[r],time:e.toISOString(),...n})},"stringifyLogrus");var m=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),C=o(t=>!!(m(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal");var J=o(t=>{let{level:r,time:e,...n}=t;return u({level:r,time:+e,...n})},"stringifyLsklog");function Y(t,r,...e){let n=z(e),s=D(e),i={code:n,...r,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((r,e)=>{let n=(r<<5)-r+e.charCodeAt(0);return n&n},0)-48),"hashCode"),H=F;function M(t,r){let e=E[H(r||"")%E.length]||[];return(0,W.colorize)(t,e)}o(M,"themeizeRandom");function d(t,r){let e=r?$[r]:[];return(0,W.colorize)(t,e)}o(d,"themeize");var mt=(0,X.getEnvVar)("LOG_VIEW","short"),x=o((t,r)=>String(t).padStart(r),"leftPad"),ht=o((t,r)=>String(t).padEnd(r),"rightPad"),R=20,dt=o((t,r=0)=>(R=Math.max(t&&t.length||0,R,r),ht(t,R)),"prettyPath"),j=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),xt=o(t=>{let r=j(t);return r||(r=t!==200?"log":null),d(x(String(t),3),r)},"prettyStatus"),yt=o(t=>x(`#${t}`,3),"prettyReqId"),bt=o(t=>{let r=t==="REMOVE"?"error":t==="WS"?"debug":null;return d(x(t,4),r)},"prettyMethod"),Lt=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,K.default)(i,s);return d(x(l,5),e)},"prettyTime"),vt=o((t,r="")=>{if(!Number.isFinite(t))return null;let e=(0,Z.default)(t,{maximumFractionDigits:1}).split(" "),n=e[1];return`${+e[0]>=100?Math.round(+e[0]):+e[0]}${r}${n}`},"prettySize"),q=o((t,r)=>[...t,r].filter(Boolean).map(String).map(n=>M(n,n)).join(":"),"prettyNs");function kt(t){let r=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],e=r[F(t)%r.length];return M(e,String(t))}o(kt,"prettyMarker");var A=o(t=>{let r=mt==="short"?(t[0]||"").toLowerCase():x(t,5);return r=`[${r}]`,d(r,t)},"prettyLevel"),wt=/\[[^"\]]+]/gm,tt=o((...t)=>{let r=[];return t.forEach(e=>{if(typeof e=="string"){let n=0;r.push(e.replace(wt,s=>(0,Q.colorize)(s,B[n++%B.length])))}else r.push(e)}),r},"prettyContent"),St=o(t=>j(t.status)||C(t)?"debug":"trace","getUrlLevel"),rt=o(t=>{let r=C(t),e=St(t);return[A(e),[kt(t.reqId),bt(t.method)].join(""),dt(t.url),yt(t.reqId),r&&t.method!=="WS"?xt(t.status):null,!r&&"\u29D7\u29D6\u29D7",r&&Lt(t.duration),r&&t.method!=="WS"?vt(t.length):null].filter(Boolean).join(" ")},"prettyUrl");function _t(t,r){let e=0;return t.forEach((n,s)=>{s===e&&r(n)&&(e+=1)}),e}o(_t,"countInRow");function Et(...t){let r=_t(t,e=>typeof e=="string");return[t.slice(0,r).join(" "),...t.slice(r)]}o(Et,"concatFirstStrings");function et(t,...r){let e=t?.ns,n=t?.name,s=t?.level||"log",i=r;if(m(t))return[rt(t)];let l=(e||"").split(":").filter(Boolean).map(String),a=[A(s)];return(l.length||n)&&a.push(q(l,n)),Et(...a,...tt(...i))}o(et,"prettyFormat");function I(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(I,"anyRegExps");var y=class{prefix;ns;name;format=S;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:a=[]}){if(r&&(this.prefix=r),e&&(this.ns=e),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(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 _[r]||0}canLog(r){let e=this.getLevelPriority(r),n=this.getLevelPriority(this.level);return this.ns&&I(this.off,this.ns)?!1:this.ns&&I(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(m(n)&&(i={...i,...n},l=s),this.format==="none")return;let a=(0,ot.omitNull)(i);if(this.format==="pretty"){this.log(...et(a,...l));return}this.log(Y(this.format||"lsk",a,...l))}};o(y,"Logger");var nt=new y(k()),Bt=nt;0&&(module.exports={log}); | ||
//# sourceMappingURL=log.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var Z=Object.create;var p=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,tt=Object.prototype.hasOwnProperty;var e=(t,r)=>p(t,"name",{value:r,configurable:!0});var k=(t,r)=>{for(var o in r)p(t,o,{get:r[o],enumerable:!0})},h=(t,r,o,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of j(r))!tt.call(t,i)&&i!==o&&p(t,i,{get:()=>r[i],enumerable:!(n=K(r,i))||n.enumerable});return t},d=(t,r,o)=>(h(t,r,"default"),o&&h(o,r,"default")),x=(t,r,o)=>(o=t!=null?Z(q(t)):{},h(r||!t||!t.__esModule?p(o,"default",{value:t,enumerable:!0}):o,t)),rt=t=>h(p({},"__esModule",{value:!0}),t);var mt={};k(mt,{detectFormat:()=>T,parse:()=>gt,stringify:()=>R});module.exports=rt(mt);var s;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(s||(s={}));var a=require("@lskjs/err");var c={};k(c,{default:()=>w.default,stringify:()=>y.default});d(c,require("fast-safe-stringify"));var y=x(require("fast-safe-stringify")),w=x(require("fast-safe-stringify"));var l=e((t,r=null,o=0)=>typeof t=="object"?(0,y.default)(t,r,o):String(t),"toString");var S=e(t=>t.map(r=>(0,a.isError)(r)?(0,a.getCode)(r):null).filter(Boolean)[0],"getErrCode"),_=e(t=>t.length?t.map(r=>(0,a.isError)(r)?(0,a.getMessage)(r):l(r)).join(" "):null,"createMsg");var lt=require("@lskjs/algos");var et=require("@lskjs/algos"),L=require("@lskjs/env");var B=require("@lskjs/env");var f=e((t,r)=>{let o=[];return t!==null&&o.push((0,B.tryJSONparse)(t)),Object.keys(r).length&&o.push(r),o},"parseArgs");var E=["trace","debug","info","warn","error","fatal"];var C=e(t=>!!(E.includes(t.level)&&t.ns),"isLsklog"),F=e(t=>!!E.includes(t.level),"isLskLikelog"),g=e(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb");var v=e(t=>{let{level:r,time:o,msg:n,ns:i,name:u,...b}=t,m={level:r,time:o,msg:n,ns:i,name:u};if(!g(t))return{format:s.lsklogweb,meta:m,args:f(n,b)};let{reqId:z,method:D,host:G,ua:U,ip:V,url:J,status:Y,length:H,duration:Q,...X}=b;return{format:s.lsklog,meta:{...m,method:D,host:G,reqId:z,ua:U,ip:V,url:J,status:Y,duration:Q,length:H},args:f(n,X)}},"parseLsklog"),W=e(t=>{let{level:r,time:o,...n}=t;return l({level:r,time:+o,...n})},"stringifyLsklog");var nt=require("@lskjs/colors"),M=require("@lskjs/env"),st=x(require("pretty-bytes")),it=x(require("pretty-time"));var ot=require("@lskjs/colors");var er=(0,M.getEnvVar)("LOG_VIEW","short");var at={10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"},ft={log:10,trace:10,debug:20,info:30,warn:40,error:50,fatal:60},A=e(t=>!!(t.name&&t.hostname&&t.pid&&t.msg&&t.time),"isBunyan"),I=e(t=>{let{level:r,time:o,msg:n,hostname:i,pid:u,v:b,...m}=t;return{format:s.bunyan,meta:{level:at[r],time:new Date(o)},args:f(n,m)}},"parseBunyan"),P=e(t=>{let{level:r,time:o,...n}=t;return l({level:ft[r],time:o.toISOString(),...n})},"stringifyBunyan");var ut=["trace","debug","info","warning","error","fatal","panic"],ct={trace:"trace",debug:"debug",info:"info",warning:"warn",error:"error",fatal:"fatal",panic:"fatal"},pt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"},N=e(t=>!!(t.msg&&ut.includes(t.level)),"isLogrus"),O=e(t=>{let{level:r,time:o,msg:n,...i}=t;return{format:s.logrus,meta:{level:ct[r],time:new Date(o)},args:f(n,i)}},"parseLogrus"),$=e(t=>{let{level:r,time:o,...n}=t;return l({level:pt[r],time:o.toISOString(),...n})},"stringifyLogrus");function T(t){return A(t)?s.bunyan:C(t)?s.lsklog:g(t)?s.lsklogweb:N(t)?s.logrus:F(t)?s.lsklog:null}e(T,"detectFormat");function R(t,r,...o){let n=S(o),i=_(o),u={code:n,...r,msg:i};return t==="bunyan"?P(u):t==="logrus"?$(u):W(u)}e(R,"stringify");function gt(t){let r=T(t);return r==="bunyan"?I(t):r==="lsklogweb"?v(t):r==="lsklog"?v(t):r==="logrus"?O(t):{format:r,meta:{},args:[t]}}e(gt,"parse");0&&(module.exports={detectFormat,parse,stringify}); | ||
"use strict";var Z=Object.create;var p=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,tt=Object.prototype.hasOwnProperty;var e=(t,r)=>p(t,"name",{value:r,configurable:!0});var S=(t,r)=>{for(var o in r)p(t,o,{get:r[o],enumerable:!0})},h=(t,r,o,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of j(r))!tt.call(t,i)&&i!==o&&p(t,i,{get:()=>r[i],enumerable:!(n=K(r,i))||n.enumerable});return t},d=(t,r,o)=>(h(t,r,"default"),o&&h(o,r,"default")),x=(t,r,o)=>(o=t!=null?Z(q(t)):{},h(r||!t||!t.__esModule?p(o,"default",{value:t,enumerable:!0}):o,t)),rt=t=>h(p({},"__esModule",{value:!0}),t);var mt={};S(mt,{detectFormat:()=>T,parse:()=>gt,stringify:()=>A});module.exports=rt(mt);var s;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(s||(s={}));var a=require("@lskjs/err");var c={};S(c,{default:()=>_.default,stringify:()=>y.default});d(c,require("fast-safe-stringify"));var y=x(require("fast-safe-stringify")),_=x(require("fast-safe-stringify"));var l=e((t,r=null,o=0)=>typeof t=="object"?(0,y.default)(t,r,o):String(t),"toString");var B=e(t=>t.map(r=>(0,a.isError)(r)?(0,a.getCode)(r):null).filter(Boolean)[0],"getErrCode"),E=e(t=>t.length?t.map(r=>(0,a.isError)(r)?(0,a.getMessage)(r):l(r)).join(" "):null,"createMsg");var lt=require("@lskjs/algos");var et=require("@lskjs/algos"),L=require("@lskjs/env");var C=require("@lskjs/env");var f=e((t,r)=>{let o=[];return t!==null&&o.push((0,C.tryJSONparse)(t)),Object.keys(r).length&&o.push(r),o},"parseArgs");var F=["trace","debug","info","warn","error","fatal"];var W=e(t=>!!(F.includes(t.level)&&t.ns),"isLsklog"),v=e(t=>!!F.includes(t.level),"isLskLikelog"),g=e(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb");var k=e(t=>{let{level:r,time:o,msg:n,ns:i,name:u,...b}=t,m={level:r,time:o,msg:n,ns:i,name:u};if(!g(t))return{format:s.lsklogweb,meta:m,args:f(n,b)};let{reqId:z,method:D,host:G,ua:U,ip:V,url:J,status:Y,length:H,duration:Q,...X}=b;return{format:s.lsklog,meta:{...m,method:D,host:G,reqId:z,ua:U,ip:V,url:J,status:Y,duration:Q,length:H},args:f(n,X)}},"parseLsklog"),M=e(t=>{let{level:r,time:o,...n}=t;return l({level:r,time:+o,...n})},"stringifyLsklog");var nt=require("@lskjs/colors"),R=require("@lskjs/env"),st=x(require("pretty-bytes")),it=x(require("pretty-time"));var ot=require("@lskjs/colors");var er=(0,R.getEnvVar)("LOG_VIEW","short");var at={10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"},ft={log:10,trace:10,debug:20,info:30,warn:40,error:50,fatal:60},I=e(t=>!!(t.name&&t.hostname&&t.pid&&t.msg&&t.time),"isBunyan"),P=e(t=>{let{level:r,time:o,msg:n,hostname:i,pid:u,v:b,...m}=t;return{format:s.bunyan,meta:{level:at[r],time:new Date(o)},args:f(n,m)}},"parseBunyan"),N=e(t=>{let{level:r,time:o,...n}=t;return l({level:ft[r],time:o.toISOString(),...n})},"stringifyBunyan");var ut=["trace","debug","info","warning","error","fatal","panic"],ct={trace:"trace",debug:"debug",info:"info",warning:"warn",error:"error",fatal:"fatal",panic:"fatal"},pt={log:"trace",trace:"trace",debug:"debug",info:"info",warn:"warning",error:"error",fatal:"fatal"},w=e(t=>!!(t.msg&&ut.includes(t.level)),"isLogrus"),O=e(t=>{let{level:r,time:o,msg:n,...i}=t;return{format:s.logrus,meta:{level:ct[r],time:new Date(o)},args:f(n,i)}},"parseLogrus"),$=e(t=>{let{level:r,time:o,...n}=t;return l({level:pt[r],time:o.toISOString(),...n})},"stringifyLogrus");function T(t){return I(t)?s.bunyan:W(t)?s.lsklog:g(t)?s.lsklogweb:w(t)&&v(t)&&t?.name?s.lsklog:w(t)?s.logrus:v(t)?s.lsklog:null}e(T,"detectFormat");function A(t,r,...o){let n=B(o),i=E(o),u={code:n,...r,msg:i};return t==="bunyan"?N(u):t==="logrus"?$(u):M(u)}e(A,"stringify");function gt(t){let r=T(t);return r==="bunyan"?P(t):r==="lsklogweb"?k(t):r==="lsklog"?k(t):r==="logrus"?O(t):{format:r,meta:{},args:[t]}}e(gt,"parse");0&&(module.exports={detectFormat,parse,stringify}); | ||
//# sourceMappingURL=index.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 N=(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 zt={};N(zt,{concatFirstStrings:()=>ft,countInRow:()=>at,getStatusLevel:()=>M,getUrlLevel:()=>lt,prettyContent:()=>A,prettyFormat:()=>m,prettyLevel:()=>L,prettyMarker:()=>it,prettyMethod:()=>ot,prettyNs:()=>P,prettyPath:()=>tt,prettyRawLog:()=>Tt,prettyReqId:()=>et,prettySize:()=>st,prettyStatus:()=>rt,prettyTime:()=>nt,prettyUrl:()=>I});module.exports=Ct(zt);var i;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(i||(i={}));var Pt=require("@lskjs/algos");var $={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 p={};N(p,{default:()=>T.default,stringify:()=>S.default});x(p,require("fast-safe-stringify"));var S=b(require("fast-safe-stringify")),T=b(require("fast-safe-stringify"));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 Ot={10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"};var D=o(t=>!!(t.name&&t.hostname&&t.pid&&t.msg&&t.time),"isBunyan"),G=o(t=>{let{level:r,time:e,msg:n,hostname:s,pid:l,v:a,...f}=t;return{format:i.bunyan,meta:{level:Ot[r],time:new Date(e)},args:u(n,f)}},"parseBunyan");var Rt=["trace","debug","info","warning","error","fatal","panic"],Wt={trace:"trace",debug:"debug",info:"info",warning:"warn",error:"error",fatal:"fatal",panic:"fatal"};var U=o(t=>!!(t.msg&&Rt.includes(t.level)),"isLogrus"),V=o(t=>{let{level:r,time:e,msg:n,...s}=t;return{format:i.logrus,meta:{level:Wt[r],time:new Date(e)},args:u(n,s)}},"parseLogrus");function Mt(t){return D(t)?i.bunyan:Y(t)?i.lsklog:c(t)?i.lsklogweb:U(t)?i.logrus:H(t)?i.lsklog:null}o(Mt,"detectFormat");function J(t){let r=Mt(t);return r==="bunyan"?G(t):r==="lsklogweb"?E(t):r==="lsklog"?E(t):r==="logrus"?V(t):{format:r,meta:{},args:[t]}}o(J,"parse");var Q=["trace","debug","info","warn","error","fatal"];var Y=o(t=>!!(Q.includes(t.level)&&t.ns),"isLsklog"),H=o(t=>!!Q.includes(t.level),"isLskLikelog"),c=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),C=o(t=>!!(c(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal"),E=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:mt,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:mt,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 O=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"),X=F;function R(t,r){let e=v[X(r||"")%v.length]||[];return(0,O.colorize)(t,e)}o(R,"themeizeRandom");function h(t,r){let e=r?$[r]:[];return(0,O.colorize)(t,e)}o(h,"themeize");var At=(0,K.getEnvVar)("LOG_VIEW","short"),d=o((t,r)=>String(t).padStart(r),"leftPad"),It=o((t,r)=>String(t).padEnd(r),"rightPad"),W=20,tt=o((t,r=0)=>(W=Math.max(t&&t.length||0,W,r),It(t,W)),"prettyPath"),M=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),rt=o(t=>{let r=M(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"),P=o((t,r)=>[...t,r].filter(Boolean).map(String).map(n=>R(n,n)).join(":"),"prettyNs");function it(t){let r=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],e=r[F(t)%r.length];return R(e,String(t))}o(it,"prettyMarker");var L=o(t=>{let r=At==="short"?(t[0]||"").toLowerCase():d(t,5);return r=`[${r}]`,h(r,t)},"prettyLevel"),Nt=/\[[^"\]]+]/gm,A=o((...t)=>{let r=[];return t.forEach(e=>{if(typeof e=="string"){let n=0;r.push(e.replace(Nt,s=>(0,Z.colorize)(s,k[n++%k.length])))}else r.push(e)}),r},"prettyContent"),lt=o(t=>M(t.status)||C(t)?"debug":"trace","getUrlLevel"),I=o(t=>{let r=C(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 m(t,...r){let e=t?.ns,n=t?.name,s=t?.level||"log",l=r;if(c(t))return[I(t)];let a=(e||"").split(":").filter(Boolean).map(String),f=[L(s)];return(a.length||n)&&f.push(P(a,n)),ft(...f,...A(...l))}o(m,"prettyFormat");var pt=require("@lskjs/env");var ut=require("@lskjs/algos");var $t=require("logfmt"),ct=o((t,r=t)=>{try{if(typeof t!="string")return t;if(!t.trim())return r;let e=$t.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 Tt=o((t,r)=>{let e,n;if(typeof r=="string"&&(!e&&r.trim()&&(e=(0,pt.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(...m({},r));return}if(typeof e!="object"){t.log(...m({},e));return}let{meta:s,args:l=[]}=J(e);t.log(...m(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")),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 zt={};T(zt,{concatFirstStrings:()=>ft,countInRow:()=>at,getStatusLevel:()=>A,getUrlLevel:()=>lt,prettyContent:()=>N,prettyFormat:()=>m,prettyLevel:()=>L,prettyMarker:()=>it,prettyMethod:()=>ot,prettyNs:()=>I,prettyPath:()=>tt,prettyRawLog:()=>Tt,prettyReqId:()=>et,prettySize:()=>st,prettyStatus:()=>rt,prettyTime:()=>nt,prettyUrl:()=>$});module.exports=Ct(zt);var i;(function(t){t.bunyan="bunyan",t.lsklog="lsklog",t.lsklogweb="lsklogweb",t.logrus="logrus",t.raw="raw"})(i||(i={}));var Pt=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 p={};T(p,{default:()=>D.default,stringify:()=>S.default});x(p,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 Ot={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:Ot[r],time:new Date(e)},args:u(n,f)}},"parseBunyan");var Rt=["trace","debug","info","warning","error","fatal","panic"],Wt={trace:"trace",debug:"debug",info:"info",warning:"warn",error:"error",fatal:"fatal",panic:"fatal"};var E=o(t=>!!(t.msg&&Rt.includes(t.level)),"isLogrus"),J=o(t=>{let{level:r,time:e,msg:n,...s}=t;return{format:i.logrus,meta:{level:Wt[r],time:new Date(e)},args:u(n,s)}},"parseLogrus");function Mt(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(Mt,"detectFormat");function Y(t){let r=Mt(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"),O=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:mt,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:mt,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 W=require("@lskjs/colors");var R=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=R;function M(t,r){let e=v[X(r||"")%v.length]||[];return(0,W.colorize)(t,e)}o(M,"themeizeRandom");function h(t,r){let e=r?z[r]:[];return(0,W.colorize)(t,e)}o(h,"themeize");var At=(0,K.getEnvVar)("LOG_VIEW","short"),d=o((t,r)=>String(t).padStart(r),"leftPad"),It=o((t,r)=>String(t).padEnd(r),"rightPad"),P=20,tt=o((t,r=0)=>(P=Math.max(t&&t.length||0,P,r),It(t,P)),"prettyPath"),A=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),rt=o(t=>{let r=A(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"),I=o((t,r)=>[...t,r].filter(Boolean).map(String).map(n=>M(n,n)).join(":"),"prettyNs");function it(t){let r=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],e=r[R(t)%r.length];return M(e,String(t))}o(it,"prettyMarker");var L=o(t=>{let r=At==="short"?(t[0]||"").toLowerCase():d(t,5);return r=`[${r}]`,h(r,t)},"prettyLevel"),Nt=/\[[^"\]]+]/gm,N=o((...t)=>{let r=[];return t.forEach(e=>{if(typeof e=="string"){let n=0;r.push(e.replace(Nt,s=>(0,Z.colorize)(s,k[n++%k.length])))}else r.push(e)}),r},"prettyContent"),lt=o(t=>A(t.status)||O(t)?"debug":"trace","getUrlLevel"),$=o(t=>{let r=O(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 m(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(I(a,n)),ft(...f,...N(...l))}o(m,"prettyFormat");var pt=require("@lskjs/env");var ut=require("@lskjs/algos");var $t=require("logfmt"),ct=o((t,r=t)=>{try{if(typeof t!="string")return t;if(!t.trim())return r;let e=$t.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 Tt=o((t,r)=>{let e,n;if(typeof r=="string"&&(!e&&r.trim()&&(e=(0,pt.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(...m({},r));return}if(typeof e!="object"){t.log(...m({},e));return}let{meta:s,args:l=[]}=Y(e);t.log(...m(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 m=Object.defineProperty;var ht=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var yt=Object.getPrototypeOf,xt=Object.prototype.hasOwnProperty;var o=(t,r)=>m(t,"name",{value:r,configurable:!0});var M=(t,r)=>{for(var e in r)m(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&&m(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?m(e,"default",{value:t,enumerable:!0}):e,t)),bt=t=>y(m({},"__esModule",{value:!0}),t);var Dt={};M(Dt,{default:()=>zt,prettyRawLog:()=>ot});module.exports=bt(Dt);var et=require("@lskjs/env");var P=require("@lskjs/algos");var Lt=require("logfmt"),A=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,P.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 p={};M(p,{default:()=>I.default,stringify:()=>L.default});x(p,require("fast-safe-stringify"));var L=b(require("fast-safe-stringify")),I=b(require("fast-safe-stringify"));var At=require("@lskjs/algos");var N={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 $=require("@lskjs/env");var u=o((t,r)=>{let e=[];return t!==null&&e.push((0,$.tryJSONparse)(t)),Object.keys(r).length&&e.push(r),e},"parseArgs");var T=["trace","debug","info","warn","error","fatal"];var z=o(t=>!!(T.includes(t.level)&&t.ns),"isLsklog"),D=o(t=>!!T.includes(t.level),"isLskLikelog"),c=o(t=>!!(t&&(t.name==="req"||t.method&&t.host&&t.url)),"isLsklogWeb"),B=o(t=>!!(c(t)&&(t.status||t.duration||t.length)),"isLsklogWebFinal"),E=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:pt,...mt}=a;return{format:i.lsklog,meta:{...f,method:st,host:it,reqId:nt,ua:lt,ip:at,url:ft,status:ut,duration:pt,length:ct},args:u(n,mt)}},"parseLsklog");var U=require("@lskjs/colors"),V=require("@lskjs/env"),J=b(require("pretty-bytes")),Y=b(require("pretty-time"));var F=require("@lskjs/colors");var C=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"),G=C;function O(t,r){let e=w[G(r||"")%w.length]||[];return(0,F.colorize)(t,e)}o(O,"themeizeRandom");function g(t,r){let e=r?N[r]:[];return(0,F.colorize)(t,e)}o(g,"themeize");var kt=(0,V.getEnvVar)("LOG_VIEW","short"),h=o((t,r)=>String(t).padStart(r),"leftPad"),wt=o((t,r)=>String(t).padEnd(r),"rightPad"),R=20,St=o((t,r=0)=>(R=Math.max(t&&t.length||0,R,r),wt(t,R)),"prettyPath"),H=o(t=>t>=500?"error":t>=400?"warn":t>=300?"debug":null,"getStatusLevel"),_t=o(t=>{let r=H(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,Y.default)(l,s);return g(h(a,5),e)},"prettyTime"),Ft=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"),Q=o((t,r)=>[...t,r].filter(Boolean).map(String).map(n=>O(n,n)).join(":"),"prettyNs");function Ot(t){let r=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],e=r[C(t)%r.length];return O(e,String(t))}o(Ot,"prettyMarker");var W=o(t=>{let r=kt==="short"?(t[0]||"").toLowerCase():h(t,5);return r=`[${r}]`,g(r,t)},"prettyLevel"),Rt=/\[[^"\]]+]/gm,X=o((...t)=>{let r=[];return t.forEach(e=>{if(typeof e=="string"){let n=0;r.push(e.replace(Rt,s=>(0,U.colorize)(s,S[n++%S.length])))}else r.push(e)}),r},"prettyContent"),Wt=o(t=>H(t.status)||B(t)?"debug":"trace","getUrlLevel"),Z=o(t=>{let r=B(t),e=Wt(t);return[W(e),[Ot(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 Mt(t,r){let e=0;return t.forEach((n,s)=>{s===e&&r(n)&&(e+=1)}),e}o(Mt,"countInRow");function Pt(...t){let r=Mt(t,e=>typeof e=="string");return[t.slice(0,r).join(" "),...t.slice(r)]}o(Pt,"concatFirstStrings");function d(t,...r){let e=t?.ns,n=t?.name,s=t?.level||"log",l=r;if(c(t))return[Z(t)];let a=(e||"").split(":").filter(Boolean).map(String),f=[W(s)];return(a.length||n)&&f.push(Q(a,n)),Pt(...f,...X(...l))}o(d,"prettyFormat");var It={10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"};var K=o(t=>!!(t.name&&t.hostname&&t.pid&&t.msg&&t.time),"isBunyan"),j=o(t=>{let{level:r,time:e,msg:n,hostname:s,pid:l,v:a,...f}=t;return{format:i.bunyan,meta:{level:It[r],time:new Date(e)},args:u(n,f)}},"parseBunyan");var Nt=["trace","debug","info","warning","error","fatal","panic"],$t={trace:"trace",debug:"debug",info:"info",warning:"warn",error:"error",fatal:"fatal",panic:"fatal"};var q=o(t=>!!(t.msg&&Nt.includes(t.level)),"isLogrus"),tt=o(t=>{let{level:r,time:e,msg:n,...s}=t;return{format:i.logrus,meta:{level:$t[r],time:new Date(e)},args:u(n,s)}},"parseLogrus");function Tt(t){return K(t)?i.bunyan:z(t)?i.lsklog:c(t)?i.lsklogweb:q(t)?i.logrus:D(t)?i.lsklog:null}o(Tt,"detectFormat");function rt(t){let r=Tt(t);return r==="bunyan"?j(t):r==="lsklogweb"?E(t):r==="lsklog"?E(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=A(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"),zt=ot;0&&(module.exports={prettyRawLog}); | ||
"use strict";var gt=Object.create;var m=Object.defineProperty;var ht=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var yt=Object.getPrototypeOf,xt=Object.prototype.hasOwnProperty;var o=(t,r)=>m(t,"name",{value:r,configurable:!0});var A=(t,r)=>{for(var e in r)m(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&&m(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?m(e,"default",{value:t,enumerable:!0}):e,t)),bt=t=>y(m({},"__esModule",{value:!0}),t);var Dt={};A(Dt,{default:()=>zt,prettyRawLog:()=>ot});module.exports=bt(Dt);var et=require("@lskjs/env");var I=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,I.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 p={};A(p,{default:()=>$.default,stringify:()=>L.default});x(p,require("fast-safe-stringify"));var L=b(require("fast-safe-stringify")),$=b(require("fast-safe-stringify"));var At=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:pt,...mt}=a;return{format:i.lsklog,meta:{...f,method:st,host:it,reqId:nt,ua:lt,ip:at,url:ft,status:ut,duration:pt,length:ct},args:u(n,mt)}},"parseLsklog");var V=require("@lskjs/colors"),J=require("@lskjs/env"),Y=b(require("pretty-bytes")),H=b(require("pretty-time"));var O=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 R(t,r){let e=w[U(r||"")%w.length]||[];return(0,O.colorize)(t,e)}o(R,"themeizeRandom");function g(t,r){let e=r?T[r]:[];return(0,O.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"),W=20,St=o((t,r=0)=>(W=Math.max(t&&t.length||0,W,r),wt(t,W)),"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=>R(n,n)).join(":"),"prettyNs");function Ot(t){let r=["\u25CB","\u2022","\u2660","\u2660","\u2666","\u2665","\u263C","\u2642","\u2640","\u266A","\xA7"],e=r[F(t)%r.length];return R(e,String(t))}o(Ot,"prettyMarker");var M=o(t=>{let r=kt==="short"?(t[0]||"").toLowerCase():h(t,5);return r=`[${r}]`,g(r,t)},"prettyLevel"),Rt=/\[[^"\]]+]/gm,Z=o((...t)=>{let r=[];return t.forEach(e=>{if(typeof e=="string"){let n=0;r.push(e.replace(Rt,s=>(0,V.colorize)(s,S[n++%S.length])))}else r.push(e)}),r},"prettyContent"),Wt=o(t=>Q(t.status)||E(t)?"debug":"trace","getUrlLevel"),K=o(t=>{let r=E(t),e=Wt(t);return[M(e),[Ot(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 Mt(t,r){let e=0;return t.forEach((n,s)=>{s===e&&r(n)&&(e+=1)}),e}o(Mt,"countInRow");function Pt(...t){let r=Mt(t,e=>typeof e=="string");return[t.slice(0,r).join(" "),...t.slice(r)]}o(Pt,"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=[M(s)];return(a.length||n)&&f.push(X(a,n)),Pt(...f,...Z(...l))}o(d,"prettyFormat");var It={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:It[r],time:new Date(e)},args:u(n,f)}},"parseBunyan");var Nt=["trace","debug","info","warning","error","fatal","panic"],$t={trace:"trace",debug:"debug",info:"info",warning:"warn",error:"error",fatal:"fatal",panic:"fatal"};var P=o(t=>!!(t.msg&&Nt.includes(t.level)),"isLogrus"),tt=o(t=>{let{level:r,time:e,msg:n,...s}=t;return{format:i.logrus,meta:{level:$t[r],time:new Date(e)},args:u(n,s)}},"parseLogrus");function Tt(t){return j(t)?i.bunyan:G(t)?i.lsklog:c(t)?i.lsklogweb:P(t)&&B(t)&&t?.name?i.lsklog:P(t)?i.logrus:B(t)?i.lsklog:null}o(Tt,"detectFormat");function rt(t){let r=Tt(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"),zt=ot;0&&(module.exports={prettyRawLog}); | ||
//# sourceMappingURL=prettyRawLog.js.map |
{ | ||
"name": "@lskjs/log", | ||
"version": "3.5.2", | ||
"version": "3.5.3", | ||
"description": "Yet another logger whitch combines the best features of debug, bunyan, logfmt/logrus, morgan/winston", | ||
@@ -64,3 +64,3 @@ "author": "Igor Suvorov <hi@isuvorov.com> (https://github.com/isuvorov)", | ||
], | ||
"gitHead": "777ba13682a39c174cc650d7cebce5b9d636fb48" | ||
"gitHead": "b603cdea207781ba0219aa23fa0fc5df8122c338" | ||
} |
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
1286773
1034