LogSpool class final
Spool of background-isolate entries: a directory where isolates started by the engine (FCM handler, WorkManager) or by the app write entry files (LogSpoolSink), and the main isolate picks them up (importInto, LogSpoolReceiver) and runs them through its root logger alongside its own entries.
The spool is the source of truth: an entry counts as delivered once its file is in the directory, not once the main isolate received it. So the background isolate does not care whether a main isolate exists, whether its port is alive, or whether it is in the same process: it writes the file and exits. The main isolate picks files up at startup, on a port notification (LogSpoolReceiver), and whenever it chooses (LogSpoolReceiver.importNow, e.g. on resume from background). Thus only one isolate writes the main store, and neither its counters nor its eviction diverge from a second writer.
Each batch is a separate *.jsonl file (one entry per line in
logEntryJson format), written to a temporary file with fsync and
renamed atomically: a file in the directory is either absent or complete.
So writers and import need no locks, never read half-written lines, and
never lose entries added during an import. The file name starts with the
write time, process id and isolate id, so files from different writers do
not collide and import follows write order.
Both ends configure the same directory, e.g.
Directory(p.join(supportDir.path, 'log_spool')); the main isolate creates
it on import, the writer on its first write.
Properties
Methods
-
files(
) → Future< List< File> > - Complete entry files in write order (by name).
-
importInto(
LogSink sink) → Future< int> -
Imports all complete files into
sink: each entry goes to LogSink.add, and the file is deleted after LogSink.flush. Returns the number of entries passed. -
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 ==(
Object other) → bool -
The equality operator.
inherited
Constants
- fileExtension → const String
- Extension of a complete entry file.
- pendingExtension → const String
- Extension of a file the writer is still filling; import ignores it.