wizard-wipeout/src-server/Server/Log.hs

30 lines
580 B
Haskell
Raw Permalink Normal View History

2024-11-05 00:24:07 +00:00
module Server.Log where
import Control.Monad (when)
import Control.Monad.RWS (asks, MonadIO (liftIO))
2024-11-07 16:48:09 +00:00
import Debug.Trace (traceIO)
2024-11-05 00:24:07 +00:00
-- internal imports
import Server.Types (LogLevel, Game, ReaderContainer (rcLogLevel))
logPrint
:: LogLevel
-> String
-> Game ()
logPrint level msg = do
curLevel <- asks rcLogLevel
when (level <= curLevel) $
liftIO $ traceIO $ show level <> ": " <> msg
logPrintIO
:: LogLevel
-> LogLevel
-> String
-> IO ()
logPrintIO curLevel level msg = do
when (level <= curLevel) $
liftIO $ traceIO $ show level <> ": " <> msg