logging-effect 1.2.6 → 1.3.0
raw patch · 3 files changed
+36/−22 lines, 3 filesdep +prettyprinterdep ~wl-pprint-textPVP ok
version bump matches the API change (PVP)
Dependencies added: prettyprinter
Dependency ranges changed: wl-pprint-text
API changes (from Hackage documentation)
- Control.Monad.Log: instance Text.PrettyPrint.Leijen.Text.Pretty Control.Monad.Log.Severity
- Control.Monad.Log: renderPretty :: Float -> Int -> Doc -> SimpleDoc
+ Control.Monad.Log: instance Data.Text.Prettyprint.Doc.Internal.Pretty Control.Monad.Log.Severity
+ Control.Monad.Log: layoutPretty :: () => LayoutOptions -> Doc ann -> SimpleDocStream ann
- Control.Monad.Log: renderWithCallStack :: (a -> Doc) -> WithCallStack a -> Doc
+ Control.Monad.Log: renderWithCallStack :: (a -> Doc ann) -> WithCallStack a -> Doc ann
- Control.Monad.Log: renderWithSeverity :: (a -> Doc) -> (WithSeverity a -> Doc)
+ Control.Monad.Log: renderWithSeverity :: (a -> Doc ann) -> (WithSeverity a -> Doc ann)
- Control.Monad.Log: renderWithTimestamp :: (UTCTime -> String) -> (a -> Doc) -> (WithTimestamp a -> Doc)
+ Control.Monad.Log: renderWithTimestamp :: (UTCTime -> String) -> (a -> Doc ann) -> (WithTimestamp a -> Doc ann)
- Control.Monad.Log: withFDHandler :: (MonadIO io, MonadMask io) => BatchingOptions -> Handle -> Float -> Int -> (Handler io Doc -> io a) -> io a
+ Control.Monad.Log: withFDHandler :: (MonadIO io, MonadMask io) => BatchingOptions -> Handle -> Double -> Int -> (Handler io (Doc ann) -> io a) -> io a
Files
- Changelog.md +14/−0
- logging-effect.cabal +2/−2
- src/Control/Monad/Log.hs +20/−20
Changelog.md view
@@ -1,3 +1,17 @@+# 1.3.0++## Major Changes++* Switch from `wl-pprint-text` to `prettyprinter`.++## Other changes++* Change the type of the `ribbonFrac` parameter of `withFDHandler`+ from `Float` to `Double` to reflect the underlying `prettyprinter`+ API.++---+ # 1.2.6 ## Other Changes
logging-effect.cabal view
@@ -1,5 +1,5 @@ name: logging-effect-version: 1.2.6+version: 1.3.0 synopsis: A mtl-style monad transformer for general purpose & compositional logging homepage: https://github.com/ocharles/logging-effect license: BSD3@@ -23,7 +23,7 @@ , free >= 4.12.1 && < 5.1 , stm >= 2.4.4.1 && < 2.5 , stm-delay >= 0.1.1.1 && < 0.2- , wl-pprint-text >= 1.1.0.4 && < 1.2+ , prettyprinter >= 1.2 && < 1.3 , monad-control >= 1.0.0.4 && < 1.1 , transformers-base >= 0.4.4 && < 0.5 , semigroups >= 0.16.2.2 && < 0.19
src/Control/Monad/Log.hs view
@@ -43,7 +43,7 @@ logDebug, logInfo, logNotice, logWarning, logError, logCritical, logAlert, logEmergency, -- * Message transformers- PP.renderPretty,+ PP.layoutPretty, -- ** Timestamps WithTimestamp(..), timestamp, renderWithTimestamp, -- ** Severity@@ -102,7 +102,8 @@ import System.IO (Handle, hFlush) import GHC.IO.Handle.FD (stdin, stdout, stderr) import qualified Data.Text.Lazy as LT-import qualified Text.PrettyPrint.Leijen.Text as PP+import qualified Data.Text.Prettyprint.Doc as PP+import qualified Data.Text.Prettyprint.Doc.Render.Text as PP import qualified Data.List.NonEmpty as NEL -- For 'MonadLog' pass-through instances.@@ -213,7 +214,7 @@ deriving (Eq,Enum,Bounded,Read,Show,Ord) instance PP.Pretty Severity where- pretty = PP.text . LT.pack . show+ pretty = PP.pretty . LT.pack . show -- | Given a way to render the underlying message @a@, render a message with its -- severity.@@ -221,7 +222,7 @@ -- >>> renderWithSeverity id (WithSeverity Informational "Flux capacitor is functional") -- [Informational] Flux capacitor is functional renderWithSeverity- :: (a -> PP.Doc) -> (WithSeverity a -> PP.Doc)+ :: (a -> PP.Doc ann) -> (WithSeverity a -> PP.Doc ann) renderWithSeverity k (WithSeverity u a) = PP.brackets (PP.pretty u) PP.<+> PP.align (k a) @@ -305,11 +306,11 @@ -- [Tue, 19 Jan 2016 11:29:42 UTC] Setting target speed to plaid renderWithTimestamp :: (UTCTime -> String) -- ^ How to format the timestamp.- -> (a -> PP.Doc)+ -> (a -> PP.Doc ann) -- ^ How to render the rest of the message.- -> (WithTimestamp a -> PP.Doc)+ -> (WithTimestamp a -> PP.Doc ann) renderWithTimestamp formatter k (WithTimestamp a t) =- PP.brackets (PP.text (LT.pack (formatter t))) PP.<+> PP.align (k a)+ PP.brackets (PP.pretty (LT.pack (formatter t))) PP.<+> PP.align (k a) -- | Add the current time as a timestamp to a message. timestamp :: (MonadIO m) => a -> m (WithTimestamp a)@@ -331,22 +332,22 @@ -- callstack. -- -- The callstack will be pretty-printed underneath the log message itself.-renderWithCallStack :: (a -> PP.Doc) -> WithCallStack a -> PP.Doc+renderWithCallStack :: (a -> PP.Doc ann) -> WithCallStack a -> PP.Doc ann renderWithCallStack k (WithCallStack stack msg) =- k msg PP.<$> PP.indent 2 (prettyCallStack (getCallStack stack))+ k msg <> PP.line <> PP.indent 2 (prettyCallStack (getCallStack stack)) #if MIN_VERSION_base(4, 9, 0) showSrcLoc :: SrcLoc -> String showSrcLoc = prettySrcLoc #endif -prettyCallStack :: [(String,SrcLoc)] -> PP.Doc+prettyCallStack :: [(String,SrcLoc)] -> PP.Doc ann prettyCallStack [] = "empty callstack" prettyCallStack (root:rest) =- prettyCallSite root PP.<$> PP.indent 2 (PP.vsep (map prettyCallSite rest))+ prettyCallSite root <> PP.line <> PP.indent 2 (PP.vsep (map prettyCallSite rest)) where prettyCallSite (f,loc) =- PP.text (LT.pack f) <> ", called at " <>- PP.text (LT.pack (showSrcLoc loc))+ PP.pretty (LT.pack f) <> ", called at " <>+ PP.pretty (LT.pack (showSrcLoc loc)) -- | Construct a 'WithCallStack' log message. --@@ -529,19 +530,18 @@ :: (MonadIO io,MonadMask io) => BatchingOptions -> Handle -- ^ The 'Handle' to write log messages to.- -> Float -- ^ The @ribbonFrac@ parameter to 'PP.renderPretty'+ -> Double -- ^ The @ribbonFrac@ parameter to 'PP.renderPretty' -> 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)+ -> (Handler io (PP.Doc ann) -> io a) -> io a withFDHandler options fd ribbonFrac width = withBatchedHandler options flush where flush messages = do- PP.displayIO+ PP.renderIO fd- (PP.renderPretty- ribbonFrac- width- (PP.vsep (NEL.toList messages) <> PP.linebreak))+ (PP.layoutPretty+ (PP.LayoutOptions (PP.AvailablePerLine width ribbonFrac))+ (PP.vsep (NEL.toList messages) <> PP.line')) hFlush fd --------------------------------------------------------------------------------