dont forget last messages
commit444d5245fd4e9e413e869e705d7138a935ac68b9
authorAleksey Uimanov <s9gf4ult@gmail.com>
dateTue 16 Jul 2019, 16:38 (7 years ago)
parent22ee0e1
katip/src/Katip/Scribes/Handle/FileOwner.hs+9−1
@@ -90,7 +90,15 @@ newFileOwner fp s = do
9090 flush -- auto debounced flush
9191 recur
9292 Left c -> case c of
93− CloseMsg -> return () -- release will close the handler
93+ CloseMsg -> do
94+ lasMsgs <- atomically $ flushTBQueue dqueue
95+ -- flush never blocks
96+ case lastMsgs of
97+ [] -> return ()
98+ _ -> do
99+ h <- readIORef ref
100+ BL.hPutStr h $ mconcat lastMsgs
101+ return () -- release will flush and close the handler
94102 FlushMsg -> do
95103 readIORef ref >>= hFlush
96104 recur