FileSink constructor

FileSink({
  1. required Directory directory,
  2. int maxFileSize = 2 * 1024 * 1024,
  3. int maxFileCount = 5,
  4. FileLogFormat format = FileLogFormat.text,
  5. String baseFileName = 'LogPilot',
  6. @visibleForTesting Duration flushInterval = const Duration(milliseconds: 500),
})

Creates a file sink that writes to directory.

maxFileSize is the threshold in bytes that triggers rotation (default 2 MB). maxFileCount is the total number of files kept including the active one (default 5). format controls whether records are written as plain text or NDJSON.

Implementation

FileSink({
  required this.directory,
  this.maxFileSize = 2 * 1024 * 1024,
  this.maxFileCount = 5,
  this.format = FileLogFormat.text,
  this.baseFileName = 'LogPilot',
  @visibleForTesting Duration flushInterval = const Duration(milliseconds: 500),
})  : assert(maxFileSize > 0, 'maxFileSize must be positive'),
      assert(maxFileCount >= 2, 'maxFileCount must be at least 2'),
      assert(baseFileName.isNotEmpty, 'baseFileName must not be empty'),
      _flushInterval = flushInterval;