append method

  1. @override
void append(
  1. LogRecord logRecord
)
override

Appending the given logRecord.

Implementation

@override
void append(LogRecord logRecord) async {
  switch (rotationCycle) {
    case RotationCycle.NEVER:
      // Do nothing
      break;
    case RotationCycle.DAY:
    case RotationCycle.WEEK:
    case RotationCycle.MONTH:
    case RotationCycle.YEAR:
      await checkForFileChange();
      break;
  }
  logRecord.loggerName ??= getType();
  _file.writeAsStringSync(
      LogRecordFormatter.format(logRecord, format!, dateFormat: dateFormat) +
          '\n',
      mode: FileMode.append);
  if (logRecord.stackTrace != null) {
    _file.writeAsStringSync(logRecord.stackTrace.toString() + '\n',
        mode: FileMode.append);
  }
}