CaptureSink class base
A LogSink that captures all logged entries in memory for verification in unit tests.
Each Handler invocation appends a CapturedLog to logs.
Note that because Handler executes asynchronously, logs may not be
visible until the current microtask queue drains. In tests, await
a short Future.delayed or use await Future.value() after the
log call to ensure the sink has received the entry before asserting.
final sink = CaptureSink();
logger.info('hello');
await Future.value(); // drain microtask queue
expect(sink, hasLog(message: 'hello'));
- Inheritance
-
- Object
- LogSink<
LogDocument> - CaptureSink
Constructors
Properties
- enabled → bool
-
Whether this sink is currently active.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
logs
→ List<
CapturedLog> -
The list of captured log events.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clear(
) → void - Clears all captured logs.
-
dispose(
) → Future< void> -
Performs cleanup, such as closing file handles or network connections.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
output(
LogDocument document, LogEntry entry, LogLevel level, LogPipelineFactory factory) → Future< void> -
Outputs the
datato the destination.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited