    module Lambdabot.Logging
        ( L.Priority(..)
        , MonadLogging(..)
        , debugM
        , infoM
        , noticeM
        , warningM
        , errorM
        , criticalM
        , alertM
        , emergencyM
        ) where

    import Control.Monad
    import Data.List
    import qualified System.Log.Logger as L

    class Monad m => MonadLogging m where
        getCurrentLogger :: m [String]
        logM :: String -> L.Priority -> String -> m ()

    instance MonadLogging IO where
        getCurrentLogger :: IO [String]
    getCurrentLogger = [String] -> IO [String]
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return []
        logM :: String -> Priority -> String -> IO ()
    logM = String -> Priority -> String -> IO ()
    L.logM

    getCurrentLoggerName :: MonadLogging m => m String
    getCurrentLoggerName :: forall (m :: * -> *). MonadLogging m => m String
    getCurrentLoggerName = ([String] -> String) -> m [String] -> m String
    forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
    liftM (String -> [String] -> String
    forall a. [a] -> [[a]] -> [a]
    intercalate String
    "." ([String] -> String)
    -> ([String] -> [String]) -> [String] -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (String -> Bool) -> [String] -> [String]
    forall a. (a -> Bool) -> [a] -> [a]
    filter (Bool -> Bool
    not (Bool -> Bool) -> (String -> Bool) -> String -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Bool
    forall a. [a] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null)) m [String]
    forall (m :: * -> *). MonadLogging m => m [String]
    getCurrentLogger

    debugM :: MonadLogging m => String -> m ()
    debugM :: forall (m :: * -> *). MonadLogging m => String -> m ()
    debugM String
    msg = do
        logger <- m String
    forall (m :: * -> *). MonadLogging m => m String
    getCurrentLoggerName
        logM logger L.DEBUG msg

    infoM :: MonadLogging m => String -> m ()
    infoM :: forall (m :: * -> *). MonadLogging m => String -> m ()
    infoM String
    msg = do
        logger <- m String
    forall (m :: * -> *). MonadLogging m => m String
    getCurrentLoggerName
        logM logger L.INFO msg

    noticeM :: MonadLogging m => String -> m ()
    noticeM :: forall (m :: * -> *). MonadLogging m => String -> m ()
    noticeM String
    msg = do
        logger <- m String
    forall (m :: * -> *). MonadLogging m => m String
    getCurrentLoggerName
        logM logger L.NOTICE msg

    warningM :: MonadLogging m => String -> m ()
    warningM :: forall (m :: * -> *). MonadLogging m => String -> m ()
    warningM String
    msg = do
        logger <- m String
    forall (m :: * -> *). MonadLogging m => m String
    getCurrentLoggerName
        logM logger L.WARNING msg

    errorM :: MonadLogging m => String -> m ()
    errorM :: forall (m :: * -> *). MonadLogging m => String -> m ()
    errorM String
    msg = do
        logger <- m String
    forall (m :: * -> *). MonadLogging m => m String
    getCurrentLoggerName
        logM logger L.ERROR msg

    criticalM :: MonadLogging m => String -> m ()
    criticalM :: forall (m :: * -> *). MonadLogging m => String -> m ()
    criticalM String
    msg = do
        logger <- m String
    forall (m :: * -> *). MonadLogging m => m String
    getCurrentLoggerName
        logM logger L.CRITICAL msg

    alertM :: MonadLogging m => String -> m ()
    alertM :: forall (m :: * -> *). MonadLogging m => String -> m ()
    alertM String
    msg = do
        logger <- m String
    forall (m :: * -> *). MonadLogging m => m String
    getCurrentLoggerName
        logM logger L.ALERT msg

    emergencyM :: MonadLogging m => String -> m ()
    emergencyM :: forall (m :: * -> *). MonadLogging m => String -> m ()
    emergencyM String
    msg = do
        logger <- m String
    forall (m :: * -> *). MonadLogging m => m String
    getCurrentLoggerName
        logM logger L.EMERGENCY msg