isolates library
Logging from background isolates into the main isolate's root logger,
including engine-started isolates (FCM, WorkManager): an on-disk spool
(LogSpool, LogSpoolSink, LogSpoolReceiver) as the source of truth,
plus a notification port registered by name (registerIsolateLogPort,
lookupIsolateLogPort) so the main isolate picks entries up now rather
than at next startup. Separate from log_trail_flutter.dart because
dart:isolate and dart:io are unavailable on web.
Classes
- IsolateLogReceiver
-
Receives entries through a port (IsolateLogSink): each entry is passed to
sink, usually the root logger's sink (
RootLogger.asSink). - IsolateLogSink
- Sink that passes entries to another isolate through port (IsolateLogReceiver.sendPort) without persisting them. There they go through the root logger alongside its own entries: same threshold, processors, sinks and store.
- LogSpool
- 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.
- LogSpoolReceiver
-
Receives entries from spool in the main isolate: imports into sink
(usually
RootLogger.asSink) on creation, on every notification to sendPort from LogSpoolSink, and on importNow. - LogSpoolSink
- Background-isolate sink that writes entries to spool.
Constants
- defaultIsolateLogPortName → const String
- Default name under which the main isolate's spool notification port is registered.
Functions
-
lookupIsolateLogPort(
{String name = defaultIsolateLogPortName}) → SendPort? -
The main isolate's notification port registered by registerIsolateLogPort,
or
nullif there is no main isolate (e.g. the system started only the background FCM handler) or it has not registered a port. The background isolate writes to the spool either way and passes the port as a notification when present: -
registerIsolateLogPort(
SendPort port, {String name = defaultIsolateLogPortName}) → void -
Registers
port(LogSpoolReceiver.sendPort) undernameso that engine-started isolates (FCM handler, WorkManager) can find it: they cannot be handed a port at spawn. The port is only a "file appeared in the spool" notification; the entries themselves are in the spool (LogSpool), so a missing or dead port loses nothing. -
unregisterIsolateLogPort(
{String name = defaultIsolateLogPortName}) → void -
Removes the
nameregistration, e.g. beforeLogSpoolReceiver.close: background isolates stop notifying a closed port. Entry delivery is not affected: entries stay in the spool until the next import.