log method

  1. @override
Future<void> log({
  1. dynamic message,
  2. LogEvent? event,
})
override

Logs a message or a structured event to the console.

message - The message or data to log if no specific event is provided. event - An optional LogEvent providing structured data for logging.

Implementation

@override
Future<void> log({dynamic message, LogEvent? event}) async {
  try {
    if (shouldLog(event: event)) {
      developer.log(
        '>>═══════════════════════CONSOLELOG STRATEGY [LOG]═══════════════════════>>',
        name: 'ConsoleLogStrategy',
      );
      if (event != null && event is ConsoleLogEvent) {
        developer.log(
          'eventName: ${event.eventName} eventMessage: ${event.eventMessage ?? "No message"} message: $message',
          name: 'ConsoleLogStrategy',
        );
      } else {
        developer.log('$message', name: 'ConsoleLogStrategy');
      }
      developer.log(
        '<<═══════════════════════CONSOLELOG STRATEGY [LOG]═══════════════════════<<',
        name: 'ConsoleLogStrategy',
      );
    }
  } catch (e, stack) {
    developer.log('Error during logging in ConsoleLogStrategy: $e',
        name: 'ConsoleLogStrategy', error: e, stackTrace: stack);
  }
}