log method
Emits entry to this printer's destination.
Implementation contract:
- Synchronous. This call must not return a
Future— theHyperLoggeremit 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 (seeRotatingFilePrinter'sonError). - Must not throw. A printer that throws crashes the caller's
log site. Wrap your I/O in
try/catchand route failures tostderror a user-supplied error hook. - No back-pressure. Drop or queue overflow yourself —
ThrottledPrinteris 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());
}
}