devink 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/index.d.mts +26 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.js +2 -1
- package/dist/index.mjs +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<h1 align="center">
|
|
2
2
|
<br>
|
|
3
3
|
<br>
|
|
4
|
-
<img width="320" src="media/
|
|
4
|
+
<img width="320" src="https://raw.githubusercontent.com/harrymate22/devink/main/media/logo.png" alt="devink">
|
|
5
5
|
<br>
|
|
6
6
|
<br>
|
|
7
7
|
<br>
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
[](https://www.npmjs.com/package/devink)
|
|
15
15
|
[](https://bundlephobia.com/result?p=devink)
|
|
16
16
|
|
|
17
|
+

|
|
18
|
+
|
|
17
19
|
**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.
|
|
18
20
|
|
|
19
21
|
Designed specifically built for high-performance CLI tools, servers, and modern development environments. 🚀
|
package/dist/index.d.mts
CHANGED
|
@@ -31,6 +31,7 @@ declare class Logger {
|
|
|
31
31
|
private transport;
|
|
32
32
|
constructor(options?: LoggerOptions);
|
|
33
33
|
private getTimestamp;
|
|
34
|
+
private highlightJson;
|
|
34
35
|
private formatMessage;
|
|
35
36
|
private stripAnsi;
|
|
36
37
|
private output;
|
|
@@ -44,6 +45,7 @@ declare const createLogger: (options?: LoggerOptions) => Logger;
|
|
|
44
45
|
declare const isColorSupported: string | boolean;
|
|
45
46
|
declare const format: (code: number, text: string) => string;
|
|
46
47
|
declare const reset: (text: string) => string;
|
|
48
|
+
declare const black: (text: string) => string;
|
|
47
49
|
declare const red: (text: string) => string;
|
|
48
50
|
declare const green: (text: string) => string;
|
|
49
51
|
declare const yellow: (text: string) => string;
|
|
@@ -52,11 +54,32 @@ declare const magenta: (text: string) => string;
|
|
|
52
54
|
declare const cyan: (text: string) => string;
|
|
53
55
|
declare const white: (text: string) => string;
|
|
54
56
|
declare const gray: (text: string) => string;
|
|
57
|
+
declare const bgBlack: (text: string) => string;
|
|
58
|
+
declare const bgRed: (text: string) => string;
|
|
59
|
+
declare const bgGreen: (text: string) => string;
|
|
60
|
+
declare const bgYellow: (text: string) => string;
|
|
61
|
+
declare const bgBlue: (text: string) => string;
|
|
62
|
+
declare const bgMagenta: (text: string) => string;
|
|
63
|
+
declare const bgCyan: (text: string) => string;
|
|
64
|
+
declare const bgWhite: (text: string) => string;
|
|
55
65
|
declare const bold: (text: string) => string;
|
|
56
66
|
declare const dim: (text: string) => string;
|
|
57
67
|
declare const italic: (text: string) => string;
|
|
58
68
|
declare const underline: (text: string) => string;
|
|
69
|
+
declare const inverse: (text: string) => string;
|
|
70
|
+
declare const hex: (hexCode: string, text: string) => string;
|
|
71
|
+
declare const bgHex: (hexCode: string, text: string) => string;
|
|
59
72
|
|
|
73
|
+
declare const ansi_bgBlack: typeof bgBlack;
|
|
74
|
+
declare const ansi_bgBlue: typeof bgBlue;
|
|
75
|
+
declare const ansi_bgCyan: typeof bgCyan;
|
|
76
|
+
declare const ansi_bgGreen: typeof bgGreen;
|
|
77
|
+
declare const ansi_bgHex: typeof bgHex;
|
|
78
|
+
declare const ansi_bgMagenta: typeof bgMagenta;
|
|
79
|
+
declare const ansi_bgRed: typeof bgRed;
|
|
80
|
+
declare const ansi_bgWhite: typeof bgWhite;
|
|
81
|
+
declare const ansi_bgYellow: typeof bgYellow;
|
|
82
|
+
declare const ansi_black: typeof black;
|
|
60
83
|
declare const ansi_blue: typeof blue;
|
|
61
84
|
declare const ansi_bold: typeof bold;
|
|
62
85
|
declare const ansi_cyan: typeof cyan;
|
|
@@ -64,6 +87,8 @@ declare const ansi_dim: typeof dim;
|
|
|
64
87
|
declare const ansi_format: typeof format;
|
|
65
88
|
declare const ansi_gray: typeof gray;
|
|
66
89
|
declare const ansi_green: typeof green;
|
|
90
|
+
declare const ansi_hex: typeof hex;
|
|
91
|
+
declare const ansi_inverse: typeof inverse;
|
|
67
92
|
declare const ansi_isColorSupported: typeof isColorSupported;
|
|
68
93
|
declare const ansi_italic: typeof italic;
|
|
69
94
|
declare const ansi_magenta: typeof magenta;
|
|
@@ -73,7 +98,7 @@ declare const ansi_underline: typeof underline;
|
|
|
73
98
|
declare const ansi_white: typeof white;
|
|
74
99
|
declare const ansi_yellow: typeof yellow;
|
|
75
100
|
declare namespace ansi {
|
|
76
|
-
export { 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_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 };
|
|
101
|
+
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 };
|
|
77
102
|
}
|
|
78
103
|
|
|
79
104
|
export { Logger, type LoggerOptions, type Theme, ansi, createLogger, defaultTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ declare class Logger {
|
|
|
31
31
|
private transport;
|
|
32
32
|
constructor(options?: LoggerOptions);
|
|
33
33
|
private getTimestamp;
|
|
34
|
+
private highlightJson;
|
|
34
35
|
private formatMessage;
|
|
35
36
|
private stripAnsi;
|
|
36
37
|
private output;
|
|
@@ -44,6 +45,7 @@ declare const createLogger: (options?: LoggerOptions) => Logger;
|
|
|
44
45
|
declare const isColorSupported: string | boolean;
|
|
45
46
|
declare const format: (code: number, text: string) => string;
|
|
46
47
|
declare const reset: (text: string) => string;
|
|
48
|
+
declare const black: (text: string) => string;
|
|
47
49
|
declare const red: (text: string) => string;
|
|
48
50
|
declare const green: (text: string) => string;
|
|
49
51
|
declare const yellow: (text: string) => string;
|
|
@@ -52,11 +54,32 @@ declare const magenta: (text: string) => string;
|
|
|
52
54
|
declare const cyan: (text: string) => string;
|
|
53
55
|
declare const white: (text: string) => string;
|
|
54
56
|
declare const gray: (text: string) => string;
|
|
57
|
+
declare const bgBlack: (text: string) => string;
|
|
58
|
+
declare const bgRed: (text: string) => string;
|
|
59
|
+
declare const bgGreen: (text: string) => string;
|
|
60
|
+
declare const bgYellow: (text: string) => string;
|
|
61
|
+
declare const bgBlue: (text: string) => string;
|
|
62
|
+
declare const bgMagenta: (text: string) => string;
|
|
63
|
+
declare const bgCyan: (text: string) => string;
|
|
64
|
+
declare const bgWhite: (text: string) => string;
|
|
55
65
|
declare const bold: (text: string) => string;
|
|
56
66
|
declare const dim: (text: string) => string;
|
|
57
67
|
declare const italic: (text: string) => string;
|
|
58
68
|
declare const underline: (text: string) => string;
|
|
69
|
+
declare const inverse: (text: string) => string;
|
|
70
|
+
declare const hex: (hexCode: string, text: string) => string;
|
|
71
|
+
declare const bgHex: (hexCode: string, text: string) => string;
|
|
59
72
|
|
|
73
|
+
declare const ansi_bgBlack: typeof bgBlack;
|
|
74
|
+
declare const ansi_bgBlue: typeof bgBlue;
|
|
75
|
+
declare const ansi_bgCyan: typeof bgCyan;
|
|
76
|
+
declare const ansi_bgGreen: typeof bgGreen;
|
|
77
|
+
declare const ansi_bgHex: typeof bgHex;
|
|
78
|
+
declare const ansi_bgMagenta: typeof bgMagenta;
|
|
79
|
+
declare const ansi_bgRed: typeof bgRed;
|
|
80
|
+
declare const ansi_bgWhite: typeof bgWhite;
|
|
81
|
+
declare const ansi_bgYellow: typeof bgYellow;
|
|
82
|
+
declare const ansi_black: typeof black;
|
|
60
83
|
declare const ansi_blue: typeof blue;
|
|
61
84
|
declare const ansi_bold: typeof bold;
|
|
62
85
|
declare const ansi_cyan: typeof cyan;
|
|
@@ -64,6 +87,8 @@ declare const ansi_dim: typeof dim;
|
|
|
64
87
|
declare const ansi_format: typeof format;
|
|
65
88
|
declare const ansi_gray: typeof gray;
|
|
66
89
|
declare const ansi_green: typeof green;
|
|
90
|
+
declare const ansi_hex: typeof hex;
|
|
91
|
+
declare const ansi_inverse: typeof inverse;
|
|
67
92
|
declare const ansi_isColorSupported: typeof isColorSupported;
|
|
68
93
|
declare const ansi_italic: typeof italic;
|
|
69
94
|
declare const ansi_magenta: typeof magenta;
|
|
@@ -73,7 +98,7 @@ declare const ansi_underline: typeof underline;
|
|
|
73
98
|
declare const ansi_white: typeof white;
|
|
74
99
|
declare const ansi_yellow: typeof yellow;
|
|
75
100
|
declare namespace ansi {
|
|
76
|
-
export { 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_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 };
|
|
101
|
+
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 };
|
|
77
102
|
}
|
|
78
103
|
|
|
79
104
|
export { Logger, type LoggerOptions, type Theme, ansi, createLogger, defaultTheme };
|
package/dist/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'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 `
|
|
2
|
+
`+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;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
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 `
|
|
2
|
+
`+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};
|