Skip to content

Commit a27ba42

Browse files
committed
AdvancedFileOutput: Fix race condition while flushing the buffer, fixes #99
1 parent 9006f29 commit a27ba42

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/src/outputs/advanced_file_output.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,11 @@ class AdvancedFileOutput extends LogOutput {
221221
_sink?.writeln(fileFooter);
222222
}
223223

224-
await _sink?.flush();
225-
await _sink?.close();
226-
_sink = null; // Explicitly set null until assigned again
224+
final sink = _sink;
225+
_sink = null; // disable writing in flushBuffer
226+
227+
await sink?.flush();
228+
await sink?.close();
227229
}
228230

229231
Future<void> _deleteRotatedFiles() async {

0 commit comments

Comments
 (0)