FileCharge constructor

FileCharge(
  1. String path, {
  2. int bufferSize = 1000,
  3. Duration writeDelay = const Duration(seconds: 5),
})

A BoltCharge that logs output to a file.

The FileCharge will write logs to a file in the specified path. Logs are written to the file in batches, this is done when it reaches the bufferSize or every writeDelay.

Implementation

FileCharge(this.path, {this.bufferSize = 1000, this.writeDelay = const Duration(seconds: 5)}) {
  final fileName = '${DateFormat('yyyy-MM-dd').format(DateTime.now())}.log';
  _file = File('$path/$fileName');

  Timer.periodic(writeDelay, (_) => _flush());
}