breadcrumbLevel property

LogLevel get breadcrumbLevel

Threshold for forwarding breadcrumbs to the error reporter, evaluated at breadcrumb-emit time and independent of the console logLevel. Mirrors logLevel exactly: dart-define breadcrumbLevel → Remote Config breadcrumbLeveldefaultRemoteConfig default info, with the same GetIt-not-ready try/catch fallback so early-boot reads never throw (ERH-008).

The valid domain is restricted to {debug, info, warn, error} — validated inline here, NOT via configBounds (which holds only numeric clamps and cannot express a string enum — ERH-027). An out-of-domain value (incl. debugVerbose, which has no backend equivalent — ERH-019) falls back to info with a one-time console warning.

Implementation

static LogLevel get breadcrumbLevel {
  const envValue = String.fromEnvironment('breadcrumbLevel');
  String value;
  if (envValue.isNotEmpty) {
    value = envValue;
  } else {
    try {
      final remoteValue = g<RemoteConfigRepoInt>().getString('breadcrumbLevel');
      if (remoteValue.isNotEmpty) {
        value = remoteValue;
      } else {
        value = defaultRemoteConfig['breadcrumbLevel'] as String;
      }
    } catch (_) {
      // GetIt not initialized (e.g., in tests), use default
      value = defaultRemoteConfig['breadcrumbLevel'] as String;
    }
  }

  // Inline domain validation (ERH-019, ERH-027): restrict to the backend-
  // mappable levels, fall back to `info` with a one-time console warning.
  if (!_breadcrumbLevelDomain.contains(value)) {
    if (!_breadcrumbLevelWarned) {
      _breadcrumbLevelWarned = true;
      // ignore: avoid_print
      print(
        'WARNING: invalid breadcrumbLevel "$value" — must be one of '
        '$_breadcrumbLevelDomain. Falling back to "info".',
      );
    }
    value = 'info';
  }

  return LogLevel.values.firstWhere((e) => e.name == value, orElse: () => LogLevel.info);
}