Commit 7e79f91
authored
(#691): Flush the
Fixes #689.
Normally the `BufWriter` in `LogBackend` is `flush`ed in `drop`, but since all of this runs from a static or a background thread, no destructors are run (reliably at least; not sure about the background thread case). Thus, we need to explicitly `flush` the buffer. I believe this may be the remaining cause of #613.
This fix adds a `flush` method to `trait WriteEvent`, which is called after all `Event`s have been written so that we never lose any of the `Event`s. It's implemented by delegating to `Write::flush`, both for `BufWriter` in `LogBackend` and `stderr()` in `DebugBackend` (though that one is usually unbuffered).
I discovered this while implementing #687, as the missing `flush` is reliably detected when running the `Backend` on the main thread.Backend buffer1 file changed
+13
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
59 | 65 | | |
60 | 66 | | |
61 | 67 | | |
| |||
66 | 72 | | |
67 | 73 | | |
68 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
69 | 79 | | |
70 | 80 | | |
71 | 81 | | |
| |||
80 | 90 | | |
81 | 91 | | |
82 | 92 | | |
83 | | - | |
| 93 | + | |
84 | 94 | | |
85 | 95 | | |
| 96 | + | |
86 | 97 | | |
87 | 98 | | |
88 | 99 | | |
| |||
0 commit comments