lookupIsolateLogPort function

SendPort? lookupIsolateLogPort({
  1. String name = defaultIsolateLogPortName,
})

The main isolate's notification port registered by registerIsolateLogPort, or null if 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:

final logger = RootLogger(
  sinks: [LogSpoolSink(LogSpool(spoolDirectory), notify: lookupIsolateLogPort())],
  // The background isolate exits without waiting for an event-loop turn.
  dispatch: LogDispatchPolicy.synchronous,
)..finishStartup();

IsolateNameServer is shared by all isolates of the process, including isolates of other groups started by other FlutterEngines, but not by other processes (iOS extensions, a service in its own android:process): the port is not visible from there, and entries arrive through the spool at the next import.

Implementation

SendPort? lookupIsolateLogPort({String name = defaultIsolateLogPortName}) => IsolateNameServer.lookupPortByName(name);