HttpSink class

Sends batched JSON records to an HTTP endpoint that accepts POST <endpoint>/log with Content-Type: application/json and an Authorization: Bearer <token> header. See tools/log_server for the reference receiver.

Inheritance

Constructors

HttpSink({required Uri endpoint, required String token, LogLevel minLevel = LogLevel.info, int batchSize = 25, Duration flushInterval = const Duration(seconds: 2), int queueCapacity = 2000, Duration initialBackoff = const Duration(seconds: 1), Duration maxBackoff = const Duration(seconds: 30), Map<String, Object?>? device, Map<String, Object?>? app, HttpSender? sender, Future<void> delay(Duration) = Future<void>.delayed})
Creates a sink that POSTs batched records to endpoint with bearer token auth. device and app are merged into every record's JSON envelope. sender and delay, which waits out each retry backoff, are overridable for tests.

Properties

batchSize → int
Flush when the queue reaches this many records.
final
flushInterval → Duration
Flush at most this long after the first queued record.
final
hashCode → int
The hash code for this object.
no setterinherited
initialBackoff → Duration
First retry delay; doubles each attempt up to maxBackoff.
final
maxBackoff → Duration
Retry backoff cap. Starts at initialBackoff, doubles, clamped here.
final
minLevel → LogLevel
Records below this level are dropped before emit.
no setteroverride
queueCapacity → int
Hard cap. Beyond this, oldest records are dropped on each new emit.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

emit(LogRecord record) → void
Delivers record. Must not throw.
override
flush() → Future<void>
Awaits any pending delivery. Override for buffered sinks.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator +(LogSink other) → LogSink
Fan out to this then other. Each sink applies its own minLevel.
inherited
operator ==(Object other) → bool
The equality operator.
inherited