HubLog Module
Canonical in-process log-emit surface for the Hub. Multi-subscriber
bidi gRPC stream (`StreamHubLog`) is layered on top in
`ScriptingHub`; local GUI diagnostics continue to flow through the
`HubEventBus` via the per-call-site bridging documented in
research.md §R8.
Zero-overhead when no subscriber is attached: `emit` gates on a
single `Volatile.Read` of the subscriber count before any
`LogEntry` allocation, timestamp read, or message formatting (R1).
Subscriber fan-out mirrors the `ScriptingHub` pattern: per-
subscriber `BoundedChannel
Types
| Type | Description |
|
Outcome of an `attach` call. `Rejected` when the subscriber cap (`HubSettings.MaxLogStreamSubscribers`) would be exceeded (FR-015a). |
|
|
Opaque correlation ID re-exported from `FSBar.Hub.CorrelationId`. Carried on every `LogEntry` whose emitter ran under a gRPC-interceptor-established scope. |
|
|
Closed enumeration of Hub subsystems that emit on the log stream. Adding a case is an additive surface-area change (new baseline line + proto enum extension at position 10+). |
|
|
One observation. Public shape — the fields map 1:1 onto `LogEntryMessage` on the wire, except `sequence` which is assigned per-subscriber by the wire mapper in `ScriptingHub`. |
|
|
Effective per-subscriber filter. Immutable; mutated by replacing the subscriber's reference atomically (R4). |
|
|
Severity levels, orderable so a subscriber can specify a floor (`entry.Severity >= minSeverity`). |
|
|
Subscription handle. Disposing detaches the subscriber and completes the channel writer within 1 s (FR-013). |
|
|
Opaque handle for the log bus. One per Hub process, created by `create` and disposed at shutdown. All subscribers share one bus. Implements `System.IDisposable`; dispose cancels every subscriber `CancellationTokenSource`, completes the per- subscriber channel writers, and guarantees resource release within 1 s (FR-013). |
Functions and values
| Function or value |
Description
|
Full Usage:
attach arg1 clientLabel filter cancellationToken
Parameters:
T
clientLabel : string
filter : LogFilter
cancellationToken : CancellationToken
Returns: AttachOutcome
|
Attach a new subscriber with the given filter and client label. Returns `Rejected` when the current subscriber count equals `HubSettings.MaxLogStreamSubscribers`.
|
|
|
Full Usage:
create events settings
Parameters:
IHubEventSink
settings : unit -> HubSettings
Returns: T
|
Construct a fresh log bus. The supplied `HubSettings.HubSettings` thunk is invoked each time `attach` checks the cap so operator edits to `MaxLogStreamSubscribers` take effect on the next attach without requiring a bus rebuild. The supplied `IHubEventSink` is retained only for the `DiagnosticsLine` bridge (R8 — emitting overflow warnings etc. back into the existing GUI diagnostics pane). Log entries themselves do NOT fan out through the event bus.
|
|
Default filter applied when a client sends an empty filter request: all categories, `Info` severity floor (FR-005a).
|
Full Usage:
emit arg1 category severity sessionId scriptingClientId buildMessage
Parameters:
T
category : LogCategory
severity : LogSeverity
sessionId : Guid option
scriptingClientId : Guid option
buildMessage : unit -> string
|
Emit one log entry. Non-blocking; O(1) work when no subscriber is attached (R1). The `buildMessage` thunk is invoked only after the filter-pass gate has confirmed at least one subscriber wants the entry, so string formatting cost is paid lazily. `sessionId` and `scriptingClientId` are passed explicitly by the emitter — `CorrelationId` is read implicitly from `CorrelationId.current ()` at emit time.
|
Full Usage:
emitFromDiagnosticsLine arg1 category severity sessionId scriptingClientId message
Parameters:
T
category : LogCategory
severity : Severity
sessionId : Guid option
scriptingClientId : Guid option
message : string
|
Bridge helper: `HubEvent.DiagnosticsLine` call sites invoke this in addition to the existing event-bus publish, passing the caller's owning category. Maps `HubEvents.Severity.Info/Warning/Error` onto `LogSeverity.Info/Warning/Error` and delegates to `emit`.
|
Full Usage:
emitSimple arg1 category severity buildMessage
Parameters:
T
category : LogCategory
severity : LogSeverity
buildMessage : unit -> string
|
Convenience wrapper with no session or client context. Equivalent to `emit bus category severity None None buildMessage`.
|
|
|
|
|
Full Usage:
resolveFilter categories minSeverity presetName
Parameters:
LogCategory list
minSeverity : LogSeverity option
presetName : string option
Returns: Result<LogFilter, string>
|
Resolve a wire-level filter request to a `LogFilter`. Returns `Error msg` when the preset is unknown or a category is `Unspecified` / a string name is unknown (FR-007).
|
|
|
Full Usage:
truncateUtf8 message
Parameters:
string
Returns: string
|
Byte-safe UTF-8 truncation at 8 KiB per FR-012a / R6. Public for tests; emit callers should not invoke directly (emit calls this internally post-filter-gate).
|
|
FSBarV1_Archived