@holz/stream-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
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("node:os"),t=require("node:util"),n=require("@holz/core");var r=({stream:n})=>r=>{let{error:s,...c}=r.context,l=new Date(r.timestamp).toISOString(),u=o[r.level],d=a(c),f=`${l} ${u} ${r.origin.length?`[${r.origin.join(`:`)}] `:``}`,p=`${f}${i(f.length,r.message)}${d?` `+d:``}`,m=s?(0,t.inspect)(s,{colors:!1})+e.EOL:``;n.write(`${p}${e.EOL}${m}`)},i=(e,t)=>t.replace(/(\r?\n)/g,t=>t+` `.repeat(e)),a=e=>Object.entries(e).map(([e,t])=>`${e}=${JSON.stringify(t)}`).join(` `),o={[n.level.trace]:`TRACE`,[n.level.debug]:`DEBUG`,[n.level.info]:`INFO `,[n.level.warn]:`WARN `,[n.level.error]:`ERROR`,[n.level.fatal]:`FATAL`};exports.createStreamBackend=r;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { EOL as
|
|
2
|
-
import { inspect as
|
|
1
|
+
import { EOL as e } from "node:os";
|
|
2
|
+
import { inspect as t } from "node:util";
|
|
3
3
|
import { level as n } from "@holz/core";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
S as createStreamBackend
|
|
4
|
+
//#region src/stream-backend.ts
|
|
5
|
+
var r = ({ stream: n }) => (r) => {
|
|
6
|
+
let { error: s, ...c } = r.context, l = new Date(r.timestamp).toISOString(), u = o[r.level], d = a(c), f = `${l} ${u} ${r.origin.length ? `[${r.origin.join(":")}] ` : ""}`, p = `${f}${i(f.length, r.message)}${d ? " " + d : ""}`, m = s ? t(s, { colors: !1 }) + e : "";
|
|
7
|
+
n.write(`${p}${e}${m}`);
|
|
8
|
+
}, i = (e, t) => t.replace(/(\r?\n)/g, (t) => t + " ".repeat(e)), a = (e) => Object.entries(e).map(([e, t]) => `${e}=${JSON.stringify(t)}`).join(" "), o = {
|
|
9
|
+
[n.trace]: "TRACE",
|
|
10
|
+
[n.debug]: "DEBUG",
|
|
11
|
+
[n.info]: "INFO ",
|
|
12
|
+
[n.warn]: "WARN ",
|
|
13
|
+
[n.error]: "ERROR",
|
|
14
|
+
[n.fatal]: "FATAL"
|
|
17
15
|
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { r as createStreamBackend };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createStreamBackend } from './stream-backend';
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export declare const createStreamBackend: ({ stream }: Config) => LogProcessor;
|
|
18
|
-
|
|
19
|
-
export { }
|
|
1
|
+
import { Writable } from 'node:stream';
|
|
2
|
+
import { LogProcessor } from '@holz/core';
|
|
3
|
+
/**
|
|
4
|
+
* Prints logs to a writable stream in plaintext. Optimized for log files.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* createStreamBackend({
|
|
8
|
+
* stream: fs.createWriteStream('my-app.log', { flags: 'a' }),
|
|
9
|
+
* })
|
|
10
|
+
*/
|
|
11
|
+
export declare const createStreamBackend: ({ stream }: Config) => LogProcessor;
|
|
12
|
+
interface Config {
|
|
13
|
+
/** Where to print logs. Normally `process.stderr`. */
|
|
14
|
+
stream: Writable;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holz/stream-backend",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3-rc.154+3f5148e",
|
|
4
4
|
"description": "Print logs to stdout or a file.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -32,21 +32,21 @@
|
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
34
|
"prepack": "vite build",
|
|
35
|
-
"test:unit": "vitest --color --passWithNoTests",
|
|
35
|
+
"test:unit": "vitest run --color --passWithNoTests",
|
|
36
36
|
"test:types": "tsc"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@holz/core": "^0.8.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@holz/core": "^0.8.
|
|
43
|
-
"@types/node": "^
|
|
44
|
-
"@vitest/coverage-v8": "^
|
|
45
|
-
"typescript": "^
|
|
46
|
-
"vite": "^
|
|
47
|
-
"vite-plugin-dts": "^
|
|
48
|
-
"vite-tsconfig-paths": "^
|
|
49
|
-
"vitest": "^
|
|
42
|
+
"@holz/core": "^0.8.3-rc.154+3f5148e",
|
|
43
|
+
"@types/node": "^24.0.0",
|
|
44
|
+
"@vitest/coverage-v8": "^4.0.0",
|
|
45
|
+
"typescript": "^6.0.0",
|
|
46
|
+
"vite": "^8.0.0",
|
|
47
|
+
"vite-plugin-dts": "^5.0.0",
|
|
48
|
+
"vite-tsconfig-paths": "^6.0.0",
|
|
49
|
+
"vitest": "^4.0.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "3f5148eb94bb1d7200d4b4993c95ea30db76b0c4"
|
|
52
52
|
}
|