log<TState> method

  1. @override
void log<TState>({
  1. required LogLevel logLevel,
  2. required EventId eventId,
  3. required TState state,
  4. Object? error,
  5. required LogFormatter<TState> formatter,
})
override

Writes a log entry.

Implementation

@override
void log<TState>({
  required LogLevel logLevel,
  required EventId eventId,
  required TState state,
  Object? error,
  required LogFormatter<TState> formatter,
}) {
  if (!isEnabled(logLevel)) {
    return;
  }

  var formattedMessage = formatter(state, error);
  if (formattedMessage.isEmpty) {
    return;
  }

  var message = '${logLevel.name}: $formattedMessage';

  // if (error != null) {
  //   message = '$message';
  // }

  developer.log(
    message,
    time: DateTime.now(),
    level: _getLogLevel(logLevel),
    name: _name,
    error: error,
  );
}