    {-# LANGUAGE CPP #-}
    {-# OPTIONS_GHC -fno-warn-deprecations #-} -- to suppress deprecation warning for ErrorT
    module System.Logging.Facade.Class where

    import           Control.Monad.Trans.Class
    import           Control.Monad.Trans.Cont
    import           Control.Monad.Trans.Identity
    import           Control.Monad.Trans.Maybe
    import           Control.Monad.Trans.RWS.Lazy
    import qualified Control.Monad.Trans.RWS.Strict as Strict
    import           Control.Monad.Trans.Reader
    import           Control.Monad.Trans.State.Lazy
    import qualified Control.Monad.Trans.State.Strict as Strict
    import           Control.Monad.Trans.Writer.Lazy
    import qualified Control.Monad.Trans.Writer.Strict as Strict

    #if MIN_VERSION_transformers(0,4,0)
    import           Control.Monad.Trans.Except
    #endif

    #if !MIN_VERSION_base(4,8,0)
    import           Data.Monoid
    #endif

    import           System.Logging.Facade.Sink
    import           System.Logging.Facade.Types

    #if !MIN_VERSION_transformers(0,6,0)
    import           Control.Monad.Trans.List
    import           Control.Monad.Trans.Error

    instance (Logging m) => Logging (ListT m) where
      consumeLogRecord = lift . consumeLogRecord

    instance (Error e, Logging m) => Logging (ErrorT e m) where
      consumeLogRecord = lift . consumeLogRecord
    #endif

    -- | A type class for monads with logging support
    class Monad m => Logging m where
      consumeLogRecord :: LogRecord -> m ()

    -- | Log messages that are produced in the `IO` monad are consumed by the
    -- global `LogSink`.
    instance Logging IO where
      consumeLogRecord :: LogRecord -> IO ()
    consumeLogRecord LogRecord
    record = do
        sink <- IO (LogRecord -> IO ())
    getLogSink
        sink record

    instance (Logging m) => Logging (ContT r m) where
      consumeLogRecord :: LogRecord -> ContT r m ()
    consumeLogRecord = m () -> ContT r m ()
    forall (m :: * -> *) a. Monad m => m a -> ContT r m a
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (m () -> ContT r m ())
    -> (LogRecord -> m ()) -> LogRecord -> ContT r m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . LogRecord -> m ()
    forall (m :: * -> *). Logging m => LogRecord -> m ()
    consumeLogRecord

    instance (Logging m) => Logging (IdentityT m) where
      consumeLogRecord :: LogRecord -> IdentityT m ()
    consumeLogRecord = m () -> IdentityT m ()
    forall (m :: * -> *) a. Monad m => m a -> IdentityT m a
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (m () -> IdentityT m ())
    -> (LogRecord -> m ()) -> LogRecord -> IdentityT m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . LogRecord -> m ()
    forall (m :: * -> *). Logging m => LogRecord -> m ()
    consumeLogRecord

    instance (Logging m) => Logging (MaybeT m) where
      consumeLogRecord :: LogRecord -> MaybeT m ()
    consumeLogRecord = m () -> MaybeT m ()
    forall (m :: * -> *) a. Monad m => m a -> MaybeT m a
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (m () -> MaybeT m ())
    -> (LogRecord -> m ()) -> LogRecord -> MaybeT m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . LogRecord -> m ()
    forall (m :: * -> *). Logging m => LogRecord -> m ()
    consumeLogRecord

    instance (Logging m) => Logging (ReaderT r m) where
      consumeLogRecord :: LogRecord -> ReaderT r m ()
    consumeLogRecord = m () -> ReaderT r m ()
    forall (m :: * -> *) a. Monad m => m a -> ReaderT r m a
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (m () -> ReaderT r m ())
    -> (LogRecord -> m ()) -> LogRecord -> ReaderT r m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . LogRecord -> m ()
    forall (m :: * -> *). Logging m => LogRecord -> m ()
    consumeLogRecord

    instance (Monoid w, Logging m) => Logging (RWST r w s m) where
      consumeLogRecord :: LogRecord -> RWST r w s m ()
    consumeLogRecord = m () -> RWST r w s m ()
    forall (m :: * -> *) a. Monad m => m a -> RWST r w s m a
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (m () -> RWST r w s m ())
    -> (LogRecord -> m ()) -> LogRecord -> RWST r w s m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . LogRecord -> m ()
    forall (m :: * -> *). Logging m => LogRecord -> m ()
    consumeLogRecord

    instance (Monoid w, Logging m) => Logging (Strict.RWST r w s m) where
      consumeLogRecord :: LogRecord -> RWST r w s m ()
    consumeLogRecord = m () -> RWST r w s m ()
    forall (m :: * -> *) a. Monad m => m a -> RWST r w s m a
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (m () -> RWST r w s m ())
    -> (LogRecord -> m ()) -> LogRecord -> RWST r w s m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . LogRecord -> m ()
    forall (m :: * -> *). Logging m => LogRecord -> m ()
    consumeLogRecord

    instance (Logging m) => Logging (StateT s m) where
      consumeLogRecord :: LogRecord -> StateT s m ()
    consumeLogRecord = m () -> StateT s m ()
    forall (m :: * -> *) a. Monad m => m a -> StateT s m a
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (m () -> StateT s m ())
    -> (LogRecord -> m ()) -> LogRecord -> StateT s m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . LogRecord -> m ()
    forall (m :: * -> *). Logging m => LogRecord -> m ()
    consumeLogRecord

    instance (Logging m) => Logging (Strict.StateT s m) where
      consumeLogRecord :: LogRecord -> StateT s m ()
    consumeLogRecord = m () -> StateT s m ()
    forall (m :: * -> *) a. Monad m => m a -> StateT s m a
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (m () -> StateT s m ())
    -> (LogRecord -> m ()) -> LogRecord -> StateT s m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . LogRecord -> m ()
    forall (m :: * -> *). Logging m => LogRecord -> m ()
    consumeLogRecord

    instance (Monoid w, Logging m) => Logging (WriterT w m) where
      consumeLogRecord :: LogRecord -> WriterT w m ()
    consumeLogRecord = m () -> WriterT w m ()
    forall (m :: * -> *) a. Monad m => m a -> WriterT w m a
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (m () -> WriterT w m ())
    -> (LogRecord -> m ()) -> LogRecord -> WriterT w m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . LogRecord -> m ()
    forall (m :: * -> *). Logging m => LogRecord -> m ()
    consumeLogRecord

    instance (Monoid w, Logging m) => Logging (Strict.WriterT w m) where
      consumeLogRecord :: LogRecord -> WriterT w m ()
    consumeLogRecord = m () -> WriterT w m ()
    forall (m :: * -> *) a. Monad m => m a -> WriterT w m a
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (m () -> WriterT w m ())
    -> (LogRecord -> m ()) -> LogRecord -> WriterT w m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . LogRecord -> m ()
    forall (m :: * -> *). Logging m => LogRecord -> m ()
    consumeLogRecord

    #if MIN_VERSION_transformers(0,4,0)
    instance (Logging m) => Logging (ExceptT e m) where
      consumeLogRecord :: LogRecord -> ExceptT e m ()
    consumeLogRecord = m () -> ExceptT e m ()
    forall (m :: * -> *) a. Monad m => m a -> ExceptT e m a
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (m () -> ExceptT e m ())
    -> (LogRecord -> m ()) -> LogRecord -> ExceptT e m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . LogRecord -> m ()
    forall (m :: * -> *). Logging m => LogRecord -> m ()
    consumeLogRecord
    #endif