wizard-wipeout/src-client/Client/Log.hs

32 lines
752 B
Haskell
Raw Normal View History

2024-11-07 16:47:11 +00:00
module Client.Log where
import Control.Monad (when)
import Control.Monad.RWS (asks, MonadIO (liftIO))
import Debug.Trace (traceIO)
-- internal imports
import Client.Types (Game, LogLevel, ReaderContainer(rcLogLevel))
2024-12-17 09:03:05 +00:00
-- | Print a log line
2024-11-07 16:47:11 +00:00
logPrint
2024-12-17 09:03:05 +00:00
:: LogLevel -- ^ Desired log level of message
-> String -- ^ The message
2024-11-07 16:47:11 +00:00
-> Game ()
logPrint level msg = do
curLevel <- asks rcLogLevel
when (level <= curLevel) $
liftIO $ traceIO $ show level <> ": " <> msg
2024-12-17 09:03:05 +00:00
-- | Print a log line
2024-11-07 16:47:11 +00:00
logPrintIO
2024-12-17 09:03:05 +00:00
:: LogLevel -- ^ Current log level
-> LogLevel -- ^ Desired log level of message
-> String -- ^ The message
2024-11-07 16:47:11 +00:00
-> IO ()
logPrintIO curLevel level msg = do
when (level <= curLevel) $
liftIO $ traceIO $ show level <> ": " <> msg