katip 0.3.1.5 → 0.4.0.0
raw patch · 7 files changed
+19/−21 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Katip.Scribes.Handle: _ioLogEnv :: LogEnv
+ Katip.Scribes.Handle: ioLogEnv :: Severity -> Verbosity -> IO LogEnv
Files
- README.md +1/−0
- changelog.md +4/−0
- examples/example.hs +1/−1
- examples/example_lens.hs +1/−2
- katip.cabal +1/−1
- src/Katip/Core.hs +2/−2
- src/Katip/Scribes/Handle.hs +9/−15
README.md view
@@ -83,3 +83,4 @@ * [Doug Beardsley](https://github.com/mightybyte) * [Leonid Onokhov](https://github.com/sopvop) * [Alexander Vershilov](https://github.com/qnikst)+* [Chris Martin](https://github.com/chris-martin)
changelog.md view
@@ -1,3 +1,7 @@+0.4.0.0+=======+* Drop unsafe _ioLogEnv for safe ioLogEnv+ 0.3.1.5 ======= * Add Semigroup instance for LogStr.
examples/example.hs view
@@ -25,7 +25,7 @@ -- | An example of advanced katip usage. Be sure to check out--- lens_example for a slightly cleaner and more general pattern.+-- example_lens.hs for a slightly cleaner and more general pattern. main :: IO () main = do le <- initLogEnv "MyApp" "production"
examples/example_lens.hs view
@@ -40,8 +40,7 @@ ---------------------------------------------------------------------------------- | An example of advanced katip usage. Be sure to check out--- lens_example for a slightly cleaner and more general pattern.+-- | An example of advanced katip usage with Lens. main :: IO () main = do le <- initLogEnv "MyApp" "production"
katip.cabal view
@@ -1,5 +1,5 @@ name: katip-version: 0.3.1.5+version: 0.4.0.0 synopsis: A structured logging framework. description: Katip is a structured logging framework. See README.md for more details.
src/Katip/Core.hs view
@@ -169,7 +169,7 @@ ---------------------------------------------------------------------------------- | Log message with Builder unerneath; use '<>' to concat in O(1).+-- | Log message with Builder underneath; use '<>' to concat in O(1). newtype LogStr = LogStr { unLogStr :: B.Builder } deriving (Generic, Show) @@ -193,7 +193,7 @@ ------------------------------------------------------------------------------- -- | Pack any string-like thing into a 'LogStr'. This will--- automatically work on 'String', 'ByteString, 'Text' and any of the+-- automatically work on 'String', 'ByteString', 'Text' and any of the -- lazy variants. logStr :: StringConv a Text => a -> LogStr logStr t = LogStr (B.fromText $ toS t)
src/Katip/Scribes/Handle.hs view
@@ -13,7 +13,6 @@ import Data.Text.Lazy.Builder import Data.Text.Lazy.IO as T import System.IO-import System.IO.Unsafe (unsafePerformIO) import qualified Control.Concurrent.Chan.Unagi.Bounded as U import Control.Concurrent.Async -------------------------------------------------------------------------------@@ -122,17 +121,12 @@ ---------------------------------------------------------------------------------- | An implicit environment to enable logging directly ouf of the IO monad.--- Be careful as this LogEnv won't perform any resource cleanup for you.-_ioLogEnv :: LogEnv-_ioLogEnv = unsafePerformIO $ do- le <- initLogEnv "io" "io"- (lh, _) <- mkHandleScribe ColorIfTerminal stdout DebugS V3- return $ registerScribe "stdout" lh le-{-# NOINLINE _ioLogEnv #-}----- ---------------------------------------------------------------------------------- -- | A default IO instance to make prototype development easy. User--- -- your own 'Monad' for production.--- instance Katip IO where getLogEnv = return _ioLogEnv+-- | Provides a simple log environment with 1 scribe going to+-- stdout. This is a decent example of how to build a LogEnv and is+-- best for scripts that just need a quick, reasonable set up to log+-- to stdout.+ioLogEnv :: Severity -> Verbosity -> IO LogEnv+ioLogEnv sev verb = do+ le <- initLogEnv "io" "io"+ (lh, _) <- mkHandleScribe ColorIfTerminal stdout sev verb+ return $ registerScribe "stdout" lh le