30 lines
570 B
Haskell
30 lines
570 B
Haskell
|
module Server.Log where
|
||
|
|
||
|
import Control.Monad (when)
|
||
|
|
||
|
import Control.Monad.RWS (asks, MonadIO (liftIO))
|
||
|
|
||
|
import Debug.Trace
|
||
|
|
||
|
-- 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
|