dvLogAnalyticsDiagnostic function

void dvLogAnalyticsDiagnostic(
  1. String code,
  2. String message
)

Logs an analytics diagnostic at the level the registry gives its code.

Implementation

void dvLogAnalyticsDiagnostic(String code, String message) {
  final String level = DVDiagnostics.all
          .where((DVDiagnostic d) => d.code == code)
          .firstOrNull
          ?.level ??
      'warning';
  _analyticsLogger.log(
    '$code: $message',
    level: switch (level) {
      'debug' => DVLogLevel.debug,
      'info' => DVLogLevel.info,
      'error' => DVLogLevel.error,
      _ => DVLogLevel.warn,
    },
    context: <String, Object?>{'code': code},
  );
}