@@ -16,14 +16,12 @@ module Control.Logger.Internal
17import Control.Has
17import Control.Has
18import Control.Lens
18import Control.Lens
19+import Control.Monad.IO.Class
19import Control.DeepSeq
20import Control.DeepSeq
20−import Data.Aeson (ToJSON, FromJSON, Object)
21+import Data.Aeson (ToJSON, FromJSON, Object, Value(..))
21import Data.Text (Text)
22import Data.Text (Text)
22import Data.Monoid
23import Data.Monoid
23import GHC.Stack
24import GHC.Stack
24−#if MIN_VERSION_mtl(2,3,0)
25−import Control.Monad.IO.Class
29data LogSeverity
27data LogSeverity
@@ -79,4 +77,18 @@ logMsgWith logger s t =
79 liftIO $ runLogger logger callStack s t
77 liftIO $ runLogger logger callStack s t
81runLogger :: Logger -> CallStack -> LogSeverity -> Text -> IO ()
79runLogger :: Logger -> CallStack -> LogSeverity -> Text -> IO ()
82−runLogger (Logger ctx theScrubber logger) cs ls txt = logger ctx cs ls (appEndo theScrubber txt)
80+runLogger (Logger ctx theScrubber logger) cs ls txt
81+ = logger (scrubContext theScrubber ctx) cs ls (appEndo theScrubber txt)
84+scrubContext :: Endo Text -> Object -> Object
85+scrubContext theScrubber = fmap doScrub
87+ doScrub :: Value -> Value
89+ Object object -> Object (fmap doScrub object)
90+ Array array -> Array (fmap doScrub array)
91+ String string -> String (appEndo theScrubber string)