summaryrefslogtreecommitdiff
path: root/src/DPut.hs
blob: b305a58176e571f208b8ac125c4f08e51413e5b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module DPut where

import Control.Concurrent.STM
import qualified Data.Map.Strict as Map
import System.IO (stderr,hPutStrLn)
import Data.Maybe
import System.IO.Unsafe (unsafePerformIO)
import System.Log.Logger

data DebugTag = XAnnounce | XDHT | XOnion | XNetCrypto | XPing | XLan | XMisc | XWLog
    deriving (Eq,Ord,Show,Read,Enum,Bounded)

appName :: String
appName = "toxmpp"

(<.>) :: String -> String -> String
a <.> b = a ++ "." ++ b

dput :: DebugTag -> String -> IO ()
dput tag msg = debugM (appName <.> show tag) msg

setTagLevel :: Priority -> DebugTag -> IO ()
setTagLevel level tag = updateGlobalLogger (appName <.> show tag) (setLevel level)

setQuiet :: DebugTag -> IO ()
setQuiet = setTagLevel WARNING

setVerbose :: DebugTag -> IO ()
setVerbose = setTagLevel DEBUG