packages feed

rio 0.1.14.1 → 0.1.15.0

raw patch · 4 files changed

+38/−3 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for rio +## 0.1.15.0++* Include source in log messages+ ## 0.1.14.1  * Support `unliftio-core` 0.2
rio.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 6b5196ca703656226be396b57dc1cad657e697252fabe2a5da4c27bb45262263+-- hash: 88c70b06dfc2b555bc230e489348124cfcbdc0bdbf0ef59810cae48053937a10  name:           rio-version:        0.1.14.1+version:        0.1.15.0 synopsis:       A standard library for Haskell description:    See README and Haddocks at <https://www.stackage.org/package/rio> category:       Control
src/RIO/Prelude/Logger.hs view
@@ -35,6 +35,8 @@   , logSticky   , logStickyDone     -- *** With source+    --+    -- $withSource   , logDebugS   , logInfoS   , logWarnS@@ -204,6 +206,17 @@   -> m () logOther = logGeneric "" . LevelOther +-- $withSource+--+-- There is a set of logging functions that take an extra 'LogSource'+-- argument to provide context, typically detailing what part of an+-- application the message comes from.+--+-- For example, in verbose mode, @infoLogS "database" "connected"@ will+-- result in+--+-- > [info] (database) connected+ -- | Log a debug level message with the given source. -- -- @since 0.0.0.0@@ -530,7 +543,7 @@ setLogFormat f options = options { logFormat = f }  simpleLogFunc :: LogOptions -> CallStack -> LogSource -> LogLevel -> Utf8Builder -> IO ()-simpleLogFunc lo cs _src level msg = do+simpleLogFunc lo cs src level msg = do     logLevel   <- logMinLevel lo     logVerbose <- logVerboseFormat lo @@ -540,6 +553,7 @@         timestamp <>         getLevel logVerbose <>         ansi reset <>+        getSource <>         logFormat lo msg <>         getLoc <>         ansi reset <>@@ -581,6 +595,11 @@              display name <>              "] "      | otherwise = mempty++   getSource :: Utf8Builder+   getSource = case src of+     "" -> ""+     _  -> "(" <> display src <> ") "     getLoc :: Utf8Builder    getLoc
test/RIO/LoggerSpec.hs view
@@ -74,3 +74,15 @@       logInfo "should be formatted"     builder <- readIORef ref     toLazyByteString builder `shouldBe` "[context] should be formatted\n"+  it "noSource" $ do+    (ref, options) <- logOptionsMemory+    withLogFunc options $ \lf -> runRIO lf $ do+      logInfoS "tests" "should appear"+    builder <- readIORef ref+    toLazyByteString builder `shouldBe` "(tests) should appear\n"+  it "noSource verbose" $ do+    (ref, options) <- logOptionsMemory+    withLogFunc (options & setLogVerboseFormat True) $ \lf -> runRIO lf $ do+      logInfoS "tests" "should appear"+    builder <- readIORef ref+    toLazyByteString builder `shouldBe` "[info] (tests) should appear\n"