@m1kad0/hannah-logging 0.1.1 → 0.2.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.
- package/README.md +12 -0
- package/dist/shipper.d.ts +7 -0
- package/dist/shipper.js +10 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,6 +64,18 @@ It is a bound function, so it can be handed to a pino hook or a winston transpor
|
|
|
64
64
|
Both report the library's own connection problems to the unwrapped logger or the original
|
|
65
65
|
console. Those messages are never shipped.
|
|
66
66
|
|
|
67
|
+
### Setting the collector address directly
|
|
68
|
+
|
|
69
|
+
A component that knows the collector address itself passes it in instead of subscribing
|
|
70
|
+
to discovery:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
shipper.setCollectorAddress('192.168.1.10:50061'); // '' withdraws it
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
It starts shipping if `connect` hasn't been called yet, takes precedence over the static
|
|
77
|
+
`collectorAddress`, and a new address moves the stream.
|
|
78
|
+
|
|
67
79
|
### Categories
|
|
68
80
|
|
|
69
81
|
Each line is tagged `GENERAL`, `TRANSCRIPT` (speech transcripts, user utterances) or
|
package/dist/shipper.d.ts
CHANGED
|
@@ -78,6 +78,13 @@ export declare class LogShipper {
|
|
|
78
78
|
setInternalLog(log: InternalLog): void;
|
|
79
79
|
/** Starts shipping. Only the first call has an effect. */
|
|
80
80
|
connect(opts: ConnectOptions): void;
|
|
81
|
+
/**
|
|
82
|
+
* Sets the collector address directly, for a component that knows it without
|
|
83
|
+
* discovery (Hannah Core itself). Treated like an address announced by Core: it takes
|
|
84
|
+
* precedence over the static fallback, and a change moves the stream. An empty
|
|
85
|
+
* address withdraws it. Starts shipping if `connect` hasn't been called yet.
|
|
86
|
+
*/
|
|
87
|
+
setCollectorAddress(address: string): void;
|
|
81
88
|
/** Stops discovery and gives the shipper up to `timeoutMs` to send what is still buffered. */
|
|
82
89
|
close(timeoutMs?: number): Promise<void>;
|
|
83
90
|
private categoryFor;
|
package/dist/shipper.js
CHANGED
|
@@ -156,6 +156,16 @@ class LogShipper {
|
|
|
156
156
|
void this.runDiscovery(opts.hannahAddress);
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Sets the collector address directly, for a component that knows it without
|
|
161
|
+
* discovery (Hannah Core itself). Treated like an address announced by Core: it takes
|
|
162
|
+
* precedence over the static fallback, and a change moves the stream. An empty
|
|
163
|
+
* address withdraws it. Starts shipping if `connect` hasn't been called yet.
|
|
164
|
+
*/
|
|
165
|
+
setCollectorAddress(address) {
|
|
166
|
+
this.connect({});
|
|
167
|
+
this.setDiscovered(address);
|
|
168
|
+
}
|
|
159
169
|
/** Stops discovery and gives the shipper up to `timeoutMs` to send what is still buffered. */
|
|
160
170
|
async close(timeoutMs = 2000) {
|
|
161
171
|
if (this.stopping) {
|