logging-effect 1.1.3 → 1.2.0
raw patch · 3 files changed
+25/−6 lines, 3 files
Files
- Changelog.md +13/−1
- logging-effect.cabal +1/−1
- src/Control/Monad/Log.hs +11/−4
Changelog.md view
@@ -1,3 +1,15 @@+# 1.2.0++## Major Changes++- `withFDHandler` now explicitly flushes the file handle whenever log entries+ are rendered out. Thanks to @filterfish for identifying this omission that+ could lead to log messages being dropped.++ Upgrade steps: no changes other than updating `logging-effect`.++---+ # 1.1.3 ## Other Changes@@ -49,7 +61,7 @@ severity. The combinators are: `logDebug`, `logInfo`, `logNotice`, `logWarning`, `logError`, `logCritical`, `logAlert` and `logEmergency`. -- `mapLogMessage` got a companion function `mapLogMessageM` that works with +- `mapLogMessage` got a companion function `mapLogMessageM` that works with monadic tranformations. *Other*
logging-effect.cabal view
@@ -1,5 +1,5 @@ name: logging-effect-version: 1.1.3+version: 1.2.0 synopsis: A mtl-style monad transformer for general purpose & compositional logging homepage: https://github.com/ocharles/logging-effect license: BSD3
src/Control/Monad/Log.hs view
@@ -100,7 +100,7 @@ #else import GHC.Stack (SrcLoc, CallStack, getCallStack, prettySrcLoc) #endif-import System.IO (Handle)+import System.IO (Handle, hFlush) import qualified Data.Text.Lazy as LT import qualified Text.PrettyPrint.Leijen.Text as PP import qualified Data.List.NonEmpty as NEL@@ -527,9 +527,16 @@ -> Int -- ^ The amount of characters per line. Lines longer than this will be pretty-printed across multiple lines if possible. -> (Handler io PP.Doc -> io a) -> io a-withFDHandler options fd ribbonFrac width =- withBatchedHandler options- (PP.displayIO fd . PP.renderPretty ribbonFrac width . (<> PP.linebreak) . PP.vsep . NEL.toList)+withFDHandler options fd ribbonFrac width = withBatchedHandler options flush+ where+ flush messages = do+ PP.displayIO+ fd+ (PP.renderPretty+ ribbonFrac+ width+ (PP.vsep (NEL.toList messages) <> PP.linebreak))+ hFlush fd -------------------------------------------------------------------------------- -- | A 'MonadLog' handler optimised for pure usage. Log messages are accumulated