errorWithContext static method

void errorWithContext(
  1. String component,
  2. String operation,
  3. String error,
  4. StackTrace? stackTrace, {
  5. Map<String, dynamic>? context,
})

Enhanced error logging with context (para ANY component)

Implementation

static void errorWithContext(
    String component, String operation, String error, StackTrace? stackTrace,
    {Map<String, dynamic>? context}) {
  // Always log errors regardless of level
  final contextStr =
      context != null ? ' | Context: ${_formatData(context)}' : '';
  final message = '💥 $component - $operation ERROR: $error$contextStr';

  if (component.toLowerCase().contains('rule')) {
    _logWithPrefix(_rulePrefix, 'ERROR', message, error, stackTrace);
  } else if (component.toLowerCase().contains('http')) {
    _logWithPrefix(_httpPrefix, 'ERROR', message, error, stackTrace);
  } else if (component.toLowerCase().contains('ui')) {
    _logWithPrefix(_uiPrefix, 'ERROR', message, error, stackTrace);
  } else if (component.toLowerCase().contains('storage')) {
    _logWithPrefix(_storagePrefix, 'ERROR', message, error, stackTrace);
  } else {
    _log('ERROR', message, error, stackTrace);
  }
}