BufferedTransport class

A Transport decorator that buffers LogEvents and flushes them in batches to an inner Transport.

Flushing is triggered by either:

Call flush manually to drain the buffer on demand, and dispose when the transport is no longer needed to cancel the timer and flush remaining events.

Example:

final transport = BufferedTransport(
  HttpTransport('https://logs.example.com'),
  maxSize: 50,
  flushInterval: Duration(seconds: 30),
);

// Or via extension:
HttpTransport('https://logs.example.com')
  .withBuffer(maxSize: 50, flushInterval: Duration(seconds: 30));
Inheritance
Available extensions

Constructors

BufferedTransport(Transport inner, {int maxSize = 100, Duration? flushInterval, LogLevel level = LogLevel.trace, Map<String, dynamic> config = const {}})

Properties

config Map<String, dynamic>
Arbitrary key/value options passed to the transport at construction time.
finalinherited
flushInterval Duration?
How often to automatically flush the buffer. When null, only maxSize triggers automatic flushes.
final
hashCode int
The hash code for this object.
no setterinherited
inner Transport
The inner transport that receives events on flush.
final
level LogLevel
Minimum severity level this transport will handle.
finalinherited
maxSize int
Maximum number of events to buffer before an automatic flush.
final
pendingCount int
Number of events currently in the buffer.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() Future<void>
Cancels the periodic timer and flushes any remaining buffered events.
emitLog(LogEvent event) Future<void>
Performs the actual delivery of event to the transport's destination.
override
flush() Future<void>
Sends all buffered events to inner and clears the buffer.
log(LogEvent event) Future<void>
Delivers event to the destination if event.level >= this.level.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
withBuffer({int maxSize = 100, Duration? flushInterval}) BufferedTransport

Available on Transport, provided by the BufferedTransportExtension extension

Wraps this transport in a BufferedTransport.

Operators

operator ==(Object other) bool
The equality operator.
inherited