@holz/stream-backend 0.5.0 → 0.6.0

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.
Files changed (2) hide show
  1. package/README.md +46 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # `@holz/stream-backend`
2
+
3
+ A Holz plugin that streams logs in plaintext. It is optimized for log files.
4
+
5
+ ## Usage
6
+
7
+ To use `@holz/stream-backend`, you first need to import it and create a backend with `createStreamBackend()`:
8
+
9
+ ```typescript
10
+ import { createStreamBackend } from '@holz/stream-backend';
11
+ import { createLogger } from '@holz/core';
12
+ import * as fs from 'fs';
13
+
14
+ createLogger(
15
+ createStreamBackend({
16
+ stream: fs.createWriteStream('server.log', { flags: 'a' }),
17
+ })
18
+ );
19
+ ```
20
+
21
+ The `stream` option specifies the NodeJS writable stream that the logs should be written to. You can use any writable stream, such as a file or `process.stderr`.
22
+
23
+ > **Note**
24
+ > If your system supports JSON, consider [`@holz/json-backend`](https://github.com/PsychoLlama/holz/tree/main/packages/holz-json-backend) as a structured alternative.
25
+
26
+ ## Example Output
27
+
28
+ When you write logs using `@holz/stream-backend`, they are formatted as plaintext and written to the stream. Each log entry is separated by a line break.
29
+
30
+ ```
31
+ 2023-03-04T21:58:11.620Z INFO [app:devices] Requesting media devices
32
+ 2023-03-04T21:58:14.288Z INFO [app:devices] Received media stream kind=["audio"]
33
+ 2023-03-04T21:58:14.288Z WARN [app:devices] User does not have a camera
34
+ 2023-03-04T21:58:14.288Z INFO [app:rtc] Creating WebRTC session signalingMode="polite"
35
+ 2023-03-04T21:58:14.288Z INFO [app:signaling] Opening signaling channel
36
+ 2023-03-04T21:58:14.346Z DEBUG [app:signaling] Signaling channel is open
37
+ 2023-03-04T21:58:14.347Z INFO [app:rtc] Sending session description type="offer"
38
+ 2023-03-04T21:58:14.491Z INFO [app:rtc] Receiving session description type="answer"
39
+ 2023-03-04T21:58:14.494Z DEBUG [app:rtc] Sending ICE candidate type="UDP" ip="10.0.0.10" port="33150"
40
+ 2023-03-04T21:58:14.494Z INFO [app:rtc] Attaching local media tracks kind=["audio"]
41
+ 2023-03-04T21:58:14.619Z DEBUG [app:rtc] Receiving ICE candidate type="UDP" ip="10.0.0.11" port="36877"
42
+ 2023-03-04T21:58:14.630Z INFO [app:rtc] Testing remote candidates...
43
+ 2023-03-04T21:58:14.684Z INFO [app:rtc] Connection successful.
44
+ ```
45
+
46
+ Note that the logs include a timestamp, log level, namespace, message, and any additional context that was provided.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holz/stream-backend",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Print logs to stdout or a file.",
5
5
  "type": "module",
6
6
  "main": "./dist/holz-stream-backend.cjs",
@@ -39,10 +39,10 @@
39
39
  "test:types": "tsc"
40
40
  },
41
41
  "peerDependencies": {
42
- "@holz/core": "^0.5.0"
42
+ "@holz/core": "^0.6.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@holz/core": "^0.5.0",
45
+ "@holz/core": "^0.6.0",
46
46
  "@types/node": "^18.14.0",
47
47
  "@vitest/coverage-c8": "^0.28.5",
48
48
  "typescript": "^4.9.5",