@holz/ansi-terminal-backend 0.5.0 → 0.7.0-rc.1
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
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# `@holz/ansi-terminal-backend`
|
|
2
|
+
|
|
3
|
+
Pretty-print logs to the terminal.
|
|
4
|
+
|
|
5
|
+
<img alt="Screenshot of logs printed to the terminal" src="https://user-images.githubusercontent.com/10053423/222926680-0a12da0c-5ff2-40a1-8759-5dca72eb89c3.png" width="600" />
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { createAnsiTerminalBackend } from '@holz/ansi-terminal-backend';
|
|
11
|
+
|
|
12
|
+
const logger = createLogger(createAnsiTerminalBackend());
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
> **Note**
|
|
16
|
+
> There is no way to disable colors. The output relies on colors to convey structure. To disable colors, use a different backend such as [`@holz/stream-backend`](https://github.com/PsychoLlama/holz/tree/main/packages/holz-stream-backend).
|
|
17
|
+
|
|
18
|
+
## Options
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
createAnsiTerminalBackend({
|
|
22
|
+
/**
|
|
23
|
+
* By default it prints to the global console, but you can override it.
|
|
24
|
+
* See: https://nodejs.org/api/console.html#new-consoleoptions
|
|
25
|
+
*/
|
|
26
|
+
console: new Console(custom.stdout, custom.stderr),
|
|
27
|
+
});
|
|
28
|
+
```
|
|
@@ -0,0 +1,24 @@
|
|
|
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 function 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 { }
|
|
@@ -6,7 +6,7 @@ const e = o("0m"), u = o("2m"), g = o("31m"), p = o("32m"), S = o("33m"), f = o(
|
|
|
6
6
|
function v(t = {}) {
|
|
7
7
|
const r = t.console ?? console, i = " ".repeat(s.Error.length);
|
|
8
8
|
return (n) => {
|
|
9
|
-
const m = b(new Date()), a = `${e}${u}${m}${e}`, l = [
|
|
9
|
+
const m = b(/* @__PURE__ */ new Date()), a = `${e}${u}${m}${e}`, l = [
|
|
10
10
|
{
|
|
11
11
|
include: !0,
|
|
12
12
|
command: "%s",
|
package/package.json
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holz/ansi-terminal-backend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-rc.1",
|
|
4
4
|
"description": "An ANSI terminal backend for Holz",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/holz-ansi-terminal-backend.cjs",
|
|
7
|
-
"module": "./dist/holz-ansi-terminal-backend.js",
|
|
8
|
-
"types": "./src/index.ts",
|
|
9
6
|
"repository": {
|
|
10
7
|
"type": "git",
|
|
11
8
|
"url": "https://github.com/PsychoLlama/holz",
|
|
@@ -13,6 +10,7 @@
|
|
|
13
10
|
},
|
|
14
11
|
"exports": {
|
|
15
12
|
".": {
|
|
13
|
+
"types": "./dist/holz-ansi-terminal-backend.d.ts",
|
|
16
14
|
"require": "./dist/holz-ansi-terminal-backend.cjs",
|
|
17
15
|
"import": "./dist/holz-ansi-terminal-backend.js"
|
|
18
16
|
}
|
|
@@ -38,14 +36,17 @@
|
|
|
38
36
|
"test:types": "tsc"
|
|
39
37
|
},
|
|
40
38
|
"peerDependencies": {
|
|
41
|
-
"@holz/core": "^0.
|
|
39
|
+
"@holz/core": "^0.7.0-rc.1"
|
|
42
40
|
},
|
|
43
41
|
"devDependencies": {
|
|
44
|
-
"@holz/core": "^0.
|
|
45
|
-
"@types/node": "^
|
|
46
|
-
"@vitest/coverage-
|
|
47
|
-
"typescript": "^
|
|
48
|
-
"vite": "^
|
|
49
|
-
"
|
|
50
|
-
|
|
42
|
+
"@holz/core": "^0.7.0-rc.1",
|
|
43
|
+
"@types/node": "^22.0.0",
|
|
44
|
+
"@vitest/coverage-v8": "^3.0.8",
|
|
45
|
+
"typescript": "^5.0.0",
|
|
46
|
+
"vite": "^6.0.0",
|
|
47
|
+
"vite-plugin-dts": "^4.5.3",
|
|
48
|
+
"vite-tsconfig-paths": "^5.1.4",
|
|
49
|
+
"vitest": "^3.0.8"
|
|
50
|
+
},
|
|
51
|
+
"stableVersion": "0.6.0"
|
|
51
52
|
}
|
|
@@ -34,7 +34,7 @@ export function createAnsiTerminalBackend(options: Options = {}): LogProcessor {
|
|
|
34
34
|
command: '%s',
|
|
35
35
|
content: log.message.replace(
|
|
36
36
|
/(\r?\n)/g,
|
|
37
|
-
`$1${timestampPrefix} ${labelSizeInWhitespace}
|
|
37
|
+
`$1${timestampPrefix} ${labelSizeInWhitespace} `,
|
|
38
38
|
),
|
|
39
39
|
},
|
|
40
40
|
{
|