wstunnel/src/Logger.hs

27 lines
698 B
Haskell
Raw Normal View History

module Logger where
2016-06-01 20:31:34 +00:00
import ClassyPrelude
import Network.Socket (HostName, PortNumber)
import qualified System.Log.Logger as LOG
data Verbosity = QUIET | VERBOSE | NORMAL
init :: Verbosity -> IO ()
init lvl = LOG.updateGlobalLogger "wstunnel" $ case lvl of
QUIET -> LOG.setLevel LOG.ERROR
VERBOSE -> LOG.setLevel LOG.DEBUG
NORMAL -> LOG.setLevel LOG.INFO
2016-06-01 20:31:34 +00:00
toStr :: (HostName, PortNumber) -> String
toStr (host, port) = fromString host <> ":" <> show port
err :: String -> IO()
err msg = LOG.errorM "wstunnel" $ "ERROR :: " <> msg
info :: String -> IO()
info = LOG.infoM "wstunnel"
debug :: String -> IO()
debug msg = LOG.debugM "wstunnel" $ "DEBUG :: " <> msg