Skip to content

Commit

Permalink
implicit log directory creation
Browse files Browse the repository at this point in the history
  • Loading branch information
fdc-am committed Feb 1, 2016
1 parent ead1b58 commit 6ad0be2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*/#*#
*_flymake.hs
.stack-work
log/*.log
log
tmp
dist
hadoop-rpc
Expand Down
1 change: 0 additions & 1 deletion log/empty

This file was deleted.

4 changes: 4 additions & 0 deletions src/Control/Distributed/Task/Util/Logging.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
module Control.Distributed.Task.Util.Logging (logError, logWarn, logInfo, logDebug, logTrace, initLogging) where

import System.Directory (createDirectoryIfMissing)
import System.IO (stdout)
import qualified System.Log.Logger as L
import qualified System.Log.Handler as L (setFormatter)
import qualified System.Log.Handler.Simple as L
import qualified System.Log.Formatter as L

import Control.Distributed.Task.Util.FileUtil

logError, logWarn, logInfo, logDebug, logTrace :: String -> IO ()
logError = simpleLog L.errorM
logWarn = simpleLog L.warningM
Expand All @@ -21,6 +24,7 @@ initLogging :: L.Priority -> L.Priority -> FilePath -> IO ()
initLogging stdoutLogLevel fileLogLevel logfile = do
L.updateGlobalLogger L.rootLoggerName (L.removeHandler)
L.updateGlobalLogger L.rootLoggerName (L.setLevel $ max' stdoutLogLevel fileLogLevel)
createDirectoryIfMissing True $ fst $ splitBasePath logfile
addHandler' $ L.fileHandler logfile fileLogLevel
addHandler' $ L.streamHandler stdout stdoutLogLevel
where
Expand Down

0 comments on commit 6ad0be2

Please sign in to comment.