AdvancedFileOutput class

Accumulates logs in a buffer to reduce frequent disk, writes while optionally switching to a new log file if it reaches a certain size.

AdvancedFileOutput offer various improvements over the original FileOutput:

  • Managing an internal buffer which collects the logs and only writes them after a certain period of time to the disk.
  • Dynamically switching log files instead of using a single one specified by the user, when the current file reaches a specified size limit (optionally).

The buffered output can significantly reduce the frequency of file writes, which can be beneficial for (micro-)SD storage and other types of low-cost storage (e.g. on IoT devices). Specific log levels can trigger an immediate flush, without waiting for the next timer tick.

New log files are created when the current file reaches the specified size limit. This is useful for writing "archives" of telemetry data and logs while keeping them structured.

Inheritance

Constructors

AdvancedFileOutput({required String path, bool overrideExisting = false, Encoding encoding = utf8, List<Level>? writeImmediately, Duration maxDelay = const Duration(seconds: 2), int maxBufferSize = 2000, int maxFileSizeKB = 1024, String latestFileName = 'latest.log', String fileNameFormatter(DateTime timestamp)?})
Creates a buffered file output.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

destroy() Future<void>
inherited
init() Future<void>
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
output(OutputEvent event) → void
override
toString() String
A string representation of this object.
inherited

Operators

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