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

logestic

Package Overview
Dependencies
Maintainers
0
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logestic - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

21

dist/index.d.ts

@@ -56,10 +56,7 @@ /**

macro: {};
macroFn: {};
}, {}, {
derive: {};
resolve: {};
schema: {}; /**
* Requests Logestic to provide a particular attribute.
* @param attrs - An attribute key or an array of attribute keys.
* @returns The Logestic instance for chaining.
*/
schema: {};
}, {

@@ -88,10 +85,7 @@ derive: {};

macro: {};
macroFn: {};
}, {}, {
derive: {};
resolve: {};
schema: {}; /**
* Requests Logestic to provide a particular attribute.
* @param attrs - An attribute key or an array of attribute keys.
* @returns The Logestic instance for chaining.
*/
schema: {};
}, {

@@ -124,10 +118,7 @@ derive: {};

macro: {};
macroFn: {};
}, {}, {
derive: {};
resolve: {};
schema: {}; /**
* Requests Logestic to provide a particular attribute.
* @param attrs - An attribute key or an array of attribute keys.
* @returns The Logestic instance for chaining.
*/
schema: {};
}, {

@@ -134,0 +125,0 @@ derive: {};

// @bun
import Z0 from"elysia";var l=function(){const $=new Map;for(let[O,H]of Object.entries(X)){for(let[W,J]of Object.entries(H))X[W]={open:`\x1B[${J[0]}m`,close:`\x1B[${J[1]}m`},H[W]=X[W],$.set(J[0],J[1]);Object.defineProperty(X,O,{value:H,enumerable:!1})}return Object.defineProperty(X,"codes",{value:$,enumerable:!1}),X.color.close="\x1B[39m",X.bgColor.close="\x1B[49m",X.color.ansi=F(),X.color.ansi256=T(),X.color.ansi16m=A(),X.bgColor.ansi=F(10),X.bgColor.ansi256=T(10),X.bgColor.ansi16m=A(10),Object.defineProperties(X,{rgbToAnsi256:{value(O,H,W){if(O===H&&H===W){if(O<8)return 16;if(O>248)return 231;return Math.round((O-8)/247*24)+232}return 16+36*Math.round(O/255*5)+6*Math.round(H/255*5)+Math.round(W/255*5)},enumerable:!1},hexToRgb:{value(O){const H=/[a-f\d]{6}|[a-f\d]{3}/i.exec(O.toString(16));if(!H)return[0,0,0];let[W]=H;if(W.length===3)W=[...W].map((K)=>K+K).join("");const J=Number.parseInt(W,16);return[J>>16&255,J>>8&255,J&255]},enumerable:!1},hexToAnsi256:{value:(O)=>X.rgbToAnsi256(...X.hexToRgb(O)),enumerable:!1},ansi256ToAnsi:{value(O){if(O<8)return 30+O;if(O<16)return 90+(O-8);let H,W,J;if(O>=232)H=((O-232)*10+8)/255,W=H,J=H;else{O-=16;const j=O%36;H=Math.floor(O/36)/5,W=Math.floor(j/6)/5,J=j%6/5}const K=Math.max(H,W,J)*2;if(K===0)return 30;let U=30+(Math.round(J)<<2|Math.round(W)<<1|Math.round(H));if(K===2)U+=60;return U},enumerable:!1},rgbToAnsi:{value:(O,H,W)=>X.ansi256ToAnsi(X.rgbToAnsi256(O,H,W)),enumerable:!1},hexToAnsi:{value:(O)=>X.ansi256ToAnsi(X.hexToAnsi256(O)),enumerable:!1}}),X};var F=($=0)=>(O)=>`\x1B[${O+$}m`,T=($=0)=>(O)=>`\x1B[${38+$};5;${O}m`,A=($=0)=>(O,H,W)=>`\x1B[${38+$};2;${O};${H};${W}m`,X={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},B0=Object.keys(X.modifier),n=Object.keys(X.color),a=Object.keys(X.bgColor),G0=[...n,...a],o=l(),G=o;import R from"process";import r from"os";import b from"tty";var B=function($,O=globalThis.Deno?globalThis.Deno.args:R.argv){const H=$.startsWith("-")?"":$.length===1?"-":"--",W=O.indexOf(H+$),J=O.indexOf("--");return W!==-1&&(J===-1||W<J)},s=function(){if("FORCE_COLOR"in Z){if(Z.FORCE_COLOR==="true")return 1;if(Z.FORCE_COLOR==="false")return 0;return Z.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(Z.FORCE_COLOR,10),3)}},t=function($){if($===0)return!1;return{level:$,hasBasic:!0,has256:$>=2,has16m:$>=3}},e=function($,{streamIsTTY:O,sniffFlags:H=!0}={}){const W=s();if(W!==void 0)I=W;const J=H?I:W;if(J===0)return 0;if(H){if(B("color=16m")||B("color=full")||B("color=truecolor"))return 3;if(B("color=256"))return 2}if("TF_BUILD"in Z&&"AGENT_NAME"in Z)return 1;if($&&!O&&J===void 0)return 0;const K=J||0;if(Z.TERM==="dumb")return K;if(R.platform==="win32"){const U=r.release().split(".");if(Number(U[0])>=10&&Number(U[2])>=10586)return Number(U[2])>=14931?3:2;return 1}if("CI"in Z){if("GITHUB_ACTIONS"in Z||"GITEA_ACTIONS"in Z)return 3;if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((U)=>(U in Z))||Z.CI_NAME==="codeship")return 1;return K}if("TEAMCITY_VERSION"in Z)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Z.TEAMCITY_VERSION)?1:0;if(Z.COLORTERM==="truecolor")return 3;if(Z.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in Z){const U=Number.parseInt((Z.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Z.TERM_PROGRAM){case"iTerm.app":return U>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(Z.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Z.TERM))return 1;if("COLORTERM"in Z)return 1;return K};function S($,O={}){const H=e($,{streamIsTTY:$&&$.isTTY,...O});return t(H)}var{env:Z}=R,I;if(B("no-color")||B("no-colors")||B("color=false")||B("color=never"))I=0;else if(B("color")||B("colors")||B("color=true")||B("color=always"))I=1;var $0={stdout:S({isTTY:b.isatty(1)}),stderr:S({isTTY:b.isatty(2)})},_=$0;function C($,O,H){let W=$.indexOf(O);if(W===-1)return $;const J=O.length;let K=0,U="";do U+=$.slice(K,W)+O+H,K=W+J,W=$.indexOf(O,K);while(W!==-1);return U+=$.slice(K),U}function k($,O,H,W){let J=0,K="";do{const U=$[W-1]==="\r";K+=$.slice(J,U?W-1:W)+O+(U?"\r\n":"\n")+H,J=W+1,W=$.indexOf("\n",J)}while(W!==-1);return K+=$.slice(J),K}var Y=function($){return W0($)};var{stdout:x,stderr:v}=_,E=Symbol("GENERATOR"),P=Symbol("STYLER"),M=Symbol("IS_EMPTY"),f=["ansi","ansi","ansi256","ansi16m"],N=Object.create(null),O0=($,O={})=>{if(O.level&&!(Number.isInteger(O.level)&&O.level>=0&&O.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const H=x?x.level:0;$.level=O.level===void 0?H:O.level};var W0=($)=>{const O=(...H)=>H.join(" ");return O0(O,$),Object.setPrototypeOf(O,Y.prototype),O};Object.setPrototypeOf(Y.prototype,Function.prototype);for(let[$,O]of Object.entries(G))N[$]={get(){const H=L(this,D(O.open,O.close,this[P]),this[M]);return Object.defineProperty(this,$,{value:H}),H}};N.visible={get(){const $=L(this,this[P],!0);return Object.defineProperty(this,"visible",{value:$}),$}};var q=($,O,H,...W)=>{if($==="rgb"){if(O==="ansi16m")return G[H].ansi16m(...W);if(O==="ansi256")return G[H].ansi256(G.rgbToAnsi256(...W));return G[H].ansi(G.rgbToAnsi(...W))}if($==="hex")return q("rgb",O,H,...G.hexToRgb(...W));return G[H][$](...W)},H0=["rgb","hex","ansi256"];for(let $ of H0){N[$]={get(){const{level:H}=this;return function(...W){const J=D(q($,f[H],"color",...W),G.color.close,this[P]);return L(this,J,this[M])}}};const O="bg"+$[0].toUpperCase()+$.slice(1);N[O]={get(){const{level:H}=this;return function(...W){const J=D(q($,f[H],"bgColor",...W),G.bgColor.close,this[P]);return L(this,J,this[M])}}}}var J0=Object.defineProperties(()=>{},{...N,level:{enumerable:!0,get(){return this[E].level},set($){this[E].level=$}}}),D=($,O,H)=>{let W,J;if(H===void 0)W=$,J=O;else W=H.openAll+$,J=O+H.closeAll;return{open:$,close:O,openAll:W,closeAll:J,parent:H}},L=($,O,H)=>{const W=(...J)=>K0(W,J.length===1?""+J[0]:J.join(" "));return Object.setPrototypeOf(W,J0),W[E]=$,W[P]=O,W[M]=H,W},K0=($,O)=>{if($.level<=0||!O)return $[M]?"":O;let H=$[P];if(H===void 0)return O;const{openAll:W,closeAll:J}=H;if(O.includes("\x1B"))while(H!==void 0)O=C(O,H.close,H.open),H=H.parent;const K=O.indexOf("\n");if(K!==-1)O=k(O,J,W,K);return W+O+J};Object.defineProperties(Y.prototype,N);var Q0=Y(),E0=Y({level:v?v.level:0});var Q=Q0;import{StatusMap as U0} from"elysia";function y($){return $.replace(/\u001b\[\d*m/g,"").trimStart()}var h=($,O,H)=>{const{request:W,path:J,body:K,query:U,set:j}=$;let z={};for(let g of O)switch(g){case"ip":z.ip=W.headers.get("x-forwarded-for")||"<ip?>";break;case"method":z.method=W.method;break;case"path":z.path=J;break;case"body":z.body=K;break;case"query":z.query=U;break;case"time":z.time=new Date;break;case"contentLength":z.contentLength=Number(W.headers.get("content-length"));break;case"status":if(!j.status)break;z.status=typeof j.status==="number"?j.status:U0[j.status];break;case"referer":z.referer=W.headers.get("referer")||"<referer?>";break;case"userAgent":z.userAgent=W.headers.get("user-agent")||"<user-agent?>";break;case"duration":const i=process.hrtime.bigint();z.duration=(i-H)/1000n;break}return z},V=($,O)=>{let H=Q.bgBlack;switch($){case"http":H=O[$]&&Q.hex(O[$])||Q.bgBlue;break;case"info":H=O[$]&&Q.hex(O[$])||Q.bgGreen;break;case"warn":H=O[$]&&Q.hex(O[$])||Q.bgYellow;break;case"debug":H=O[$]&&Q.hex(O[$])||Q.bgCyan;break;case"error":H=O[$]&&Q.hex(O[$])||Q.bgRed;break}const W=` ${$.toUpperCase()} `;return H?.(W)??W};var m=($)=>new w($).use(["time","method","path","status"]).format({onSuccess({time:O,method:H,path:W,status:J}){const K=Q.gray(`${O.toISOString()}`),U=Q.cyan(`${H} ${W}`);let j=Q.white;if(200<=J&&J<300)j=Q.green;if(400<=J&&J<500)j=Q.yellow;if(500<=J)j=Q.red;return`[${K}] ${U} ${j(J)}`},onFailure({request:O,error:H,code:W,datetime:J}){const K=Q.gray(`${J.toISOString()}`),U=Q.red(`${O.method} ${O.url} ${H.message} ${W}`);return`[${K}] ${U}`}});var p=($)=>{const O=$.getFullYear(),H=$.getMonth()+1,W=$.getDate(),J=$.getHours(),K=$.getMinutes(),U=$.getSeconds();return`${W}/${H}/${O} ${J}:${K}:${U}`},X0={showLevel:!0},c=($)=>new w({...X0,...$}).use(["time","method","path","duration"]).format({onSuccess({time:O,method:H,path:W,duration:J}){const K=Q.gray(p(O)),U=Q.cyan(`${H} ${W}`);return`${K} ${U} ${J}\u03BCs`},onFailure({request:O,datetime:H}){const W=p(H);return Q.red(`${W} ${O.method} ${O.url}`)}});var u=($)=>new w($).use(["time","method","path","status"]).format({onSuccess({time:O,method:H,path:W,status:J}){const K=Q.gray(`${O.toString()}`),U=Q.cyan(`${H} ${W}`);let j=Q.white;if(200<=J&&J<300)j=Q.green;if(400<=J&&J<500)j=Q.yellow;if(500<=J)j=Q.red;return`[${K}] ${U} ${j(J)}`},onFailure({request:O,error:H,code:W,datetime:J}){const K=Q.gray(`${J.toString()}`),U=Q.red(`${O.method} ${O.url} ${H.message} ${W}`);return`[${K}] ${U}`}});var d=($)=>{switch($){case"common":return m;case"fancy":return c;case"commontz":return u}};import j0 from"fs";var a0=Q;class w{requestedAttrs;dest;showLevel;logLevelColour;httpLogging;explicitLogging;constructor($={}){this.requestedAttrs=[],this.showLevel=$.showLevel||!1,this.logLevelColour=$.logLevelColour||{},this.httpLogging=$.httpLogging||!0,this.explicitLogging=$.explicitLogging||!0,this.setDest($.dest||Bun.stdout)}setDest($){if($===Bun.stdin)throw new Error("Cannot log to stdin. Please provide a writable destination.");if($===Bun.stdout||$===Bun.stderr){this.dest=$;return}this.createFileIfNotExists($).then((O)=>this.dest=O).catch((O)=>{throw O})}async createFileIfNotExists($){if(!await $.exists())Bun.write($,"");return $}use($){if(Array.isArray($)){for(let O of $)this._use(O);return this}return this._use($),this}_use($){this.requestedAttrs.push($)}static preset($,O={}){return d($)(O)}build(){return new Z0({name:"logestic"}).decorate("logestic",this)}format($){return this.build().state("logestic_timeStart",0n).onRequest(({store:O,request:H})=>{if(O.logestic_timeStart=process.hrtime.bigint(),$.onRequest){let W=$.onRequest(H);if(this.showLevel)W=`${V("http",this.logLevelColour)} ${W}`;this.log(W)}}).onResponse({as:"global"},(O)=>{if(!this.httpLogging)return;const{store:{logestic_timeStart:H}}=O;let W=h(O,this.requestedAttrs,H),J=$.onSuccess(W);if(this.showLevel)J=`${V("http",this.logLevelColour)} ${J}`;this.log(J)}).onError({as:"global"},({request:O,error:H,code:W})=>{let J=new Date,K=$.onFailure({request:O,error:H,code:W,datetime:J});if(this.showLevel)K=`${V("error",this.logLevelColour)} ${K}`;this.log(K)})}async log($){const O=`${$}\n`;if(!this.dest.name||!this.dest.name.length){Bun.write(this.dest,O);return}const H=y(O);j0.appendFile(this.dest.name,H,(W)=>{if(W)throw W})}info($){if(!this.explicitLogging)return;let O=$;if(this.showLevel)O=`${V("info",this.logLevelColour)} ${$}`;this.log(O)}warn($){if(!this.explicitLogging)return;let O=$;if(this.showLevel)O=`${V("warn",this.logLevelColour)} ${$}`;this.log(O)}debug($){if(!this.explicitLogging)return;let O=$;if(this.showLevel)O=`${V("debug",this.logLevelColour)} ${$}`;this.log(O)}error($){if(!this.explicitLogging)return;let O=$;if(this.showLevel)O=`${V("error",this.logLevelColour)} ${$}`;this.log(O)}}export{a0 as chalk,w as Logestic};
import W$ from"elysia";var o=function(){const $=new Map;for(let[O,V]of Object.entries(U)){for(let[z,H]of Object.entries(V))U[z]={open:`\x1B[${H[0]}m`,close:`\x1B[${H[1]}m`},V[z]=U[z],$.set(H[0],H[1]);Object.defineProperty(U,O,{value:V,enumerable:!1})}return Object.defineProperty(U,"codes",{value:$,enumerable:!1}),U.color.close="\x1B[39m",U.bgColor.close="\x1B[49m",U.color.ansi=E(),U.color.ansi256=T(),U.color.ansi16m=k(),U.bgColor.ansi=E(10),U.bgColor.ansi256=T(10),U.bgColor.ansi16m=k(10),Object.defineProperties(U,{rgbToAnsi256:{value(O,V,z){if(O===V&&V===z){if(O<8)return 16;if(O>248)return 231;return Math.round((O-8)/247*24)+232}return 16+36*Math.round(O/255*5)+6*Math.round(V/255*5)+Math.round(z/255*5)},enumerable:!1},hexToRgb:{value(O){const V=/[a-f\d]{6}|[a-f\d]{3}/i.exec(O.toString(16));if(!V)return[0,0,0];let[z]=V;if(z.length===3)z=[...z].map((J)=>J+J).join("");const H=Number.parseInt(z,16);return[H>>16&255,H>>8&255,H&255]},enumerable:!1},hexToAnsi256:{value:(O)=>U.rgbToAnsi256(...U.hexToRgb(O)),enumerable:!1},ansi256ToAnsi:{value(O){if(O<8)return 30+O;if(O<16)return 90+(O-8);let V,z,H;if(O>=232)V=((O-232)*10+8)/255,z=V,H=V;else{O-=16;const X=O%36;V=Math.floor(O/36)/5,z=Math.floor(X/6)/5,H=X%6/5}const J=Math.max(V,z,H)*2;if(J===0)return 30;let Q=30+(Math.round(H)<<2|Math.round(z)<<1|Math.round(V));if(J===2)Q+=60;return Q},enumerable:!1},rgbToAnsi:{value:(O,V,z)=>U.ansi256ToAnsi(U.rgbToAnsi256(O,V,z)),enumerable:!1},hexToAnsi:{value:(O)=>U.ansi256ToAnsi(U.hexToAnsi256(O)),enumerable:!1}}),U};var E=($=0)=>(O)=>`\x1B[${O+$}m`,T=($=0)=>(O)=>`\x1B[${38+$};5;${O}m`,k=($=0)=>(O,V,z)=>`\x1B[${38+$};2;${O};${V};${z}m`,U={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},w$=Object.keys(U.modifier),n=Object.keys(U.color),a=Object.keys(U.bgColor),P$=[...n,...a],r=o(),P=r;import N from"process";import l from"os";import F from"tty";var w=function($,O=globalThis.Deno?globalThis.Deno.args:N.argv){const V=$.startsWith("-")?"":$.length===1?"-":"--",z=O.indexOf(V+$),H=O.indexOf("--");return z!==-1&&(H===-1||z<H)},t=function(){if("FORCE_COLOR"in W){if(W.FORCE_COLOR==="true")return 1;if(W.FORCE_COLOR==="false")return 0;return W.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(W.FORCE_COLOR,10),3)}},s=function($){if($===0)return!1;return{level:$,hasBasic:!0,has256:$>=2,has16m:$>=3}},e=function($,{streamIsTTY:O,sniffFlags:V=!0}={}){const z=t();if(z!==void 0)Y=z;const H=V?Y:z;if(H===0)return 0;if(V){if(w("color=16m")||w("color=full")||w("color=truecolor"))return 3;if(w("color=256"))return 2}if("TF_BUILD"in W&&"AGENT_NAME"in W)return 1;if($&&!O&&H===void 0)return 0;const J=H||0;if(W.TERM==="dumb")return J;if(N.platform==="win32"){const Q=l.release().split(".");if(Number(Q[0])>=10&&Number(Q[2])>=10586)return Number(Q[2])>=14931?3:2;return 1}if("CI"in W){if("GITHUB_ACTIONS"in W||"GITEA_ACTIONS"in W)return 3;if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((Q)=>(Q in W))||W.CI_NAME==="codeship")return 1;return J}if("TEAMCITY_VERSION"in W)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(W.TEAMCITY_VERSION)?1:0;if(W.COLORTERM==="truecolor")return 3;if(W.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in W){const Q=Number.parseInt((W.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(W.TERM_PROGRAM){case"iTerm.app":return Q>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(W.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(W.TERM))return 1;if("COLORTERM"in W)return 1;return J};function S($,O={}){const V=e($,{streamIsTTY:$&&$.isTTY,...O});return s(V)}var{env:W}=N,Y;if(w("no-color")||w("no-colors")||w("color=false")||w("color=never"))Y=0;else if(w("color")||w("colors")||w("color=true")||w("color=always"))Y=1;var $$={stdout:S({isTTY:F.isatty(1)}),stderr:S({isTTY:F.isatty(2)})},h=$$;function A($,O,V){let z=$.indexOf(O);if(z===-1)return $;const H=O.length;let J=0,Q="";do Q+=$.slice(J,z)+O+V,J=z+H,z=$.indexOf(O,J);while(z!==-1);return Q+=$.slice(J),Q}function C($,O,V,z){let H=0,J="";do{const Q=$[z-1]==="\r";J+=$.slice(H,Q?z-1:z)+O+(Q?"\r\n":"\n")+V,H=z+1,z=$.indexOf("\n",H)}while(z!==-1);return J+=$.slice(H),J}var M=function($){return z$($)};var{stdout:_,stderr:b}=h,q=Symbol("GENERATOR"),B=Symbol("STYLER"),L=Symbol("IS_EMPTY"),f=["ansi","ansi","ansi256","ansi16m"],I=Object.create(null),O$=($,O={})=>{if(O.level&&!(Number.isInteger(O.level)&&O.level>=0&&O.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const V=_?_.level:0;$.level=O.level===void 0?V:O.level};var z$=($)=>{const O=(...V)=>V.join(" ");return O$(O,$),Object.setPrototypeOf(O,M.prototype),O};Object.setPrototypeOf(M.prototype,Function.prototype);for(let[$,O]of Object.entries(P))I[$]={get(){const V=x(this,D(O.open,O.close,this[B]),this[L]);return Object.defineProperty(this,$,{value:V}),V}};I.visible={get(){const $=x(this,this[B],!0);return Object.defineProperty(this,"visible",{value:$}),$}};var R=($,O,V,...z)=>{if($==="rgb"){if(O==="ansi16m")return P[V].ansi16m(...z);if(O==="ansi256")return P[V].ansi256(P.rgbToAnsi256(...z));return P[V].ansi(P.rgbToAnsi(...z))}if($==="hex")return R("rgb",O,V,...P.hexToRgb(...z));return P[V][$](...z)},V$=["rgb","hex","ansi256"];for(let $ of V$){I[$]={get(){const{level:V}=this;return function(...z){const H=D(R($,f[V],"color",...z),P.color.close,this[B]);return x(this,H,this[L])}}};const O="bg"+$[0].toUpperCase()+$.slice(1);I[O]={get(){const{level:V}=this;return function(...z){const H=D(R($,f[V],"bgColor",...z),P.bgColor.close,this[B]);return x(this,H,this[L])}}}}var H$=Object.defineProperties(()=>{},{...I,level:{enumerable:!0,get(){return this[q].level},set($){this[q].level=$}}}),D=($,O,V)=>{let z,H;if(V===void 0)z=$,H=O;else z=V.openAll+$,H=O+V.closeAll;return{open:$,close:O,openAll:z,closeAll:H,parent:V}},x=($,O,V)=>{const z=(...H)=>J$(z,H.length===1?""+H[0]:H.join(" "));return Object.setPrototypeOf(z,H$),z[q]=$,z[B]=O,z[L]=V,z},J$=($,O)=>{if($.level<=0||!O)return $[L]?"":O;let V=$[B];if(V===void 0)return O;const{openAll:z,closeAll:H}=V;if(O.includes("\x1B"))while(V!==void 0)O=A(O,V.close,V.open),V=V.parent;const J=O.indexOf("\n");if(J!==-1)O=C(O,H,z,J);return z+O+H};Object.defineProperties(M.prototype,I);var K$=M(),q$=M({level:b?b.level:0});var K=K$;import{StatusMap as Q$} from"elysia";function m($){return $.replace(/\u001b\[\d*m/g,"").trimStart()}var v=($,O,V)=>{const{request:z,path:H,body:J,query:Q,set:X}=$;let Z={};for(let p of O)switch(p){case"ip":Z.ip=z.headers.get("x-forwarded-for")||"<ip?>";break;case"method":Z.method=z.method;break;case"path":Z.path=H;break;case"body":Z.body=J;break;case"query":Z.query=Q;break;case"time":Z.time=new Date;break;case"contentLength":Z.contentLength=Number(z.headers.get("content-length"));break;case"status":if(!X.status)break;Z.status=typeof X.status==="number"?X.status:Q$[X.status];break;case"referer":Z.referer=z.headers.get("referer")||"<referer?>";break;case"userAgent":Z.userAgent=z.headers.get("user-agent")||"<user-agent?>";break;case"duration":const g=process.hrtime.bigint();Z.duration=(g-V)/1000n;break}return Z},G=($,O)=>{let V=K.bgBlack;switch($){case"http":V=O[$]&&K.hex(O[$])||K.bgBlue;break;case"info":V=O[$]&&K.hex(O[$])||K.bgGreen;break;case"warn":V=O[$]&&K.hex(O[$])||K.bgYellow;break;case"debug":V=O[$]&&K.hex(O[$])||K.bgCyan;break;case"error":V=O[$]&&K.hex(O[$])||K.bgRed;break}const z=` ${$.toUpperCase()} `;return V?.(z)??z};var c=($)=>new j($).use(["time","method","path","status"]).format({onSuccess({time:O,method:V,path:z,status:H}){const J=K.gray(`${O.toISOString()}`),Q=K.cyan(`${V} ${z}`);let X=K.white;if(200<=H&&H<300)X=K.green;if(400<=H&&H<500)X=K.yellow;if(500<=H)X=K.red;return`[${J}] ${Q} ${X(H)}`},onFailure({request:O,error:V,code:z,datetime:H}){const J=K.gray(`${H.toISOString()}`),Q=K.red(`${O.method} ${O.url} ${V.message} ${z}`);return`[${J}] ${Q}`}});var u=($)=>{const O=$.getFullYear(),V=$.getMonth()+1,z=$.getDate(),H=$.getHours(),J=$.getMinutes(),Q=$.getSeconds();return`${z}/${V}/${O} ${H}:${J}:${Q}`},U$={showLevel:!0},d=($)=>new j({...U$,...$}).use(["time","method","path","duration"]).format({onSuccess({time:O,method:V,path:z,duration:H}){const J=K.gray(u(O)),Q=K.cyan(`${V} ${z}`);return`${J} ${Q} ${H}\u03BCs`},onFailure({request:O,datetime:V}){const z=u(V);return K.red(`${z} ${O.method} ${O.url}`)}});var i=($)=>new j($).use(["time","method","path","status"]).format({onSuccess({time:O,method:V,path:z,status:H}){const J=K.gray(`${O.toString()}`),Q=K.cyan(`${V} ${z}`);let X=K.white;if(200<=H&&H<300)X=K.green;if(400<=H&&H<500)X=K.yellow;if(500<=H)X=K.red;return`[${J}] ${Q} ${X(H)}`},onFailure({request:O,error:V,code:z,datetime:H}){const J=K.gray(`${H.toString()}`),Q=K.red(`${O.method} ${O.url} ${V.message} ${z}`);return`[${J}] ${Q}`}});var y=($)=>{switch($){case"common":return c;case"fancy":return d;case"commontz":return i}};import X$ from"fs";var a$=K;class j{requestedAttrs;dest;showLevel;logLevelColour;httpLogging;explicitLogging;constructor($={}){this.requestedAttrs=[],this.showLevel=$.showLevel||!1,this.logLevelColour=$.logLevelColour||{},this.httpLogging=$.httpLogging||!0,this.explicitLogging=$.explicitLogging||!0,this.setDest($.dest||Bun.stdout)}setDest($){if($===Bun.stdin)throw new Error("Cannot log to stdin. Please provide a writable destination.");if($===Bun.stdout||$===Bun.stderr){this.dest=$;return}this.createFileIfNotExists($).then((O)=>this.dest=O).catch((O)=>{throw O})}async createFileIfNotExists($){if(!await $.exists())Bun.write($,"");return $}use($){if(Array.isArray($)){for(let O of $)this._use(O);return this}return this._use($),this}_use($){this.requestedAttrs.push($)}static preset($,O={}){return y($)(O)}build(){return new W$({name:"logestic"}).decorate("logestic",this)}format($){return this.build().state("logestic_timeStart",0n).onRequest(({store:O,request:V})=>{if(O.logestic_timeStart=process.hrtime.bigint(),$.onRequest){let z=$.onRequest(V);if(this.showLevel)z=`${G("http",this.logLevelColour)} ${z}`;this.log(z)}}).onAfterResponse({as:"global"},(O)=>{if(!this.httpLogging)return;const{store:{logestic_timeStart:V}}=O;let z=v(O,this.requestedAttrs,V),H=$.onSuccess(z);if(this.showLevel)H=`${G("http",this.logLevelColour)} ${H}`;this.log(H)}).onError({as:"global"},({request:O,error:V,code:z})=>{let H=new Date,J=$.onFailure({request:O,error:V,code:z,datetime:H});if(this.showLevel)J=`${G("error",this.logLevelColour)} ${J}`;this.log(J)})}async log($){const O=`${$}\n`;if(!this.dest.name||!this.dest.name.length){Bun.write(this.dest,O);return}const V=m(O);X$.appendFile(this.dest.name,V,(z)=>{if(z)throw z})}info($){if(!this.explicitLogging)return;let O=$;if(this.showLevel)O=`${G("info",this.logLevelColour)} ${$}`;this.log(O)}warn($){if(!this.explicitLogging)return;let O=$;if(this.showLevel)O=`${G("warn",this.logLevelColour)} ${$}`;this.log(O)}debug($){if(!this.explicitLogging)return;let O=$;if(this.showLevel)O=`${G("debug",this.logLevelColour)} ${$}`;this.log(O)}error($){if(!this.explicitLogging)return;let O=$;if(this.showLevel)O=`${G("error",this.logLevelColour)} ${$}`;this.log(O)}}export{a$ as chalk,j as Logestic};

@@ -18,2 +18,3 @@ import { Logestic } from '..';

macro: {};
macroFn: {};
}, {}, {

@@ -20,0 +21,0 @@ derive: {};

@@ -18,2 +18,3 @@ import { Logestic } from '..';

macro: {};
macroFn: {};
}, {}, {

@@ -20,0 +21,0 @@ derive: {};

@@ -18,2 +18,3 @@ import { Logestic } from '..';

macro: {};
macroFn: {};
}, {}, {

@@ -20,0 +21,0 @@ derive: {};

@@ -17,2 +17,3 @@ import { Preset } from '../types';

macro: {};
macroFn: {};
}, {}, {

@@ -19,0 +20,0 @@ derive: {};

@@ -7,4 +7,2 @@ /**

*/
/// <reference types="bun-types" />
/// <reference types="bun-types" />
import { BunFile } from 'bun';

@@ -11,0 +9,0 @@ export type Attribute = {

{
"name": "logestic",
"version": "1.2.0",
"version": "1.2.1",
"author": "Nishant Aanjaney Jalan <cybercoder.nishant@gmail.com>",

@@ -33,3 +33,3 @@ "description": "An advanced and customisable logging library for ElysiaJS",

"typescript": "^5.0.0",
"elysia": "^1.0.9"
"elysia": "^1.1.3"
},

@@ -39,3 +39,3 @@ "devDependencies": {

"bun-types": "latest",
"elysia": "^1.0.9",
"elysia": "^1.1.3",
"rimraf": "^5.0.5",

@@ -42,0 +42,0 @@ "typescript": "^5.4.3"

@@ -27,4 +27,11 @@ # Logestic

```
**Note**: You must have `elysia@1.0` installed in your project.
## Compatibility Matrix
| Logestic Version | Elysia Version | Compatible? |
| :--------------: | :------------: | :---------: |
| <= v1.2.0 | v1.0.9 | ✅ |
| v1.2.0 | v1.1.0 | ❌ |
| v1.2.1 | v1.1.3 | ✅ |
## Usage

@@ -31,0 +38,0 @@

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