@holz/ansi-terminal-backend 0.8.2 → 0.8.3-rc.152
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/dist/holz-ansi-terminal-backend.cjs +1 -1
- package/dist/holz-ansi-terminal-backend.js +47 -49
- package/dist/src/__tests__/ansi-terminal-backend.test.d.ts +1 -0
- package/dist/src/ansi-codes.d.ts +16 -0
- package/dist/{holz-ansi-terminal-backend.d.ts → src/ansi-terminal-backend.d.ts} +21 -24
- package/dist/src/index.d.ts +1 -0
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@holz/core");var t=e=>`\x1b[${e}`,n=t(`0m`),r=t(`1m`),i=t(`2m`);t(`30m`);var a=t(`31m`),o=t(`32m`),s=t(`33m`),c=t(`34m`);t(`35m`),t(`36m`),t(`37m`);var l=t(`97m`),u=(e={})=>{let t=e.console??console,r=` `.repeat(5);return e=>{let a=`${n}${i}${d(new Date(e.timestamp))}${n}`,o=[{include:!0,command:`%s`,content:a},{include:!0,command:`%s`,content:f[e.level]},{include:!0,command:`%s`,content:e.message.replace(/(\r?\n)/g,`$1${a} ${r} `)},{include:Object.keys(e.context).length>0,command:`%O`,content:e.context},{include:e.origin.length>0,command:`%s`,content:`${i}${e.origin.join(`:`)}${n}`}].filter(e=>e.include),s=o.map(e=>e.command).join(` `),c=o.map(e=>e.content);t.error(s,...c)}},d=e=>`[${e.getHours().toString().padStart(2,`0`)}:${e.getMinutes().toString().padStart(2,`0`)}:${e.getSeconds().toString().padStart(2,`0`)}.${e.getMilliseconds().toString().padStart(3,`0`)}]`,f={[e.level.trace]:`${l}TRACE${n}`,[e.level.debug]:`${c}DEBUG${n}`,[e.level.info]:`${o}INFO${n} `,[e.level.warn]:`${s}WARN${n} `,[e.level.error]:`${a}ERROR${n}`,[e.level.fatal]:`${r}${a}FATAL${n}`};exports.createAnsiTerminalBackend=u;
|
|
@@ -1,50 +1,48 @@
|
|
|
1
|
-
import { level as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
[c.fatal]: `${g}${d}FATAL${n}`
|
|
47
|
-
};
|
|
48
|
-
export {
|
|
49
|
-
v as createAnsiTerminalBackend
|
|
1
|
+
import { level as e } from "@holz/core";
|
|
2
|
+
//#region src/ansi-codes.ts
|
|
3
|
+
var t = (e) => `\x1b[${e}`, n = t("0m"), r = t("1m"), i = t("2m");
|
|
4
|
+
t("30m");
|
|
5
|
+
var a = t("31m"), o = t("32m"), s = t("33m"), c = t("34m");
|
|
6
|
+
t("35m"), t("36m"), t("37m");
|
|
7
|
+
var l = t("97m"), u = (e = {}) => {
|
|
8
|
+
let t = e.console ?? console, r = " ".repeat(5);
|
|
9
|
+
return (e) => {
|
|
10
|
+
let a = `${n}${i}${d(new Date(e.timestamp))}${n}`, o = [
|
|
11
|
+
{
|
|
12
|
+
include: !0,
|
|
13
|
+
command: "%s",
|
|
14
|
+
content: a
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
include: !0,
|
|
18
|
+
command: "%s",
|
|
19
|
+
content: f[e.level]
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
include: !0,
|
|
23
|
+
command: "%s",
|
|
24
|
+
content: e.message.replace(/(\r?\n)/g, `$1${a} ${r} `)
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
include: Object.keys(e.context).length > 0,
|
|
28
|
+
command: "%O",
|
|
29
|
+
content: e.context
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
include: e.origin.length > 0,
|
|
33
|
+
command: "%s",
|
|
34
|
+
content: `${i}${e.origin.join(":")}${n}`
|
|
35
|
+
}
|
|
36
|
+
].filter((e) => e.include), s = o.map((e) => e.command).join(" "), c = o.map((e) => e.content);
|
|
37
|
+
t.error(s, ...c);
|
|
38
|
+
};
|
|
39
|
+
}, d = (e) => `[${e.getHours().toString().padStart(2, "0")}:${e.getMinutes().toString().padStart(2, "0")}:${e.getSeconds().toString().padStart(2, "0")}.${e.getMilliseconds().toString().padStart(3, "0")}]`, f = {
|
|
40
|
+
[e.trace]: `${l}TRACE${n}`,
|
|
41
|
+
[e.debug]: `${c}DEBUG${n}`,
|
|
42
|
+
[e.info]: `${o}INFO${n} `,
|
|
43
|
+
[e.warn]: `${s}WARN${n} `,
|
|
44
|
+
[e.error]: `${a}ERROR${n}`,
|
|
45
|
+
[e.fatal]: `${r}${a}FATAL${n}`
|
|
50
46
|
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { u as createAnsiTerminalBackend };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assumes 3-bit color support for an ANSI terminal. This should work on most
|
|
3
|
+
* modern terminals, including on Windows.
|
|
4
|
+
*/
|
|
5
|
+
export declare const reset: string;
|
|
6
|
+
export declare const bold: string;
|
|
7
|
+
export declare const dim: string;
|
|
8
|
+
export declare const black: string;
|
|
9
|
+
export declare const red: string;
|
|
10
|
+
export declare const green: string;
|
|
11
|
+
export declare const yellow: string;
|
|
12
|
+
export declare const blue: string;
|
|
13
|
+
export declare const magenta: string;
|
|
14
|
+
export declare const cyan: string;
|
|
15
|
+
export declare const white: string;
|
|
16
|
+
export declare const brightWhite: string;
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
import { LogProcessor } from '@holz/core';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { }
|
|
1
|
+
import { LogProcessor } from '@holz/core';
|
|
2
|
+
/**
|
|
3
|
+
* A backend that prints logs to a 3-bit ansi terminal. This should work on
|
|
4
|
+
* most Unix systems and Windows >= 10.
|
|
5
|
+
*
|
|
6
|
+
* NOTE: This is not smart enough to detect if the output is a TTY or if it
|
|
7
|
+
* supports colors, nor is this the appropriate place to check. Without color
|
|
8
|
+
* ques, the printed text is much less understandable. It is better to check
|
|
9
|
+
* when constructing the logger instead.
|
|
10
|
+
*/
|
|
11
|
+
export declare const createAnsiTerminalBackend: (options?: Options) => LogProcessor;
|
|
12
|
+
interface Options {
|
|
13
|
+
/**
|
|
14
|
+
* Defaults the global `console`, but in NodeJS you can create a console
|
|
15
|
+
* over any writable stream. It could be a file or a network socket.
|
|
16
|
+
*
|
|
17
|
+
* @see https://nodejs.org/api/console.html#new-consoleoptions
|
|
18
|
+
*/
|
|
19
|
+
console?: Console;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createAnsiTerminalBackend } from './ansi-terminal-backend';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holz/ansi-terminal-backend",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3-rc.152+a4ea736",
|
|
4
4
|
"description": "An ANSI terminal backend for Holz",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -31,21 +31,21 @@
|
|
|
31
31
|
],
|
|
32
32
|
"scripts": {
|
|
33
33
|
"prepack": "vite build",
|
|
34
|
-
"test:unit": "vitest --color --passWithNoTests",
|
|
34
|
+
"test:unit": "vitest run --color --passWithNoTests",
|
|
35
35
|
"test:types": "tsc"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@holz/core": "^0.8.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@holz/core": "^0.8.
|
|
42
|
-
"@types/node": "^
|
|
43
|
-
"@vitest/coverage-v8": "^
|
|
44
|
-
"typescript": "^
|
|
45
|
-
"vite": "^
|
|
46
|
-
"vite-plugin-dts": "^
|
|
47
|
-
"vite-tsconfig-paths": "^
|
|
48
|
-
"vitest": "^
|
|
41
|
+
"@holz/core": "^0.8.3-rc.152+a4ea736",
|
|
42
|
+
"@types/node": "^24.0.0",
|
|
43
|
+
"@vitest/coverage-v8": "^4.0.0",
|
|
44
|
+
"typescript": "^6.0.0",
|
|
45
|
+
"vite": "^8.0.0",
|
|
46
|
+
"vite-plugin-dts": "^5.0.0",
|
|
47
|
+
"vite-tsconfig-paths": "^6.0.0",
|
|
48
|
+
"vitest": "^4.0.0"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "a4ea7361cad7340841a12ca7c7366ffbd25eaa35"
|
|
51
51
|
}
|