LogCollectorOutput class
A LogOutput that sends log records to a remote logCollector collector
over WebSocket using rpc_dart contracts.
Each instance generates a unique session ID so multiple connections from the same app are distinguishable in the collector.
Design (0.2.1)
Reconnect is delegated to RpcClientConnection, the canonical
transport-agnostic auto-reconnect wrapper. It owns the backoff loop, rebuilds
the WebSocket transport via the channelFactory on every attempt and exposes
a stable proxy RpcClientConnection.transport; the RpcCallerEndpoint and
caller are built once on that proxy and survive reconnects. Lifecycle is
driven off RpcClientConnection.state: on the transition to
RpcClientOnline the client (re-)handshakes and flushes the buffer, and
while not online it buffers.
Sends are pipelined: the pump issues the next send without awaiting the
previous ack, so per-record round-trip latency no longer caps throughput,
and the logging hot path (write) never blocks. Records move
buffer -> in-flight on send and are dropped only when their ack arrives, so
nothing is lost across a reconnect (unacked in-flight records are requeued
at the buffer head, preserving order).
final controller = LogController(
outputs: [
ConsoleOutput(),
LogCollectorOutput(
uri: Uri.parse('ws://192.168.1.10:9500'),
device: DeviceInfo(name: 'MyApp', app: 'com.example'),
),
],
);
Constructors
-
LogCollectorOutput({required Uri uri, required DeviceInfo device, int bufferSize = 2000, int maxInFlight = 32, String? scopeFilter, Future<
WebSocketChannel> channelFactory(Uri uri)?}) -
Creates a LogCollectorOutput that sends records to
uri.
Properties
- bufferedCount → int
-
Number of records buffered but not yet handed to the wire.
Exposed for tests/diagnostics.
no setter
- bufferSize → int
-
Maximum number of records to buffer while disconnected or in flight.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- inFlightCount → int
-
Number of records sent but not yet acknowledged.
Exposed for tests/diagnostics.
no setter
- isAsync → bool
-
Whether this output uses async writing.
no setterinherited
- isConnected → bool
-
Whether the client currently has a live, handshaken connection.
Exposed for tests/diagnostics.
no setter
- maxInFlight → int
-
Maximum number of unacked records allowed on the wire at once.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scopeFilter → String?
-
Optional scope filter. If non-null, this output only receives records
whose scope starts with this prefix.
final
- sessionId → String
-
Short random session ID to distinguish multiple connections.
final
Methods
-
dispose(
) → void - Clean up resources.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
write(
LogRecord record) → void - Write a log record synchronously.
-
writeAsync(
LogRecord record) → Future< void> -
Write a log record asynchronously.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited