more linting and adding Log module
This commit is contained in:
parent
bd5b74722c
commit
892333bb6e
3 changed files with 31 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
|||
{-# LANGUAGE StrictData #-}
|
||||
module Client.Types where
|
||||
|
||||
import qualified Control.Concurrent.STM as STM
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
module Library.Types.Communication where
|
||||
|
||||
import Data.Aeson
|
||||
|
|
29
src-server/Server/Log.hs
Normal file
29
src-server/Server/Log.hs
Normal file
|
@ -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
|
Loading…
Reference in a new issue