fatal method
Marks an error as fatal and records it to the console.
This method treats the error as a critical failure that should be prominently flagged in the console.
error
- The critical error to log.
stackTrace
- The stack trace associated with the critical error.
event
- An optional LogEvent providing additional context for the critical error.
Implementation
@override
Future<void> fatal(
{dynamic error, StackTrace? stackTrace, LogEvent? event}) async {
try {
if (shouldLog(event: event)) {
developer.log(
'>>═══════════════════════CONSOLELOG STRATEGY [FATAL]═══════════════════════>>',
name: 'ConsoleLogStrategy',
);
if (event != null) {
final ConsoleLogEvent consoleEvent = event as ConsoleLogEvent;
developer.log(
'eventName: ${consoleEvent.eventName} eventMessage: ${consoleEvent.eventMessage ?? "No message"} error: $error',
name: 'ConsoleLogStrategy',
error: error,
stackTrace: stackTrace,
);
} else {
developer.log('$error',
name: 'ConsoleLogStrategy', error: error, stackTrace: stackTrace);
}
developer.log(
'<<═══════════════════════CONSOLELOG STRATEGY [FATAL]═══════════════════════<<',
name: 'ConsoleLogStrategy',
);
}
} catch (e, stack) {
developer.log(
'Fatal Error during error handling in ConsoleLogStrategy: $e',
name: 'ConsoleLogStrategy',
error: e,
stackTrace: stack);
}
}