ENH use log file instead of stderr
This commit is contained in:
parent
a61b17502d
commit
6c3d8c3eaf
|
@ -65,7 +65,7 @@ parseTest =
|
|||
(long "test" <> short 't' <> help "test dependencies without running")
|
||||
|
||||
xio :: XOpts -> IO ()
|
||||
xio o = runXIO $
|
||||
xio o = runXIO "xmobar.log" $
|
||||
case o of
|
||||
XDeps -> printDeps
|
||||
XTest -> withDBus_ evalConfig
|
||||
|
|
|
@ -91,7 +91,7 @@ parseTest =
|
|||
(long "test" <> short 't' <> help "test dependencies without running")
|
||||
|
||||
xio :: XOpts -> IO ()
|
||||
xio o = runXIO $
|
||||
xio o = runXIO "xmonad.log" $
|
||||
case o of
|
||||
XDeps -> printDeps
|
||||
XTest -> undefined
|
||||
|
|
|
@ -118,7 +118,7 @@ import qualified RIO.Text as T
|
|||
import System.Posix.Files
|
||||
import System.Process.Typed (nullStream)
|
||||
import UnliftIO.Environment
|
||||
import XMonad.Core (X, io)
|
||||
import XMonad.Core (X, dataDir, getDirectories, io)
|
||||
import XMonad.Internal.IO
|
||||
import XMonad.Internal.Shell hiding (proc, runProcess)
|
||||
import XMonad.Internal.Theme
|
||||
|
@ -131,9 +131,18 @@ import XMonad.Internal.Theme
|
|||
|
||||
-- | Run feature evaluation(s) with the cache
|
||||
-- Currently there is no easy way to not use this (oh well)
|
||||
runXIO :: XIO a -> IO a
|
||||
runXIO x = do
|
||||
logOpts <- setLogVerboseFormat True . setLogUseTime True <$> logOptionsHandle stderr False
|
||||
runXIO :: FilePath -> XIO a -> IO a
|
||||
runXIO logfile x = do
|
||||
-- TODO this directory will not exist on a fresh system
|
||||
p <- (</> logfile) . dataDir <$> getDirectories
|
||||
catchIO (withFile p AppendMode $ runXIOInner x) $ \e -> do
|
||||
print e
|
||||
putStrLn "could not open log file, falling back to stderr"
|
||||
runXIOInner x stderr
|
||||
|
||||
runXIOInner :: XIO a -> Handle -> IO a
|
||||
runXIOInner x h = do
|
||||
logOpts <- setLogVerboseFormat True . setLogUseTime True <$> logOptionsHandle h False
|
||||
pc <- mkDefaultProcessContext
|
||||
withLogFunc logOpts $ \f -> do
|
||||
p <- getParams
|
||||
|
|
Loading…
Reference in New Issue