log method

  1. @override
void log(
  1. LogEntry entry
)
override

Emits entry to this printer's destination.

Implementation contract:

  • Synchronous. This call must not return a Future — the HyperLogger emit path is synchronous to keep the call site non-blocking. If you need async work (network, file rotation, compression), schedule it off-path inside the implementation and surface failures via your own callback (see RotatingFilePrinter's onError).
  • Must not throw. A printer that throws crashes the caller's log site. Wrap your I/O in try/catch and route failures to stderr or a user-supplied error hook.
  • No back-pressure. Drop or queue overflow yourself — ThrottledPrinter is one example of a wrapper that does exactly that.

Implementation

@override
void log(LogEntry entry) {
  final message = entry.object ?? entry.message;

  if (message is LogMessage) {
    _logStructured(entry, message);
  } else {
    _logAtLevel(entry.level, message.toString());
  }
}