2016-08-27 16:31:32 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2016-08-27 16:42:38 +00:00
|
|
|
data Verbosity = QUIET | VERBOSE | NORMAL
|
|
|
|
|
|
|
|
init :: Verbosity -> IO ()
|
|
|
|
init lvl = LOG.updateGlobalLogger "wstunnel" $ case lvl of
|
2016-10-09 18:54:08 +00:00
|
|
|
QUIET -> LOG.setLevel LOG.ERROR
|
2016-08-27 16:42:38 +00:00
|
|
|
VERBOSE -> LOG.setLevel LOG.DEBUG
|
2016-10-09 18:54:08 +00:00
|
|
|
NORMAL -> LOG.setLevel LOG.INFO
|
2016-08-27 16:42:38 +00:00
|
|
|
|
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
|