initLogger function

void initLogger(
  1. String logDir, {
  2. int maxFileCount = 10,
  3. int maxFileLength = 1024 * 1024 * 10,
  4. String? fileLeading,
})

Init logger to write log to file.

logDir the directory to store log files. fileLeading the leading of log file content, it will be written to the first line of each log file.

Implementation

void initLogger(
  String logDir, {
  int maxFileCount = 10,
  int maxFileLength = 1024 * 1024 * 10, // 10 MB
  String? fileLeading,
}) {
  assert(maxFileCount > 1, 'maxFileCount must be greater than 1');
  assert(maxFileLength > 10 * 1024, 'maxFileLength must be greater than 10 KB');
  if (fileLeading != null) {
    assert(fileLeading.length < maxFileLength, 'fileLeading is too long');
  }
  _writeToFile.init(logDir, maxFileCount, maxFileLength, fileLeading);
}