df1 0.3.1 → 0.3.2
raw patch · 4 files changed
+82/−10 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +7/−0
- df1.cabal +2/−2
- lib/Df1/Render.hs +13/−8
- lib/Df1/Types.hs +60/−0
CHANGELOG.md view
@@ -1,3 +1,10 @@+# Version 0.3.2++* Added `ToValue` instances for common types like `Int`, `Bool`, etc.++* Changed colours in `Log` rendering.++ # Version 0.3.1 * Added missing language pragma.
df1.cabal view
@@ -1,8 +1,8 @@ name: df1-version: 0.3.1+version: 0.3.2 author: Renzo Carbonara maintainer: renλren.zone-copyright: Renzo Carbonara 2016-2018+copyright: Renzo Carbonara 2016 license: BSD3 license-file: LICENSE.txt extra-source-files: README.md CHANGELOG.md
lib/Df1/Render.hs view
@@ -39,17 +39,17 @@ renderColor = \log_ -> let t = renderIso8601 (log_time log_) <> space pDef = \fg -> renderPathColor fg fgBlue fgCyan (log_path log_)- pRed = renderPathColor fgBlack fgWhite fgWhite (log_path log_)+ pRed = renderPathColor fgBlack fgWhite fgCyan (log_path log_) m = space <> renderMessage (log_message log_) <> reset in case log_level log_ of Debug -> reset <> t <> pDef fgDefault <> fgDefault <> debug <> m Info -> reset <> t <> pDef fgDefault <> fgDefault <> info <> m Notice ->- bgDefault <> fgGreen <> t <> pDef fgDefault <> fgGreen <> notice <> m+ reset <> t <> pDef fgDefault <> fgGreen <> notice <> fgDefault <> m Warning ->- bgDefault <> fgYellow <> t <> pDef fgDefault <> fgYellow <> warning <> m+ reset <> t <> pDef fgDefault <> fgYellow <> warning <> fgDefault <> m Error ->- bgDefault <> fgRed <> t <> pDef fgDefault <> fgRed <> error <> m+ bgWhite <> fgBlack <> t <> pDef fgBlack <> fgRed <> error <> fgBlack <> m Critical -> bgRed <> fgBlack <> t <> pRed <> fgWhite <> critical <> fgBlack <> m Alert ->@@ -248,10 +248,10 @@ fgDefault = BB.string7 "\x1b[39m" {-# INLINE fgDefault #-} --- | Reset background-bgDefault :: BB.Builder-bgDefault = BB.string7 "\x1b[49m"-{-# INLINE bgDefault #-}+-- -- | Reset background+-- bgDefault :: BB.Builder+-- bgDefault = BB.string7 "\x1b[49m"+-- {-# INLINE bgDefault #-} -- | green foreground fgGreen :: BB.Builder@@ -292,6 +292,11 @@ bgRed :: BB.Builder bgRed = BB.string7 "\x1b[41m" {-# INLINE bgRed #-}++-- | Red background+bgWhite :: BB.Builder+bgWhite = BB.string7 "\x1b[47m"+{-# INLINE bgWhite #-} -- | Render @'%'@ followed by the given 'Word8' rendered as two hexadecimal -- nibbles.
lib/Df1/Types.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TypeSynonymInstances #-} @@ -12,10 +13,14 @@ , Message, unMessage, ToMessage(message) ) where +import Control.Exception (SomeException) import Data.Semigroup (Semigroup((<>))) import Data.Sequence as Seq import qualified Data.Text as T import qualified Data.Text.Lazy as TL+import Data.Int (Int8, Int16, Int32, Int64)+import Data.Word (Word8, Word16, Word32, Word64)+import Numeric.Natural (Natural) import Data.String (IsString(fromString)) import qualified Data.Time.Clock.System as Time @@ -118,6 +123,10 @@ message = Message . TL.pack {-# INLINE message #-} +instance ToMessage SomeException where+ message = message . show+ {-# INLINE message #-}+ -------------------------------------------------------------------------------- -- | Importance of the logged message.@@ -381,6 +390,57 @@ -- @ instance ToValue String where value = Value . TL.pack+ {-# INLINE value #-}++instance ToValue SomeException where+ value = value . show+ {-# INLINE value #-}++instance ToValue Bool where+ value = \b -> if b then Value "true" else Value "false"+ {-# INLINE value #-}++instance ToValue Int where+ value = value . show+ {-# INLINE value #-}+instance ToValue Int8 where+ value = value . show+ {-# INLINE value #-}+instance ToValue Int16 where+ value = value . show+ {-# INLINE value #-}+instance ToValue Int32 where+ value = value . show+ {-# INLINE value #-}+instance ToValue Int64 where+ value = value . show+ {-# INLINE value #-}+instance ToValue Word where+ value = value . show+ {-# INLINE value #-}+instance ToValue Word8 where+ value = value . show+ {-# INLINE value #-}+instance ToValue Word16 where+ value = value . show+ {-# INLINE value #-}+instance ToValue Word32 where+ value = value . show+ {-# INLINE value #-}+instance ToValue Word64 where+ value = value . show+ {-# INLINE value #-}+instance ToValue Integer where+ value = value . show+ {-# INLINE value #-}+instance ToValue Natural where+ value = value . show+ {-# INLINE value #-}+instance ToValue Float where+ value = value . show+ {-# INLINE value #-}+instance ToValue Double where+ value = value . show {-# INLINE value #-} --------------------------------------------------------------------------------