polysemy-log 0.4.2.0 → 0.4.3.0
raw patch · 5 files changed
+39/−12 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Polysemy.Log.Handle: interpretDataLogHandleWith :: Member (Embed IO) r => Handle -> (a -> Text) -> InterpreterFor (DataLog a) r
Files
- changelog.md +1/−0
- lib/Polysemy/Log/Handle.hs +25/−0
- lib/Polysemy/Log/Stderr.hs +5/−5
- lib/Polysemy/Log/Stdout.hs +6/−6
- polysemy-log.cabal +2/−1
changelog.md view
@@ -1,6 +1,7 @@ # Unreleased * Add interceptors for setting the log level.+* Set std streams to line buffering. # 0.3.0.0
+ lib/Polysemy/Log/Handle.hs view
@@ -0,0 +1,25 @@+{-# language CPP #-}++-- |Description: Handle Interpreters, Internal+module Polysemy.Log.Handle where++import qualified Data.Text.IO as Text++import Polysemy.Log.Data.DataLog (DataLog)+import Polysemy.Log.Log (interpretDataLog)++#if !MIN_VERSION_relude(1,0,0)+import System.IO (hSetBuffering, BufferMode (LineBuffering))+#endif++-- |Interpret 'DataLog' by printing to the given handle, converting messages to 'Text' with the supplied function.+-- Sets the handle into 'LineBuffering' mode.+interpretDataLogHandleWith ::+ Member (Embed IO) r =>+ Handle ->+ (a -> Text) ->+ InterpreterFor (DataLog a) r+interpretDataLogHandleWith handle fmt sem = do+ embed @IO (hSetBuffering handle LineBuffering)+ interpretDataLog (embed . Text.hPutStrLn handle . fmt) sem+{-# inline interpretDataLogHandleWith #-}
lib/Polysemy/Log/Stderr.hs view
@@ -1,7 +1,6 @@--- |Description: Internal+-- |Description: Stderr Interpreters, Internal module Polysemy.Log.Stderr where -import qualified Data.Text.IO as Text import Polysemy.Async (Async) import Polysemy.Conc (Race) import Polysemy.Resource (Resource)@@ -13,16 +12,17 @@ import Polysemy.Log.Data.LogMessage (LogMessage) import Polysemy.Log.Data.Severity (Severity) import Polysemy.Log.Format (formatLogEntry)+import Polysemy.Log.Handle (interpretDataLogHandleWith) import Polysemy.Log.Level (setLogLevel)-import Polysemy.Log.Log (interpretDataLog, interpretLogDataLog, interpretLogDataLogConc)+import Polysemy.Log.Log (interpretLogDataLog, interpretLogDataLogConc) -- |Interpret 'DataLog' by printing to stderr, converting messages to 'Text' with the supplied function. interpretDataLogStderrWith :: Member (Embed IO) r => (a -> Text) -> InterpreterFor (DataLog a) r-interpretDataLogStderrWith fmt =- interpretDataLog \ msg -> embed (Text.hPutStrLn stderr (fmt msg))+interpretDataLogStderrWith =+ interpretDataLogHandleWith stderr {-# inline interpretDataLogStderrWith #-} -- |Interpret 'DataLog' by printing to stderr, converting messages to 'Text' by using 'Show'.
lib/Polysemy/Log/Stdout.hs view
@@ -1,7 +1,6 @@--- |Description: Internal+-- |Description: Stdout Interpreters, Internal module Polysemy.Log.Stdout where -import qualified Data.Text.IO as Text import Polysemy.Async (Async) import Polysemy.Conc (Race) import Polysemy.Resource (Resource)@@ -11,18 +10,19 @@ import Polysemy.Log.Data.Log (Log) import Polysemy.Log.Data.LogEntry (LogEntry) import Polysemy.Log.Data.LogMessage (LogMessage)-import Polysemy.Log.Format (formatLogEntry)-import Polysemy.Log.Log (interpretDataLog, interpretLogDataLog, interpretLogDataLogConc) import Polysemy.Log.Data.Severity (Severity)+import Polysemy.Log.Format (formatLogEntry)+import Polysemy.Log.Handle (interpretDataLogHandleWith) import Polysemy.Log.Level (setLogLevel)+import Polysemy.Log.Log (interpretLogDataLog, interpretLogDataLogConc) -- |Interpret 'DataLog' by printing to stdout, converting messages to 'Text' with the supplied function. interpretDataLogStdoutWith :: Member (Embed IO) r => (a -> Text) -> InterpreterFor (DataLog a) r-interpretDataLogStdoutWith fmt =- interpretDataLog \ msg -> embed (Text.hPutStrLn stdout (fmt msg))+interpretDataLogStdoutWith =+ interpretDataLogHandleWith stdout {-# inline interpretDataLogStdoutWith #-} -- |Interpret 'DataLog' by printing to stdout, converting messages to 'Text' by using 'Show'.
polysemy-log.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: polysemy-log-version: 0.4.2.0+version: 0.4.3.0 synopsis: Polysemy Effects for Logging description: See <https://hackage.haskell.org/package/polysemy-log/docs/Polysemy-Log.html> category: Logging@@ -37,6 +37,7 @@ Polysemy.Log.Data.LogMetadata Polysemy.Log.Data.Severity Polysemy.Log.Format+ Polysemy.Log.Handle Polysemy.Log.Level Polysemy.Log.Log Polysemy.Log.Prelude