@m1kad0/hannah-logging 0.0.0 → 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 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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m1kad0/hannah-logging",
3
- "version": "0.0.0",
3
+ "version": "0.2.0",
4
4
  "description": "Ships the logs of a Hannah component to the Hannah log collector",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {