maybeStartStreamTrace function

StreamTrace? maybeStartStreamTrace(
  1. File file, {
  2. required String? envLookup(
    1. String key
    ),
})

Starts a StreamTrace into file when the env knob is on: FA_STREAM_TRACE=1 (exactly 1; any other value or an unset key keeps the trace off). Returns the started trace, or null when the knob is off. envLookup is a test seam; real hosts pass (key) => Platform.environment[key].

Implementation

StreamTrace? maybeStartStreamTrace(
  File file, {
  required String? Function(String key) envLookup,
}) {
  if (envLookup('FA_STREAM_TRACE') != '1') return null;
  return StreamTrace.start(FileStreamTraceSink(file));
}