blob: e5824a4e6d390eb988c27dcd2c49731b790ce993 (
plain) (
blame)
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
30
31
32
|
module Internal.Logger where
import XMonad
import qualified XMonad.Util.ExtensibleState as XS
import System.IO
import Internal.NoPersist
newtype LoggerState =
LoggerState {
logHandle :: Maybe (NoPersist Handle)
}
instance ExtensionClass LoggerState where
initialValue = LoggerState Nothing
logs :: String -> X ()
logs s = do
LoggerState handle' <- XS.get
handle <-
case handle' of
Nothing -> do
handle <- io $ openFile "/tmp/xmonad.log" AppendMode
XS.put $ LoggerState $ Just $ NoPersist handle
return handle
Just (NoPersist h) -> return h
io $ do
hPutStrLn handle s
hFlush handle
|