AdvancedFileOutput constructor
- 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
- int? maxRotatedFilesCount,
- Comparator<
File> ? fileSorter, - Duration fileUpdateDuration = const Duration(minutes: 1),
Creates a buffered file output.
By default, the log is buffered until either the maxBufferSize
has been
reached, the timer controlled by maxDelay
has been triggered or an
OutputEvent contains a writeImmediately
log level.
maxFileSizeKB
controls the log file rotation. The output automatically
switches to a new log file as soon as the current file exceeds it.
Use -1 to disable log rotation.
maxDelay
describes the maximum amount of time before the buffer has to be
written to the file.
Any log levels that are specified in writeImmediately
trigger an immediate
flush to the disk (Level.warning, Level.error and Level.fatal by default).
path
is either treated as directory for rotating or as target file name,
depending on maxFileSizeKB
.
maxRotatedFilesCount
controls the number of rotated files to keep. By default
is null, which means no limit.
If set to a positive number, the output will keep the last
maxRotatedFilesCount
files. The deletion step will be executed by sorting
files following the fileSorter
ascending strategy and keeping the last files.
The latestFileName
will not be counted. The default fileSorter
strategy is
sorting by last modified date, beware that could be not reliable in some
platforms and/or filesystems.
Implementation
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 Function(DateTime timestamp)? fileNameFormatter,
int? maxRotatedFilesCount,
Comparator<File>? fileSorter,
Duration fileUpdateDuration = const Duration(minutes: 1),
}) {
throw UnsupportedError("Not supported on this platform.");
}