diff --git a/src/System/Logger/Backend/ColorOption.hs b/src/System/Logger/Backend/ColorOption.hs index e6e9479..e649250 100644 --- a/src/System/Logger/Backend/ColorOption.hs +++ b/src/System/Logger/Backend/ColorOption.hs @@ -51,15 +51,17 @@ module System.Logger.Backend.ColorOption import Configuration.Utils import Control.DeepSeq +import Control.Lens import Control.Monad.Except -import qualified Data.CaseInsensitive as CI +import Data.Char (toLower) #if ! MIN_VERSION_base(4,8,0) import Data.Monoid #endif import Data.Monoid.Unicode import Data.String import qualified Data.Text as T +import Data.Text.Lens import Data.Typeable import GHC.Generics @@ -85,10 +87,10 @@ data ColorOption instance NFData ColorOption readColorOption - ∷ (Monad m, Eq a, Show a, CI.FoldCase a, IsString a, IsString e, Monoid e, MonadError e m) + ∷ (Monad m, Eq a, Show a, IsText a, IsString a, IsString e, Monoid e, MonadError e m) ⇒ a → m ColorOption -readColorOption x = case CI.mk x of +readColorOption x = case runIdentity (text (pure . toLower) x) of "auto" → return ColorAuto "false" → return ColorFalse "true" → return ColorTrue diff --git a/src/System/Logger/Backend/Handle.hs b/src/System/Logger/Backend/Handle.hs index ffb3e1d..0253f98 100644 --- a/src/System/Logger/Backend/Handle.hs +++ b/src/System/Logger/Backend/Handle.hs @@ -70,7 +70,7 @@ import Control.Monad.Except import Control.Monad.Trans.Control import Control.Monad.Writer -import qualified Data.CaseInsensitive as CI +import Data.Char (toLower) import qualified Data.List as L import Data.Monoid.Unicode import Data.String @@ -106,17 +106,18 @@ data LoggerHandleConfig instance NFData LoggerHandleConfig readLoggerHandleConfig - ∷ (MonadError e m, Eq a, Show a, CI.FoldCase a, IsText a, IsString e, Monoid e) + ∷ (MonadError e m, Eq a, Show a, IsText a, IsString e, Monoid e) ⇒ a → m LoggerHandleConfig -readLoggerHandleConfig x = case CI.mk tx of +readLoggerHandleConfig x = case foldedTx of "stdout" → return StdOut "stderr" → return StdErr - _ | CI.mk (L.take 5 tx) ≡ "file:" → return $ FileHandle (L.drop 5 tx) + _ | L.take 5 foldedTx ≡ "file:" → return $ FileHandle (L.drop 5 tx) e → throwError $ "unexpected logger handle value: " ⊕ fromString (show e) ⊕ ", expected \"stdout\", \"stderr\", or \"file:\"" where + foldedTx = runIdentity $ text (pure . toLower) tx tx = packed # x loggerHandleConfigText @@ -217,7 +218,7 @@ withHandleBackend = withHandleBackend_ id withHandleBackend_ ∷ (MonadIO m, MonadBaseControl IO m) - ⇒ (msg -> T.Text) + ⇒ (msg → T.Text) -- ^ formatting function for the log message → HandleBackendConfig → (LoggerBackend msg → m α) @@ -241,7 +242,7 @@ handleBackend = handleBackend_ id {-# INLINE handleBackend #-} handleBackend_ - ∷ (msg -> T.Text) + ∷ (msg → T.Text) -- ^ formatting function for the log message → Handle → Bool diff --git a/src/System/Logger/Types.hs b/src/System/Logger/Types.hs index 9ae02ee..86498aa 100644 --- a/src/System/Logger/Types.hs +++ b/src/System/Logger/Types.hs @@ -105,7 +105,7 @@ import Control.Monad.Trans.Trace import Control.Monad.Writer import Control.Monad.Unicode -import qualified Data.CaseInsensitive as CI +import Data.Char (toLower) import Data.Monoid.Unicode import Data.String import qualified Data.Text as T @@ -135,10 +135,10 @@ data LogLevel instance NFData LogLevel readLogLevel - ∷ (MonadError e m, Eq a, Show a, CI.FoldCase a, IsString a, IsString e, Monoid e) + ∷ (MonadError e m, Eq a, Show a, IsText a, IsString a, IsString e, Monoid e) ⇒ a → m LogLevel -readLogLevel x = case CI.mk x of +readLogLevel x = case runIdentity (text (pure . toLower) x) of "quiet" → return Quiet "error" → return Error "warn" → return Warn @@ -196,10 +196,10 @@ logPolicyText LogPolicyRaise = "raise" logPolicyText LogPolicyBlock = "block" readLogPolicy - ∷ (MonadError e m, Eq a, Show a, CI.FoldCase a, IsText a, IsString e, Monoid e) + ∷ (MonadError e m, Eq a, Show a, IsText a, IsString e, Monoid e) ⇒ a → m LogPolicy -readLogPolicy x = case CI.mk tx of +readLogPolicy x = case foldedTx of "discard" → return LogPolicyDiscard "raise" → return LogPolicyRaise "block" → return LogPolicyBlock @@ -207,6 +207,7 @@ readLogPolicy x = case CI.mk tx of $ "invalid log policy value " ⊕ fromString (show e) ⊕ ";" ⊕ " the log policy value must be one of \"discard\", \"raise\", or \"block\"" where + foldedTx = runIdentity $ text (pure . toLower) tx tx = packed # x instance ToJSON LogPolicy where diff --git a/yet-another-logger.cabal b/yet-another-logger.cabal index bd702a5..8c9182a 100644 --- a/yet-another-logger.cabal +++ b/yet-another-logger.cabal @@ -96,7 +96,6 @@ Library base == 4.*, base-unicode-symbols >= 0.2, bytestring >= 0.10, - case-insensitive >= 1.2, clock >= 0.4, configuration-tools >= 0.2.8, deepseq >= 1.3,