log method

void log(
  1. BDLevel level,
  2. String message, {
  3. Object? error,
  4. StackTrace? stackTrace,
  5. bool? isFatal,
})

Use this method to create log entries for user-defined levels. To record a message at a predefined level (e.g. BDLevel.info, BDLevel.warning) you can use their specialized methods instead (e.g. info, warning, etc).

The log record will also contain a field for the zone in which this call was made. This can be advantageous if a log listener wants to handler records of different zones differently (e.g. group log records by HTTP request if each HTTP request handler runs in it's own zone).

Implementation

void log(
  final BDLevel level,
  final String message, {
  final Object? error,
  final StackTrace? stackTrace,
  final bool? isFatal,
}) {
  final BDLogRecord newLogRecord = BDLogRecord(
    level,
    message,
    error: error,
    stackTrace: stackTrace,
    isFatal: isFatal ?? false,
  );

  recordQueue.add(newLogRecord);

  final Completer<void>? task = processingTask;

  if (task == null || task.isCompleted) {
    unawaited(_registerLogProcessingTimer());
  }
}