PrintLogCollector class
A generic LogCollector that can be used with any logging solution.
This collector exposes an addLog method that can be called from your logging listener to forward logs to the Marionette system.
Example with the logging package
final collector = PrintLogCollector();
MarionetteBinding.ensureInitialized(
MarionetteConfiguration(logCollector: collector),
);
Logger.root.level = Level.ALL;
Logger.root.onRecord.listen((record) {
collector.addLog('${record.level.name}: ${record.loggerName}: ${record.message}');
});
Example with Zone to capture print statements
final collector = PrintLogCollector();
MarionetteBinding.ensureInitialized(
MarionetteConfiguration(logCollector: collector),
);
runZoned(
() => runApp(MyApp()),
zoneSpecification: ZoneSpecification(
print: (self, parent, zone, line) {
parent.print(zone, line);
collector.addLog(line);
},
),
);
- Implemented types
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addLog(
String message) → void - Adds a log entry.
-
dispose(
) → void -
Stops collecting logs and releases any resources.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
start(
void onLog(String message)) → void -
Starts collecting logs.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited