log method

void log(
  1. LogEntry entry
)

Logs a structured entry with the specified level.

Implementation

void log(LogEntry entry) {
  if (!enabled || entry.level.value < minimumLevel.value) {
    return;
  }

  // Check sampling rules
  final sampler = samplers[entry.category];
  if (sampler != null) {
    if (!sampler.shouldLog(entry)) {
      return;
    }
    sampler.recordLog(entry);
  }

  // Format and output the log entry
  final formatted = _formatEntry(entry);
  print(formatted);

  // Handle error stack traces
  if (entry.error != null && entry.stackTrace != null) {
    print(entry.stackTrace.toString());
  }
}