Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support set file update duration #86

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/src/outputs/advanced_file_output.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class AdvancedFileOutput extends LogOutput {
String Function(DateTime timestamp)? fileNameFormatter,
int? maxRotatedFilesCount,
Comparator<File>? fileSorter,
Duration fileUpdateDuration = const Duration(minutes: 1),
}) : _path = path,
_overrideExisting = overrideExisting,
_encoding = encoding,
Expand All @@ -86,6 +87,7 @@ class AdvancedFileOutput extends LogOutput {
],
_maxRotatedFilesCount = maxRotatedFilesCount,
_fileSorter = fileSorter ?? _defaultFileSorter,
_fileUpdateDuration = fileUpdateDuration,
_file = maxFileSizeKB > 0 ? File('$path/$latestFileName') : File(path);

/// Logs directory path by default, particular log file path if [_maxFileSizeKB] is 0.
Expand All @@ -101,6 +103,7 @@ class AdvancedFileOutput extends LogOutput {
final String Function(DateTime timestamp) _fileNameFormatter;
final int? _maxRotatedFilesCount;
final Comparator<File> _fileSorter;
final Duration _fileUpdateDuration;

final File _file;
IOSink? _sink;
Expand Down Expand Up @@ -140,7 +143,7 @@ class AdvancedFileOutput extends LogOutput {
}

_targetFileUpdater = Timer.periodic(
const Duration(minutes: 1),
_fileUpdateDuration,
(_) => _updateTargetFile(),
);
}
Expand Down
1 change: 1 addition & 0 deletions lib/src/outputs/advanced_file_output_stub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class AdvancedFileOutput extends LogOutput {
String Function(DateTime timestamp)? fileNameFormatter,
int? maxRotatedFilesCount,
Comparator<File>? fileSorter,
Duration fileUpdateDuration = const Duration(minutes: 1),
}) {
throw UnsupportedError("Not supported on this platform.");
}
Expand Down
Loading