From 1bda1faf65c2ccf4e6a0dc349ddbc0f97b67b1da Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 30 Apr 2017 12:54:50 -0400 Subject: log remote logs to subdir --- Log.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Log.hs') diff --git a/Log.hs b/Log.hs index 7e414a1..6f6ce30 100644 --- a/Log.hs +++ b/Log.hs @@ -57,11 +57,12 @@ type Logger = AnyMessage -> IO () logDir :: IO FilePath logDir = ( "log") <$> dotDir -withSessionLogger :: SessionID -> (Logger -> IO a) -> IO a -withSessionLogger sessionid a = bracket setup cleanup go +withSessionLogger :: (Maybe FilePath) -> SessionID -> (Logger -> IO a) -> IO a +withSessionLogger subdir sessionid a = bracket setup cleanup go where setup = do - dir <- logDir + basedir <- logDir + let dir = maybe basedir (basedir ) subdir createDirectoryIfMissing False dir return $ sessionLogFile dir sessionid cleanup logfile = putStrLn $ "** debug-me session was logged to " ++ logfile -- cgit v1.2.3