diff --git a/src-client/Client/Types.hs b/src-client/Client/Types.hs index f24c5ca..dadbfb0 100644 --- a/src-client/Client/Types.hs +++ b/src-client/Client/Types.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE StrictData #-} module Client.Types where import qualified Control.Concurrent.STM as STM diff --git a/src-lib/Library/Types/Communication.hs b/src-lib/Library/Types/Communication.hs index 57f723c..52070ae 100644 --- a/src-lib/Library/Types/Communication.hs +++ b/src-lib/Library/Types/Communication.hs @@ -1,4 +1,5 @@ {-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE StrictData #-} module Library.Types.Communication where import Data.Aeson diff --git a/src-server/Server/Log.hs b/src-server/Server/Log.hs new file mode 100644 index 0000000..3d27258 --- /dev/null +++ b/src-server/Server/Log.hs @@ -0,0 +1,29 @@ +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