Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lskjs/log

Package Overview
Dependencies
Maintainers
11
Versions
260
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lskjs/log - npm Package Compare versions

Comparing version 3.5.3 to 3.6.0

lib/createLogger.d.ts

2

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc