ThrottledPrinter class

A LogPrinter wrapper that rate-limits output to prevent high-frequency logging from choking the process or overwhelming the terminal.

Entries up to maxPerSecond are forwarded immediately. Once the limit is hit, excess entries are queued and drained at the throttled rate. When the queue exceeds maxQueueSize, the oldest entries are dropped and a summary message is printed when draining resumes.

HyperLogger.init(
  printer: ThrottledPrinter(
    LogPrinterPresets.terminal(),
    maxPerSecond: 30,
  ),
);
Implemented types

Constructors

ThrottledPrinter(LogPrinter inner, {int maxPerSecond = 30, int maxQueueSize = 500})

Properties

hashCode int
The hash code for this object.
no setterinherited
inner LogPrinter
The underlying printer that receives rate-limited entries.
final
maxPerSecond int
Maximum entries forwarded per second before throttling kicks in.
final
maxQueueSize int
Maximum queued entries. When exceeded, oldest entries are dropped.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Cancels the in-flight drain timer (no-op if none is scheduled) and disposes the wrapped inner printer. Required so that replacing the global printer via HyperLogger.init(...) doesn't leak the drain Timer on the orphan instance.
override
flush() → void
Immediately flushes all queued entries to the wrapped printer, ignoring the rate limit. Useful before shutdown or in crash scenarios where you want everything out.
log(LogEntry entry) → void
Emits entry to this printer's destination.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited