I have a following monad transformer stack including the monad-logger transformer and I want to be able to turn off logging by a parameter.
I can see, there is the NoLoggingT type but I don't know how to make it work.
newtype MyApp a = MyApp
{ runApp :: StateT Direction (LoggingT IO) a
}
deriving (Functor, Applicative, Monad, MonadIO, MonadState Direction, MonadLogger)
runMyApp :: Params -> MyApp a -> Direction -> IO (a, Direction)
runMyApp (Params _ True) app st = runFileLoggingT "log.log" (runStateT (runApp app) st)
runMyApp (Params _ False) app st = runNoLoggingT (runStateT (runApp app) st)
How to turn off logging in this example?
I can see the function filterLogger that could return always false in case of deactivating the logging but is there any solution with the runNoLoggingT?