log method

  1. @override
void log(
  1. String message, {
  2. required LogLevel level,
  3. Object? error,
  4. StackTrace? stackTrace,
  5. Map<String, Object?>? context,
  6. bool printStackTrace = true,
  7. bool printError = true,
})
override

Logs a message with the specified level.

Implementation

@override
void log(
  String message, {
  required LogLevel level,
  Object? error,
  StackTrace? stackTrace,
  Map<String, Object?>? context,
  bool printStackTrace = true,
  bool printError = true,
}) {
  if (_destroyed) {
    _log('Logger has been destroyed. It cannot be used anymore.');
    return;
  }

  final LogWrapper logMessage = LogWrapper(
    message: LogMessage(
      message: message,
      level: level,
      timestamp: clock.now(),
      error: error,
      stackTrace: stackTrace,
      context: context,
    ),
    printStackTrace: printStackTrace,
    printError: printError,
  );

  _controller.add(logMessage);
}