@holz/ansi-terminal-backend 0.8.2 → 0.8.3-rc.154

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@holz/core"),o=n=>`\x1B[${n}`,t=o("0m"),p=o("1m"),$=o("2m"),d=o("31m"),S=o("32m"),v=o("33m"),b=o("34m"),f=o("97m"),A=(n={})=>{const r=n.console??console,i=" ".repeat(5);return e=>{const a=h(new Date(e.timestamp)),l=`${t}${$}${a}${t}`,m=[{include:!0,command:"%s",content:l},{include:!0,command:"%s",content:T[e.level]},{include:!0,command:"%s",content:e.message.replace(/(\r?\n)/g,`$1${l} ${i} `)},{include:Object.keys(e.context).length>0,command:"%O",content:e.context},{include:e.origin.length>0,command:"%s",content:`${$}${e.origin.join(":")}${t}`}].filter(s=>s.include),u=m.map(s=>s.command).join(" "),g=m.map(s=>s.content);r.error(u,...g)}},h=n=>{const r=n.getHours().toString().padStart(2,"0"),i=n.getMinutes().toString().padStart(2,"0"),e=n.getSeconds().toString().padStart(2,"0"),a=n.getMilliseconds().toString().padStart(3,"0");return`[${r}:${i}:${e}.${a}]`},T={[c.level.trace]:`${f}TRACE${t}`,[c.level.debug]:`${b}DEBUG${t}`,[c.level.info]:`${S}INFO${t} `,[c.level.warn]:`${v}WARN${t} `,[c.level.error]:`${d}ERROR${t}`,[c.level.fatal]:`${p}${d}FATAL${t}`};exports.createAnsiTerminalBackend=A;
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 c } from "@holz/core";
2
- const o = (e) => `\x1B[${e}`, n = o("0m"), g = o("1m"), l = o("2m"), d = o("31m"), S = o("32m"), b = o("33m"), f = o("34m"), h = o("97m"), v = (e = {}) => {
3
- const r = e.console ?? console, m = " ".repeat(5);
4
- return (t) => {
5
- const i = A(new Date(t.timestamp)), a = `${n}${l}${i}${n}`, $ = [
6
- {
7
- include: !0,
8
- command: "%s",
9
- content: a
10
- },
11
- {
12
- include: !0,
13
- command: "%s",
14
- content: x[t.level]
15
- },
16
- {
17
- include: !0,
18
- command: "%s",
19
- content: t.message.replace(
20
- /(\r?\n)/g,
21
- `$1${a} ${m} `
22
- )
23
- },
24
- {
25
- include: Object.keys(t.context).length > 0,
26
- command: "%O",
27
- content: t.context
28
- },
29
- {
30
- include: t.origin.length > 0,
31
- command: "%s",
32
- content: `${l}${t.origin.join(":")}${n}`
33
- }
34
- ].filter((s) => s.include), u = $.map((s) => s.command).join(" "), p = $.map((s) => s.content);
35
- r.error(u, ...p);
36
- };
37
- }, A = (e) => {
38
- const r = e.getHours().toString().padStart(2, "0"), m = e.getMinutes().toString().padStart(2, "0"), t = e.getSeconds().toString().padStart(2, "0"), i = e.getMilliseconds().toString().padStart(3, "0");
39
- return `[${r}:${m}:${t}.${i}]`;
40
- }, x = {
41
- [c.trace]: `${h}TRACE${n}`,
42
- [c.debug]: `${f}DEBUG${n}`,
43
- [c.info]: `${S}INFO${n} `,
44
- [c.warn]: `${b}WARN${n} `,
45
- [c.error]: `${d}ERROR${n}`,
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
- * A backend that prints logs to a 3-bit ansi terminal. This should work on
5
- * most Unix systems and Windows >= 10.
6
- *
7
- * NOTE: This is not smart enough to detect if the output is a TTY or if it
8
- * supports colors, nor is this the appropriate place to check. Without color
9
- * ques, the printed text is much less understandable. It is better to check
10
- * when constructing the logger instead.
11
- */
12
- export declare const createAnsiTerminalBackend: (options?: Options) => LogProcessor;
13
-
14
- declare interface Options {
15
- /**
16
- * Defaults the global `console`, but in NodeJS you can create a console
17
- * over any writable stream. It could be a file or a network socket.
18
- *
19
- * @see https://nodejs.org/api/console.html#new-consoleoptions
20
- */
21
- console?: Console;
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.2",
3
+ "version": "0.8.3-rc.154+3f5148e",
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.2",
42
- "@types/node": "^22.0.0",
43
- "@vitest/coverage-v8": "^3.0.8",
44
- "typescript": "^5.8.2",
45
- "vite": "^6.0.0",
46
- "vite-plugin-dts": "^4.5.3",
47
- "vite-tsconfig-paths": "^5.1.4",
48
- "vitest": "^3.0.8"
41
+ "@holz/core": "^0.8.3-rc.154+3f5148e",
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": "f099a09cd01834de9bc1714908183cbb7b828c85"
50
+ "gitHead": "3f5148eb94bb1d7200d4b4993c95ea30db76b0c4"
51
51
  }