+53
-10
@@ -13,9 +13,28 @@ interface Theme { | ||
| } | ||
| declare const modernTheme: Theme; | ||
| declare const minimalTheme: Theme; | ||
| declare const classicTheme: Theme; | ||
| declare const defaultTheme: Theme; | ||
| declare enum LogLevel { | ||
| trace = 10, | ||
| debug = 20, | ||
| info = 30, | ||
| success = 35, | ||
| warn = 40, | ||
| error = 50, | ||
| fatal = 60, | ||
| none = 100 | ||
| } | ||
| type LogLevelName = keyof typeof LogLevel; | ||
| interface TransportContext { | ||
| level: LogLevelName; | ||
| levelValue: number; | ||
| message: unknown[]; | ||
| formatted: string; | ||
| raw: string; | ||
| timestamp: string; | ||
| } | ||
| interface Transport { | ||
| success: (...args: unknown[]) => void; | ||
| error: (...args: unknown[]) => void; | ||
| warn: (...args: unknown[]) => void; | ||
| info: (...args: unknown[]) => void; | ||
| write(ctx: TransportContext): void; | ||
| } | ||
@@ -26,4 +45,9 @@ interface LoggerOptions { | ||
| colors?: boolean; | ||
| transport?: Partial<Transport>; | ||
| level?: LogLevelName; | ||
| mode?: 'text' | 'json'; | ||
| transports?: Transport[]; | ||
| } | ||
| declare class ConsoleTransport implements Transport { | ||
| write(ctx: TransportContext): void; | ||
| } | ||
| declare class Logger { | ||
@@ -33,9 +57,14 @@ private theme; | ||
| private colors; | ||
| private transport; | ||
| private level; | ||
| private mode; | ||
| private transports; | ||
| private timeCache; | ||
| constructor(options?: LoggerOptions); | ||
| private shouldLog; | ||
| private getTimestamp; | ||
| private safeStringify; | ||
| private highlightJson; | ||
| private formatMessage; | ||
| private stripAnsi; | ||
| private output; | ||
| private emit; | ||
| private dispatch; | ||
| success(...message: unknown[]): void; | ||
@@ -45,2 +74,6 @@ error(...message: unknown[]): void; | ||
| info(...message: unknown[]): void; | ||
| trace(...message: unknown[]): void; | ||
| debug(...message: unknown[]): void; | ||
| fatal(...message: unknown[]): void; | ||
| box(title: string, message: string): void; | ||
| } | ||
@@ -74,7 +107,13 @@ declare const createLogger: (options?: LoggerOptions) => Logger; | ||
| declare const inverse: (text: string) => string; | ||
| declare const rgb: (r: number, g: number, b: number, text: string) => string; | ||
| declare const bgRgb: (r: number, g: number, b: number, text: string) => string; | ||
| declare const hex: (hexCode: string, text: string) => string; | ||
| declare const bgHex: (hexCode: string, text: string) => string; | ||
| declare const color256: (code: number, text: string) => string; | ||
| declare const bgColor256: (code: number, text: string) => string; | ||
| declare const stripAnsi: (text: string) => string; | ||
| declare const ansi_bgBlack: typeof bgBlack; | ||
| declare const ansi_bgBlue: typeof bgBlue; | ||
| declare const ansi_bgColor256: typeof bgColor256; | ||
| declare const ansi_bgCyan: typeof bgCyan; | ||
@@ -85,2 +124,3 @@ declare const ansi_bgGreen: typeof bgGreen; | ||
| declare const ansi_bgRed: typeof bgRed; | ||
| declare const ansi_bgRgb: typeof bgRgb; | ||
| declare const ansi_bgWhite: typeof bgWhite; | ||
@@ -91,2 +131,3 @@ declare const ansi_bgYellow: typeof bgYellow; | ||
| declare const ansi_bold: typeof bold; | ||
| declare const ansi_color256: typeof color256; | ||
| declare const ansi_cyan: typeof cyan; | ||
@@ -104,2 +145,4 @@ declare const ansi_dim: typeof dim; | ||
| declare const ansi_reset: typeof reset; | ||
| declare const ansi_rgb: typeof rgb; | ||
| declare const ansi_stripAnsi: typeof stripAnsi; | ||
| declare const ansi_underline: typeof underline; | ||
@@ -109,5 +152,5 @@ declare const ansi_white: typeof white; | ||
| declare namespace ansi { | ||
| export { ansi_bgBlack as bgBlack, ansi_bgBlue as bgBlue, ansi_bgCyan as bgCyan, ansi_bgGreen as bgGreen, ansi_bgHex as bgHex, ansi_bgMagenta as bgMagenta, ansi_bgRed as bgRed, ansi_bgWhite as bgWhite, ansi_bgYellow as bgYellow, ansi_black as black, ansi_blue as blue, ansi_bold as bold, ansi_cyan as cyan, ansi_dim as dim, ansi_format as format, ansi_gray as gray, ansi_green as green, ansi_hex as hex, ansi_inverse as inverse, ansi_isColorSupported as isColorSupported, ansi_italic as italic, ansi_magenta as magenta, ansi_red as red, ansi_reset as reset, ansi_underline as underline, ansi_white as white, ansi_yellow as yellow }; | ||
| export { ansi_bgBlack as bgBlack, ansi_bgBlue as bgBlue, ansi_bgColor256 as bgColor256, ansi_bgCyan as bgCyan, ansi_bgGreen as bgGreen, ansi_bgHex as bgHex, ansi_bgMagenta as bgMagenta, ansi_bgRed as bgRed, ansi_bgRgb as bgRgb, ansi_bgWhite as bgWhite, ansi_bgYellow as bgYellow, ansi_black as black, ansi_blue as blue, ansi_bold as bold, ansi_color256 as color256, ansi_cyan as cyan, ansi_dim as dim, ansi_format as format, ansi_gray as gray, ansi_green as green, ansi_hex as hex, ansi_inverse as inverse, ansi_isColorSupported as isColorSupported, ansi_italic as italic, ansi_magenta as magenta, ansi_red as red, ansi_reset as reset, ansi_rgb as rgb, ansi_stripAnsi as stripAnsi, ansi_underline as underline, ansi_white as white, ansi_yellow as yellow }; | ||
| } | ||
| export { Logger, type LoggerOptions, type Theme, ansi, createLogger, defaultTheme }; | ||
| export { ConsoleTransport, LogLevel, type LogLevelName, Logger, type LoggerOptions, type Theme, type Transport, type TransportContext, ansi, classicTheme, createLogger, defaultTheme, minimalTheme, modernTheme }; |
+53
-10
@@ -13,9 +13,28 @@ interface Theme { | ||
| } | ||
| declare const modernTheme: Theme; | ||
| declare const minimalTheme: Theme; | ||
| declare const classicTheme: Theme; | ||
| declare const defaultTheme: Theme; | ||
| declare enum LogLevel { | ||
| trace = 10, | ||
| debug = 20, | ||
| info = 30, | ||
| success = 35, | ||
| warn = 40, | ||
| error = 50, | ||
| fatal = 60, | ||
| none = 100 | ||
| } | ||
| type LogLevelName = keyof typeof LogLevel; | ||
| interface TransportContext { | ||
| level: LogLevelName; | ||
| levelValue: number; | ||
| message: unknown[]; | ||
| formatted: string; | ||
| raw: string; | ||
| timestamp: string; | ||
| } | ||
| interface Transport { | ||
| success: (...args: unknown[]) => void; | ||
| error: (...args: unknown[]) => void; | ||
| warn: (...args: unknown[]) => void; | ||
| info: (...args: unknown[]) => void; | ||
| write(ctx: TransportContext): void; | ||
| } | ||
@@ -26,4 +45,9 @@ interface LoggerOptions { | ||
| colors?: boolean; | ||
| transport?: Partial<Transport>; | ||
| level?: LogLevelName; | ||
| mode?: 'text' | 'json'; | ||
| transports?: Transport[]; | ||
| } | ||
| declare class ConsoleTransport implements Transport { | ||
| write(ctx: TransportContext): void; | ||
| } | ||
| declare class Logger { | ||
@@ -33,9 +57,14 @@ private theme; | ||
| private colors; | ||
| private transport; | ||
| private level; | ||
| private mode; | ||
| private transports; | ||
| private timeCache; | ||
| constructor(options?: LoggerOptions); | ||
| private shouldLog; | ||
| private getTimestamp; | ||
| private safeStringify; | ||
| private highlightJson; | ||
| private formatMessage; | ||
| private stripAnsi; | ||
| private output; | ||
| private emit; | ||
| private dispatch; | ||
| success(...message: unknown[]): void; | ||
@@ -45,2 +74,6 @@ error(...message: unknown[]): void; | ||
| info(...message: unknown[]): void; | ||
| trace(...message: unknown[]): void; | ||
| debug(...message: unknown[]): void; | ||
| fatal(...message: unknown[]): void; | ||
| box(title: string, message: string): void; | ||
| } | ||
@@ -74,7 +107,13 @@ declare const createLogger: (options?: LoggerOptions) => Logger; | ||
| declare const inverse: (text: string) => string; | ||
| declare const rgb: (r: number, g: number, b: number, text: string) => string; | ||
| declare const bgRgb: (r: number, g: number, b: number, text: string) => string; | ||
| declare const hex: (hexCode: string, text: string) => string; | ||
| declare const bgHex: (hexCode: string, text: string) => string; | ||
| declare const color256: (code: number, text: string) => string; | ||
| declare const bgColor256: (code: number, text: string) => string; | ||
| declare const stripAnsi: (text: string) => string; | ||
| declare const ansi_bgBlack: typeof bgBlack; | ||
| declare const ansi_bgBlue: typeof bgBlue; | ||
| declare const ansi_bgColor256: typeof bgColor256; | ||
| declare const ansi_bgCyan: typeof bgCyan; | ||
@@ -85,2 +124,3 @@ declare const ansi_bgGreen: typeof bgGreen; | ||
| declare const ansi_bgRed: typeof bgRed; | ||
| declare const ansi_bgRgb: typeof bgRgb; | ||
| declare const ansi_bgWhite: typeof bgWhite; | ||
@@ -91,2 +131,3 @@ declare const ansi_bgYellow: typeof bgYellow; | ||
| declare const ansi_bold: typeof bold; | ||
| declare const ansi_color256: typeof color256; | ||
| declare const ansi_cyan: typeof cyan; | ||
@@ -104,2 +145,4 @@ declare const ansi_dim: typeof dim; | ||
| declare const ansi_reset: typeof reset; | ||
| declare const ansi_rgb: typeof rgb; | ||
| declare const ansi_stripAnsi: typeof stripAnsi; | ||
| declare const ansi_underline: typeof underline; | ||
@@ -109,5 +152,5 @@ declare const ansi_white: typeof white; | ||
| declare namespace ansi { | ||
| export { ansi_bgBlack as bgBlack, ansi_bgBlue as bgBlue, ansi_bgCyan as bgCyan, ansi_bgGreen as bgGreen, ansi_bgHex as bgHex, ansi_bgMagenta as bgMagenta, ansi_bgRed as bgRed, ansi_bgWhite as bgWhite, ansi_bgYellow as bgYellow, ansi_black as black, ansi_blue as blue, ansi_bold as bold, ansi_cyan as cyan, ansi_dim as dim, ansi_format as format, ansi_gray as gray, ansi_green as green, ansi_hex as hex, ansi_inverse as inverse, ansi_isColorSupported as isColorSupported, ansi_italic as italic, ansi_magenta as magenta, ansi_red as red, ansi_reset as reset, ansi_underline as underline, ansi_white as white, ansi_yellow as yellow }; | ||
| export { ansi_bgBlack as bgBlack, ansi_bgBlue as bgBlue, ansi_bgColor256 as bgColor256, ansi_bgCyan as bgCyan, ansi_bgGreen as bgGreen, ansi_bgHex as bgHex, ansi_bgMagenta as bgMagenta, ansi_bgRed as bgRed, ansi_bgRgb as bgRgb, ansi_bgWhite as bgWhite, ansi_bgYellow as bgYellow, ansi_black as black, ansi_blue as blue, ansi_bold as bold, ansi_color256 as color256, ansi_cyan as cyan, ansi_dim as dim, ansi_format as format, ansi_gray as gray, ansi_green as green, ansi_hex as hex, ansi_inverse as inverse, ansi_isColorSupported as isColorSupported, ansi_italic as italic, ansi_magenta as magenta, ansi_red as red, ansi_reset as reset, ansi_rgb as rgb, ansi_stripAnsi as stripAnsi, ansi_underline as underline, ansi_white as white, ansi_yellow as yellow }; | ||
| } | ||
| export { Logger, type LoggerOptions, type Theme, ansi, createLogger, defaultTheme }; | ||
| export { ConsoleTransport, LogLevel, type LogLevelName, Logger, type LoggerOptions, type Theme, type Transport, type TransportContext, ansi, classicTheme, createLogger, defaultTheme, minimalTheme, modernTheme }; |
+4
-2
@@ -1,2 +0,4 @@ | ||
| 'use strict';var h=Object.defineProperty;var x=(t,s)=>{for(var r in s)h(t,r,{get:s[r],enumerable:true});};var l={};x(l,{bgBlack:()=>I,bgBlue:()=>M,bgCyan:()=>E,bgGreen:()=>R,bgHex:()=>g,bgMagenta:()=>S,bgRed:()=>L,bgWhite:()=>N,bgYellow:()=>C,black:()=>d,blue:()=>v,bold:()=>o,cyan:()=>k,dim:()=>j,format:()=>e,gray:()=>m,green:()=>T,hex:()=>n,inverse:()=>z,isColorSupported:()=>p,italic:()=>A,magenta:()=>O,red:()=>w,reset:()=>b,underline:()=>J,white:()=>y,yellow:()=>$});var p=!process.env.NO_COLOR&&(process.env.FORCE_COLOR||process.stdout?.isTTY||process.env.TERM==="xterm-256color"),e=(t,s)=>p?`\x1B[${t}m${s}\x1B[0m`:s,b=t=>e(0,t),d=t=>e(30,t),w=t=>e(31,t),T=t=>e(32,t),$=t=>e(33,t),v=t=>e(34,t),O=t=>e(35,t),k=t=>e(36,t),y=t=>e(37,t),m=t=>e(90,t),I=t=>e(40,t),L=t=>e(41,t),R=t=>e(42,t),C=t=>e(43,t),M=t=>e(44,t),S=t=>e(45,t),E=t=>e(46,t),N=t=>e(47,t),o=t=>e(1,t),j=t=>e(2,t),A=t=>e(3,t),J=t=>e(4,t),z=t=>e(7,t),n=(t,s)=>{if(!p)return s;let r=t.replace(/^#/,"");if(r.length!==6)return s;let i=parseInt(r.substring(0,2),16),u=parseInt(r.substring(2,4),16),f=parseInt(r.substring(4,6),16);return `\x1B[38;2;${i};${u};${f}m${s}\x1B[0m`},g=(t,s)=>{if(!p)return s;let r=t.replace(/^#/,"");if(r.length!==6)return s;let i=parseInt(r.substring(0,2),16),u=parseInt(r.substring(2,4),16),f=parseInt(r.substring(4,6),16);return `\x1B[48;2;${i};${u};${f}m${s}\x1B[0m`};var a={success:t=>t,error:t=>t,warn:t=>t,info:t=>t,prefix:{success:n("#10b981","\u2714")+" "+g("#064e3b",n("#34d399",o(" SUCCESS "))),error:n("#ef4444","\u2716")+" "+g("#7f1d1d",n("#f87171",o(" ERROR "))),warn:n("#f59e0b","\u26A0")+" "+g("#78350f",n("#fbbf24",o(" WARNING "))),info:n("#0ea5e9","\u2139")+" "+g("#0c4a6e",n("#38bdf8",o(" INFO ")))}};var B={success:console.log,error:console.error,warn:console.warn,info:console.info},c=class{theme;timestamps;colors;transport;constructor(s={}){this.theme={...a,...s.theme,prefix:{...a.prefix,...s.theme?.prefix}},this.timestamps=s.timestamps??false,this.colors=s.colors??true,this.transport={...B,...s.transport};}getTimestamp(){if(!this.timestamps)return "";let r=new Date().toISOString().split("T")[1]?.split(".")[0];return m(`[${r}] `)}highlightJson(s){return this.colors?s.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,r=>/^"/.test(r)?/:$/.test(r)?n("#9ca3af",r.slice(0,-1))+":":n("#34d399",r):/true|false/.test(r)?n("#c084fc",r):/null/.test(r)?n("#f87171",r):n("#fbbf24",r)):s}formatMessage(s){return s.map(r=>{if(typeof r=="string")return r;try{let i=JSON.stringify(r,null,2);return ` | ||
| `+this.highlightJson(i)}catch{return "[Unserializable Object]"}}).join(" ")}stripAnsi(s){return s.replace(/\x1b\[[0-9;]*m/g,"")}output(s,r){let i=this.colors?r:this.stripAnsi(r);this.transport[s](i);}success(...s){let r=this.formatMessage(s);this.output("success",`${this.getTimestamp()}${this.theme.prefix.success} ${this.theme.success(r)}`);}error(...s){let r=this.formatMessage(s);this.output("error",`${this.getTimestamp()}${this.theme.prefix.error} ${this.theme.error(r)}`);}warn(...s){let r=this.formatMessage(s);this.output("warn",`${this.getTimestamp()}${this.theme.prefix.warn} ${this.theme.warn(r)}`);}info(...s){let r=this.formatMessage(s);this.output("info",`${this.getTimestamp()}${this.theme.prefix.info} ${this.theme.info(r)}`);}},F=t=>new c(t);exports.Logger=c;exports.ansi=l;exports.createLogger=F;exports.defaultTheme=a; | ||
| 'use strict';var M=Object.defineProperty;var A=(t,r)=>{for(var e in r)M(t,e,{get:r[e],enumerable:true});};var I={};A(I,{bgBlack:()=>F,bgBlue:()=>Y,bgColor256:()=>tt,bgCyan:()=>G,bgGreen:()=>U,bgHex:()=>Q,bgMagenta:()=>D,bgRed:()=>L,bgRgb:()=>R,bgWhite:()=>H,bgYellow:()=>W,black:()=>B,blue:()=>J,bold:()=>P,color256:()=>X,cyan:()=>v,dim:()=>h,format:()=>i,gray:()=>b,green:()=>w,hex:()=>s,inverse:()=>K,isColorSupported:()=>p,italic:()=>Z,magenta:()=>_,red:()=>d,reset:()=>V,rgb:()=>S,stripAnsi:()=>u,underline:()=>q,white:()=>z,yellow:()=>T});var x=process.env,p=!x.NO_COLOR&&(x.FORCE_COLOR||process.stdout&&process.stdout.isTTY||x.TERM==="xterm-256color"||x.CI==="true"),i=(t,r)=>p?`\x1B[${t}m${r}\x1B[0m`:r,V=t=>i(0,t),B=t=>i(30,t),d=t=>i(31,t),w=t=>i(32,t),T=t=>i(33,t),J=t=>i(34,t),_=t=>i(35,t),v=t=>i(36,t),z=t=>i(37,t),b=t=>i(90,t),F=t=>i(40,t),L=t=>i(41,t),U=t=>i(42,t),W=t=>i(43,t),Y=t=>i(44,t),D=t=>i(45,t),G=t=>i(46,t),H=t=>i(47,t),P=t=>i(1,t),h=t=>i(2,t),Z=t=>i(3,t),q=t=>i(4,t),K=t=>i(7,t),S=(t,r,e,o)=>p?`\x1B[38;2;${t};${r};${e}m${o}\x1B[0m`:o,R=(t,r,e,o)=>p?`\x1B[48;2;${t};${r};${e}m${o}\x1B[0m`:o,s=(t,r)=>{if(!p)return r;let e=t.replace(/^#/,"");return e.length!==6?r:S(parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16),r)},Q=(t,r)=>{if(!p)return r;let e=t.replace(/^#/,"");return e.length!==6?r:R(parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16),r)},X=(t,r)=>p?`\x1B[38;5;${t}m${r}\x1B[0m`:r,tt=(t,r)=>p?`\x1B[48;5;${t}m${r}\x1B[0m`:r,u=t=>t.replace(/\x1b\[[0-9;]*m/g,"");var N={success:t=>s("#10b981",t),error:t=>s("#f43f5e",t),warn:t=>s("#f59e0b",t),info:t=>s("#38bdf8",t),prefix:{success:s("#10b981","\u2714")+" "+s("#34d399",h("success")),error:s("#f43f5e","\u2716")+" "+s("#fb7185",h("error")),warn:s("#f59e0b","\u26A0")+" "+s("#fbbf24",h("warn")),info:s("#38bdf8","\u2139")+" "+s("#7dd3fc",h("info"))}},rt={success:t=>t,error:t=>t,warn:t=>t,info:t=>t,prefix:{success:s("#10b981","\u2714"),error:s("#f43f5e","\u2716"),warn:s("#f59e0b","\u26A0"),info:s("#38bdf8","\u2139")}},et={success:t=>w(t),error:t=>d(t),warn:t=>T(t),info:t=>v(t),prefix:{success:w("SUCCESS"),error:d("ERROR"),warn:T("WARN"),info:v("INFO")}},$=N;var y=(n=>(n[n.trace=10]="trace",n[n.debug=20]="debug",n[n.info=30]="info",n[n.success=35]="success",n[n.warn=40]="warn",n[n.error=50]="error",n[n.fatal=60]="fatal",n[n.none=100]="none",n))(y||{}),C=class{write(r){(r.levelValue>=50?console.error:console.log)(r.formatted);}},k=class{theme;timestamps;colors;level;mode;transports;timeCache={time:"",str:""};constructor(r={}){this.theme={...$,...r.theme,prefix:{...$.prefix,...r.theme?.prefix}},this.timestamps=r.timestamps??false,this.colors=r.colors??!!p,this.level=y[r.level??"trace"],this.mode=r.mode??"text",this.transports=r.transports??[new C];}shouldLog(r){return r>=this.level}getTimestamp(){if(!this.timestamps)return {iso:"",formatted:""};let e=new Date().toISOString(),o=e.split("T")[1]?.split(".")[0]||"";if(this.timeCache.time===o)return {iso:e,formatted:this.timeCache.str};let g=b(`[${o}] `);return this.timeCache={time:o,str:g},{iso:e,formatted:g}}safeStringify(r,e){let o=new Set;return JSON.stringify(r,(g,a)=>{if(typeof a=="object"&&a!==null){if(o.has(a))return "[Circular]";o.add(a);}return a},e)}highlightJson(r){return !this.colors||r.length>5e3?r:r.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,e=>/^"/.test(e)?/:$/.test(e)?s("#9ca3af",e.slice(0,-1))+":":s("#34d399",e):/true|false/.test(e)?s("#c084fc",e):/null/.test(e)?s("#f87171",e):s("#fbbf24",e))}formatMessage(r){return r.map(e=>{if(typeof e=="string")return e;if(e instanceof Error)return e.stack||e.message;try{return ` | ||
| `+this.highlightJson(this.safeStringify(e,2))}catch{return "[Unserializable]"}}).join(" ")}emit(r,e,o,g){let a=y[r];if(!this.shouldLog(a))return;let f=this.getTimestamp(),m,n;if(this.mode==="json"){let c={level:r,time:f.iso,message:g.length===1?g[0]:g};m=n=this.safeStringify(c);}else {let c=this.formatMessage(g);m=`${f.formatted}${e} ${o(c)}`,n=u(m),this.colors||(m=n);}this.dispatch(r,a,g,m,n,f.iso);}dispatch(r,e,o,g,a,f){let m={level:r,levelValue:e,message:o,formatted:g,raw:a,timestamp:f};for(let n=0;n<this.transports.length;n++)this.transports[n]?.write(m);}success(...r){this.emit("success",this.theme.prefix.success,this.theme.success,r);}error(...r){this.emit("error",this.theme.prefix.error,this.theme.error,r);}warn(...r){this.emit("warn",this.theme.prefix.warn,this.theme.warn,r);}info(...r){this.emit("info",this.theme.prefix.info,this.theme.info,r);}trace(...r){this.emit("trace",b("\u{1F50D}"),b,r);}debug(...r){this.emit("debug",s("#94a3b8","\u{1F41B}"),e=>s("#94a3b8",e),r);}fatal(...r){this.emit("fatal",s("#be123c","\u{1F480}"),e=>s("#be123c",e),r);}box(r,e){let o=30;if(!this.shouldLog(o))return;let g=e.split(` | ||
| `),a=Math.max(r.length,...g.map(l=>u(l).length))+4,f=`\u250C\u2500 ${r} ${"\u2500".repeat(a-r.length-3)}\u2510`,m=`\u2514${"\u2500".repeat(a)}\u2518`,n=g.map(l=>{let E=a-u(l).length-2;return `\u2502 ${l}${" ".repeat(Math.max(0,E))} \u2502`}),c=[f,...n,m].join(` | ||
| `),O=u(c);if(this.mode==="json"){let l=this.getTimestamp();c=O=this.safeStringify({level:"info",time:l.iso,title:r,message:e}),this.dispatch("info",o,[e],c,O,l.iso);return}this.colors&&(c=s("#38bdf8",c));let j=this.getTimestamp();this.dispatch("info",o,[e],c,O,j.iso);}},st=t=>new k(t);exports.ConsoleTransport=C;exports.LogLevel=y;exports.Logger=k;exports.ansi=I;exports.classicTheme=et;exports.createLogger=st;exports.defaultTheme=$;exports.minimalTheme=rt;exports.modernTheme=N; |
+4
-2
@@ -1,2 +0,4 @@ | ||
| var h=Object.defineProperty;var x=(t,s)=>{for(var r in s)h(t,r,{get:s[r],enumerable:true});};var l={};x(l,{bgBlack:()=>I,bgBlue:()=>M,bgCyan:()=>E,bgGreen:()=>R,bgHex:()=>g,bgMagenta:()=>S,bgRed:()=>L,bgWhite:()=>N,bgYellow:()=>C,black:()=>d,blue:()=>v,bold:()=>o,cyan:()=>k,dim:()=>j,format:()=>e,gray:()=>m,green:()=>T,hex:()=>n,inverse:()=>z,isColorSupported:()=>p,italic:()=>A,magenta:()=>O,red:()=>w,reset:()=>b,underline:()=>J,white:()=>y,yellow:()=>$});var p=!process.env.NO_COLOR&&(process.env.FORCE_COLOR||process.stdout?.isTTY||process.env.TERM==="xterm-256color"),e=(t,s)=>p?`\x1B[${t}m${s}\x1B[0m`:s,b=t=>e(0,t),d=t=>e(30,t),w=t=>e(31,t),T=t=>e(32,t),$=t=>e(33,t),v=t=>e(34,t),O=t=>e(35,t),k=t=>e(36,t),y=t=>e(37,t),m=t=>e(90,t),I=t=>e(40,t),L=t=>e(41,t),R=t=>e(42,t),C=t=>e(43,t),M=t=>e(44,t),S=t=>e(45,t),E=t=>e(46,t),N=t=>e(47,t),o=t=>e(1,t),j=t=>e(2,t),A=t=>e(3,t),J=t=>e(4,t),z=t=>e(7,t),n=(t,s)=>{if(!p)return s;let r=t.replace(/^#/,"");if(r.length!==6)return s;let i=parseInt(r.substring(0,2),16),u=parseInt(r.substring(2,4),16),f=parseInt(r.substring(4,6),16);return `\x1B[38;2;${i};${u};${f}m${s}\x1B[0m`},g=(t,s)=>{if(!p)return s;let r=t.replace(/^#/,"");if(r.length!==6)return s;let i=parseInt(r.substring(0,2),16),u=parseInt(r.substring(2,4),16),f=parseInt(r.substring(4,6),16);return `\x1B[48;2;${i};${u};${f}m${s}\x1B[0m`};var a={success:t=>t,error:t=>t,warn:t=>t,info:t=>t,prefix:{success:n("#10b981","\u2714")+" "+g("#064e3b",n("#34d399",o(" SUCCESS "))),error:n("#ef4444","\u2716")+" "+g("#7f1d1d",n("#f87171",o(" ERROR "))),warn:n("#f59e0b","\u26A0")+" "+g("#78350f",n("#fbbf24",o(" WARNING "))),info:n("#0ea5e9","\u2139")+" "+g("#0c4a6e",n("#38bdf8",o(" INFO ")))}};var B={success:console.log,error:console.error,warn:console.warn,info:console.info},c=class{theme;timestamps;colors;transport;constructor(s={}){this.theme={...a,...s.theme,prefix:{...a.prefix,...s.theme?.prefix}},this.timestamps=s.timestamps??false,this.colors=s.colors??true,this.transport={...B,...s.transport};}getTimestamp(){if(!this.timestamps)return "";let r=new Date().toISOString().split("T")[1]?.split(".")[0];return m(`[${r}] `)}highlightJson(s){return this.colors?s.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,r=>/^"/.test(r)?/:$/.test(r)?n("#9ca3af",r.slice(0,-1))+":":n("#34d399",r):/true|false/.test(r)?n("#c084fc",r):/null/.test(r)?n("#f87171",r):n("#fbbf24",r)):s}formatMessage(s){return s.map(r=>{if(typeof r=="string")return r;try{let i=JSON.stringify(r,null,2);return ` | ||
| `+this.highlightJson(i)}catch{return "[Unserializable Object]"}}).join(" ")}stripAnsi(s){return s.replace(/\x1b\[[0-9;]*m/g,"")}output(s,r){let i=this.colors?r:this.stripAnsi(r);this.transport[s](i);}success(...s){let r=this.formatMessage(s);this.output("success",`${this.getTimestamp()}${this.theme.prefix.success} ${this.theme.success(r)}`);}error(...s){let r=this.formatMessage(s);this.output("error",`${this.getTimestamp()}${this.theme.prefix.error} ${this.theme.error(r)}`);}warn(...s){let r=this.formatMessage(s);this.output("warn",`${this.getTimestamp()}${this.theme.prefix.warn} ${this.theme.warn(r)}`);}info(...s){let r=this.formatMessage(s);this.output("info",`${this.getTimestamp()}${this.theme.prefix.info} ${this.theme.info(r)}`);}},F=t=>new c(t);export{c as Logger,l as ansi,F as createLogger,a as defaultTheme}; | ||
| var M=Object.defineProperty;var A=(t,r)=>{for(var e in r)M(t,e,{get:r[e],enumerable:true});};var I={};A(I,{bgBlack:()=>F,bgBlue:()=>Y,bgColor256:()=>tt,bgCyan:()=>G,bgGreen:()=>U,bgHex:()=>Q,bgMagenta:()=>D,bgRed:()=>L,bgRgb:()=>R,bgWhite:()=>H,bgYellow:()=>W,black:()=>B,blue:()=>J,bold:()=>P,color256:()=>X,cyan:()=>v,dim:()=>h,format:()=>i,gray:()=>b,green:()=>w,hex:()=>s,inverse:()=>K,isColorSupported:()=>p,italic:()=>Z,magenta:()=>_,red:()=>d,reset:()=>V,rgb:()=>S,stripAnsi:()=>u,underline:()=>q,white:()=>z,yellow:()=>T});var x=process.env,p=!x.NO_COLOR&&(x.FORCE_COLOR||process.stdout&&process.stdout.isTTY||x.TERM==="xterm-256color"||x.CI==="true"),i=(t,r)=>p?`\x1B[${t}m${r}\x1B[0m`:r,V=t=>i(0,t),B=t=>i(30,t),d=t=>i(31,t),w=t=>i(32,t),T=t=>i(33,t),J=t=>i(34,t),_=t=>i(35,t),v=t=>i(36,t),z=t=>i(37,t),b=t=>i(90,t),F=t=>i(40,t),L=t=>i(41,t),U=t=>i(42,t),W=t=>i(43,t),Y=t=>i(44,t),D=t=>i(45,t),G=t=>i(46,t),H=t=>i(47,t),P=t=>i(1,t),h=t=>i(2,t),Z=t=>i(3,t),q=t=>i(4,t),K=t=>i(7,t),S=(t,r,e,o)=>p?`\x1B[38;2;${t};${r};${e}m${o}\x1B[0m`:o,R=(t,r,e,o)=>p?`\x1B[48;2;${t};${r};${e}m${o}\x1B[0m`:o,s=(t,r)=>{if(!p)return r;let e=t.replace(/^#/,"");return e.length!==6?r:S(parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16),r)},Q=(t,r)=>{if(!p)return r;let e=t.replace(/^#/,"");return e.length!==6?r:R(parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16),r)},X=(t,r)=>p?`\x1B[38;5;${t}m${r}\x1B[0m`:r,tt=(t,r)=>p?`\x1B[48;5;${t}m${r}\x1B[0m`:r,u=t=>t.replace(/\x1b\[[0-9;]*m/g,"");var N={success:t=>s("#10b981",t),error:t=>s("#f43f5e",t),warn:t=>s("#f59e0b",t),info:t=>s("#38bdf8",t),prefix:{success:s("#10b981","\u2714")+" "+s("#34d399",h("success")),error:s("#f43f5e","\u2716")+" "+s("#fb7185",h("error")),warn:s("#f59e0b","\u26A0")+" "+s("#fbbf24",h("warn")),info:s("#38bdf8","\u2139")+" "+s("#7dd3fc",h("info"))}},rt={success:t=>t,error:t=>t,warn:t=>t,info:t=>t,prefix:{success:s("#10b981","\u2714"),error:s("#f43f5e","\u2716"),warn:s("#f59e0b","\u26A0"),info:s("#38bdf8","\u2139")}},et={success:t=>w(t),error:t=>d(t),warn:t=>T(t),info:t=>v(t),prefix:{success:w("SUCCESS"),error:d("ERROR"),warn:T("WARN"),info:v("INFO")}},$=N;var y=(n=>(n[n.trace=10]="trace",n[n.debug=20]="debug",n[n.info=30]="info",n[n.success=35]="success",n[n.warn=40]="warn",n[n.error=50]="error",n[n.fatal=60]="fatal",n[n.none=100]="none",n))(y||{}),C=class{write(r){(r.levelValue>=50?console.error:console.log)(r.formatted);}},k=class{theme;timestamps;colors;level;mode;transports;timeCache={time:"",str:""};constructor(r={}){this.theme={...$,...r.theme,prefix:{...$.prefix,...r.theme?.prefix}},this.timestamps=r.timestamps??false,this.colors=r.colors??!!p,this.level=y[r.level??"trace"],this.mode=r.mode??"text",this.transports=r.transports??[new C];}shouldLog(r){return r>=this.level}getTimestamp(){if(!this.timestamps)return {iso:"",formatted:""};let e=new Date().toISOString(),o=e.split("T")[1]?.split(".")[0]||"";if(this.timeCache.time===o)return {iso:e,formatted:this.timeCache.str};let g=b(`[${o}] `);return this.timeCache={time:o,str:g},{iso:e,formatted:g}}safeStringify(r,e){let o=new Set;return JSON.stringify(r,(g,a)=>{if(typeof a=="object"&&a!==null){if(o.has(a))return "[Circular]";o.add(a);}return a},e)}highlightJson(r){return !this.colors||r.length>5e3?r:r.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,e=>/^"/.test(e)?/:$/.test(e)?s("#9ca3af",e.slice(0,-1))+":":s("#34d399",e):/true|false/.test(e)?s("#c084fc",e):/null/.test(e)?s("#f87171",e):s("#fbbf24",e))}formatMessage(r){return r.map(e=>{if(typeof e=="string")return e;if(e instanceof Error)return e.stack||e.message;try{return ` | ||
| `+this.highlightJson(this.safeStringify(e,2))}catch{return "[Unserializable]"}}).join(" ")}emit(r,e,o,g){let a=y[r];if(!this.shouldLog(a))return;let f=this.getTimestamp(),m,n;if(this.mode==="json"){let c={level:r,time:f.iso,message:g.length===1?g[0]:g};m=n=this.safeStringify(c);}else {let c=this.formatMessage(g);m=`${f.formatted}${e} ${o(c)}`,n=u(m),this.colors||(m=n);}this.dispatch(r,a,g,m,n,f.iso);}dispatch(r,e,o,g,a,f){let m={level:r,levelValue:e,message:o,formatted:g,raw:a,timestamp:f};for(let n=0;n<this.transports.length;n++)this.transports[n]?.write(m);}success(...r){this.emit("success",this.theme.prefix.success,this.theme.success,r);}error(...r){this.emit("error",this.theme.prefix.error,this.theme.error,r);}warn(...r){this.emit("warn",this.theme.prefix.warn,this.theme.warn,r);}info(...r){this.emit("info",this.theme.prefix.info,this.theme.info,r);}trace(...r){this.emit("trace",b("\u{1F50D}"),b,r);}debug(...r){this.emit("debug",s("#94a3b8","\u{1F41B}"),e=>s("#94a3b8",e),r);}fatal(...r){this.emit("fatal",s("#be123c","\u{1F480}"),e=>s("#be123c",e),r);}box(r,e){let o=30;if(!this.shouldLog(o))return;let g=e.split(` | ||
| `),a=Math.max(r.length,...g.map(l=>u(l).length))+4,f=`\u250C\u2500 ${r} ${"\u2500".repeat(a-r.length-3)}\u2510`,m=`\u2514${"\u2500".repeat(a)}\u2518`,n=g.map(l=>{let E=a-u(l).length-2;return `\u2502 ${l}${" ".repeat(Math.max(0,E))} \u2502`}),c=[f,...n,m].join(` | ||
| `),O=u(c);if(this.mode==="json"){let l=this.getTimestamp();c=O=this.safeStringify({level:"info",time:l.iso,title:r,message:e}),this.dispatch("info",o,[e],c,O,l.iso);return}this.colors&&(c=s("#38bdf8",c));let j=this.getTimestamp();this.dispatch("info",o,[e],c,O,j.iso);}},st=t=>new k(t);export{C as ConsoleTransport,y as LogLevel,k as Logger,I as ansi,et as classicTheme,st as createLogger,$ as defaultTheme,rt as minimalTheme,N as modernTheme}; |
+1
-1
| { | ||
| "name": "devink", | ||
| "version": "1.0.2", | ||
| "version": "1.0.3", | ||
| "description": "Fast, lightweight, professional logger built with TypeScript. No dependencies.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
+107
-96
@@ -1,34 +0,29 @@ | ||
| <h1 align="center"> | ||
| <br> | ||
| <br> | ||
| <img width="320" src="https://raw.githubusercontent.com/harrymate22/devink/main/media/logo.png" alt="devink"> | ||
| <br> | ||
| <br> | ||
| <br> | ||
| </h1> | ||
|  | ||
| > Fast, lightweight, professional terminal logger. Zero dependencies. | ||
| # devink | ||
| [](https://npmjs.com/package/devink) | ||
| [](https://github.com/user/devink/blob/main/LICENSE) | ||
| [](https://www.npmjs.com/package/devink) | ||
| [](https://bundlephobia.com/result?p=devink) | ||
| > A fast, lightweight, and professional **TypeScript logger** with zero dependencies. Keep your terminal cool, soothing, and strictly structured. | ||
|  | ||
| [](https://npmjs.org/package/devink) | ||
| [](https://opensource.org/licenses/MIT) | ||
| **Devink** is a production-grade, zero-dependency Node.js logging library featuring custom transports, graceful JSON serialization, a deep-merging theme system, and automatic ANSI color detection. | ||
| `devink` is a zero-dependency **Node.js logger** designed for developers who need high performance, beautiful **CLI output**, and structured **JSON logging**. With full **ANSI color support**, dynamic terminal capability detection, and customizable transports, it's the perfect production-ready logger for modern TS/JS environments. | ||
| Designed specifically built for high-performance CLI tools, servers, and modern development environments. 🚀 | ||
| --- | ||
| ## Highlights | ||
| ## 🚀 Features | ||
| - **Zero Dependencies**: Pure, self-contained raw ANSI escape engine (`NO_COLOR`, `FORCE_COLOR`, `TERM`, `isTTY` support). | ||
| - **Graceful Error Handling**: Bulletproof object stringification gracefully handles Circular JSON crashes. | ||
| - **Custom Transports**: Redirect logs to files, external services, or any custom stream easily. | ||
| - **Deep Theme System**: Merge your own styles tightly without overriding whole config structures. | ||
| - **Lightweight & Fast**: Extremely fast execution. | ||
| - **Modern Module Setup**: Full TypeScript compatibility, exporting ESM (`import`) and CommonJS (`require`). | ||
| - **Zero Dependencies**: Lightweight and ultra-fast. No bloated `node_modules`. | ||
| - **Full ANSI & 256/RGB Color Support**: Beautiful, soothing UI themes for the terminal. No harsh contrast. | ||
| - **Structured JSON Logging**: Instantly switch to JSON mode for seamless integration with Datadog, ELK, AWS CloudWatch, and parsing tools. | ||
| - **Log Levels & Priority Filtering**: Granular control via `trace`, `debug`, `info`, `warn`, `error`, and `fatal`. | ||
| - **Custom Transports**: Route logs to files, external APIs, or custom formatting engines. | ||
| - **Terminal Capability Detection**: Automatically detects `process.stdout.isTTY`, `FORCE_COLOR`, `NO_COLOR`, and `CI` environments. | ||
| - **Boxed Output**: Help crucial information stand out with Unicode-boxed messages. | ||
| - **TypeScript native**: Built with TS, exporting standard typings out-of-the-box. | ||
| ## Installation | ||
| --- | ||
| ## 📦 Installation | ||
| ```bash | ||
@@ -38,114 +33,130 @@ npm install devink | ||
| ## Quick Start | ||
| ```bash | ||
| yarn add devink | ||
| ``` | ||
| ```typescript | ||
| import { createLogger } from 'devink'; | ||
| ```bash | ||
| pnpm add devink | ||
| ``` | ||
| const logger = createLogger({ timestamps: true }); | ||
| --- | ||
| logger.success('Database connection established'); | ||
| logger.info('Listening on port 3000'); | ||
| logger.warn('Memory usage above 80%'); | ||
| logger.error('Request failed', { status: 500 }); | ||
| ``` | ||
| ## 💻 Usage | ||
| ## Advanced Usage | ||
| ### Basic CLI Logger | ||
| ### Custom Transports | ||
| Create a beautiful terminal logger with timestamps and the modern theme out of the box: | ||
| Devink allows you to intercept output and route it to your own methods. No more hardcoded `console.log`. | ||
| ```typescript | ||
| ```ts | ||
| import { createLogger } from 'devink'; | ||
| import fs from 'fs'; | ||
| const fileStream = fs.createWriteStream('./app.log', { flags: 'a' }); | ||
| const logger = createLogger({ | ||
| transport: { | ||
| // Override log execution logic | ||
| success: (...args) => fileStream.write(`[PASS] ${args.join(' ')}\n`), | ||
| error: (...args) => { | ||
| console.error(...args); // Keep console logging | ||
| fileStream.write(`[CRITICAL] ${args.join(' ')}\n`); | ||
| }, | ||
| }, | ||
| timestamps: true, | ||
| level: 'info', | ||
| }); | ||
| logger.success('User registered!'); // Goes straight to app.log | ||
| logger.info('Server started on port 3000'); | ||
| logger.success('Database connected successfully'); | ||
| logger.warn('Rate limit approaching'); | ||
| logger.error(new Error('Connection timeout')); | ||
| ``` | ||
| ### Color Control | ||
| ### Structured JSON Logging | ||
| For environments where strict text formatting is required, Devink lets you disable ANSI explicitly. | ||
| Perfect for production environments where log aggregation is crucial: | ||
| ```typescript | ||
| ```ts | ||
| import { createLogger } from 'devink'; | ||
| const logger = createLogger({ | ||
| colors: false, // Instantly strips all ANSI escape codes | ||
| mode: 'json', | ||
| level: 'trace', | ||
| }); | ||
| logger.info('This will definitely be plain text.'); | ||
| logger.info('Processing payment', { userId: 123, amount: 49.99 }); | ||
| // Output: {"level":"info","time":"2023-10-25T14:30:00.000Z","message":["Processing payment",{"userId":123,"amount":49.99}]} | ||
| ``` | ||
| ### Deep Theming | ||
| ### Beautiful Boxed Output | ||
| Deep-merge your theme overrides seamlessly. | ||
| Make important startup messages or critical alerts pop in the console: | ||
| ```typescript | ||
| import { createLogger, ansi } from 'devink'; | ||
| ```ts | ||
| const logger = createLogger(); | ||
| const customLogger = createLogger({ | ||
| theme: { | ||
| // Colors text differently | ||
| warn: (msg) => ansi.magenta(ansi.bold(msg)), | ||
| prefix: { | ||
| // Overrides ONLY the success icon, preserving defaults for others | ||
| success: ansi.green('🚀 SUCCESS'), | ||
| }, | ||
| }, | ||
| }); | ||
| customLogger.success('Payload deployed!'); | ||
| customLogger.warn('Custom colored warning.'); | ||
| logger.box( | ||
| 'System Ready', | ||
| 'All microservices have booted successfully.\nListening on http://localhost:8080', | ||
| ); | ||
| ``` | ||
| ### Safe Serialization | ||
| --- | ||
| No more logging crashes from deep object introspection or circular references. | ||
| ## ⚙️ Configuration | ||
| ```typescript | ||
| const logger = createLogger(); | ||
| The `createLogger` function accepts an optional `LoggerOptions` object: | ||
| const circularObj: any = {}; | ||
| circularObj.self = circularObj; | ||
| | Property | Type | Default | Description | | ||
| | ------------ | ------------------ | -------------------- | -------------------------------------------------------------------------------------- | | ||
| | `level` | `LogLevelName` | `'trace'` | Minimum log level to output (`trace` < `debug` < `info` < `warn` < `error` < `fatal`). | | ||
| | `mode` | `'text' \| 'json'` | `'text'` | Output mode. Text formats for the console, JSON formats for log aggregators. | | ||
| | `colors` | `boolean` | `true` | Whether to use ANSI colors. Automatically disabled if terminal doesn't support it. | | ||
| | `timestamps` | `boolean` | `false` | Prepend a timestamp to text outputs (`[HH:MM:SS]`). | | ||
| | `theme` | `Partial<Theme>` | `modernTheme` | Customize the prefix, success, error, warn, and info styling. | | ||
| | `transports` | `Transport[]` | `[ConsoleTransport]` | Target output locations hooks (e.g., standard out, file streams). | | ||
| // Doesn't throw! Gently recovers to '[Unserializable Object]' | ||
| logger.error('Error snapshot:', circularObj); | ||
| ### Theme Presets | ||
| `devink` ships with several UI/UX optimized presets, designed for accessibility and developer comfort: | ||
| - `modernTheme` (Default): Soft, cool hex colors (`#10b981`, `#f43f5e`, `#38bdf8`) with dim text to prevent eye strain. | ||
| - `classicTheme`: Standard ANSI colors (Red, Green, Yellow, Cyan). | ||
| - `minimalTheme`: Prefix icons only, without extra text like "success" or "error". | ||
| ```ts | ||
| import { createLogger, classicTheme } from 'devink'; | ||
| const logger = createLogger({ | ||
| theme: classicTheme, | ||
| }); | ||
| ``` | ||
| ## API Reference | ||
| ### Custom Transports | ||
| ### `createLogger(options?: LoggerOptions)` | ||
| You can easily route logs anywhere by providing objects that implement the `Transport` interface (which requires a `write(ctx: TransportContext)` method). | ||
| Creates a new `Logger` instance. | ||
| ```ts | ||
| import { createLogger, Transport, TransportContext } from 'devink'; | ||
| import fs from 'node:fs'; | ||
| #### `LoggerOptions` | ||
| class FileTransport implements Transport { | ||
| write(ctx: TransportContext) { | ||
| fs.appendFileSync('app.log', ctx.raw + '\n'); | ||
| } | ||
| } | ||
| | Option | Type | Default | Description | | ||
| | :----------- | :------------------- | :------------------ | :------------------------------------------------------- | | ||
| | `timestamps` | `boolean` | `false` | Prepends `[HH:MM:SS]` timestamp to every message. | | ||
| | `colors` | `boolean` | `true` | When `false`, all output will be stripped of ANSI codes. | | ||
| | `theme` | `Partial<Theme>` | `{}` | Deep partial override of color structures and prefixes. | | ||
| | `transport` | `Partial<Transport>` | `console.*` methods | Custom output handler for standard log layers. | | ||
| const logger = createLogger({ | ||
| transports: [new FileTransport()], // Now writes to app.log instead of console | ||
| }); | ||
| ``` | ||
| ## Runtime Compatibility | ||
| --- | ||
| - Node.js `^18.0.0` or newer | ||
| - Fully compatible with ESM & CommonJS | ||
| ## 🎨 ANSI Capabilities | ||
| Built with ❤️ by **[Harry Mate](https://github.com/harrymate22)**. | ||
| 🌟 If you find this library helpful, consider dropping a **Star** on GitHub and **[following me (@harrymate22)](https://github.com/harrymate22)** for more open-source tools! | ||
| If you want to build your own CLI tools, `devink` exports its high-performance, zero-dependency ANSI utilities: | ||
| ## License | ||
| ```ts | ||
| import { ansi } from 'devink'; | ||
| console.log(ansi.rgb(255, 100, 50, 'True RGB text!')); | ||
| console.log(ansi.hex('#34d399', 'Hex coded text!')); | ||
| console.log(ansi.color256(128, '256 color terminal support!')); | ||
| console.log(ansi.dim('Low contrast subtitle.')); | ||
| ``` | ||
| --- | ||
| ## 📄 License | ||
| MIT © [harrymate22](https://github.com/harrymate22) |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
31273
35.36%187
53.28%162
7.28%3
-57.14%