hslogger 1.1.5 → 1.2.0
raw patch · 3 files changed
+15/−4 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ System.Log.Logger: removeAllHandlers :: IO ()
Files
- hslogger.cabal +2/−2
- src/System/Log/Handler/Simple.hs +3/−1
- src/System/Log/Logger.hs +10/−1
hslogger.cabal view
@@ -1,10 +1,10 @@ Name: hslogger-Version: 1.1.5+Version: 1.2.0 License: BSD3 Maintainer: John Goerzen <jgoerzen@complete.org> Author: John Goerzen Stability: Stable-Copyright: Copyright (c) 2004-2011 John Goerzen+Copyright: Copyright (c) 2004-2012 John Goerzen license-file: LICENSE build-type: Simple Homepage: http://software.complete.org/hslogger
src/System/Log/Handler/Simple.hs view
@@ -17,7 +17,9 @@ verboseStreamHandler) where +#if !MIN_VERSION_base(4,6,0) import Prelude hiding (catch)+#endif import Control.Exception (SomeException, catch) import Data.Char (ord) @@ -64,7 +66,7 @@ where writeToHandle hdl msg = hPutStrLn hdl msg `catch` (handleWriteException hdl msg)- handleWriteException :: Handle -> String -> SomeException -> IO ()+ handleWriteException :: Handle -> String -> IOError -> IO () handleWriteException hdl msg e = let msg' = "Error writing log message: " ++ show e ++ " (original message: " ++ msg ++ ")"
src/System/Log/Logger.hs view
@@ -154,6 +154,7 @@ -- make your job easier. debugM, infoM, noticeM, warningM, errorM, criticalM, alertM, emergencyM,+ removeAllHandlers, traplogging, -- ** Logging to a particular Logger by object logL,@@ -187,7 +188,7 @@ updateGlobalLogger ) where import System.Log-import System.Log.Handler(LogHandler)+import System.Log.Handler(LogHandler, close) import System.Log.Formatter(LogFormatter) import qualified System.Log.Handler(handle) import System.Log.Handler.Simple@@ -451,6 +452,14 @@ updateGlobalLogger ln func = do l <- getLogger ln saveGlobalLogger (func l)++-- | Allow gracefull shutdown. Release all opened files/handlers/etc.+removeAllHandlers :: IO ()+removeAllHandlers =+ modifyMVar_ logTree $ \lt -> do+ let allHandlers = Map.fold (\l r -> concat [r, handlers l]) [] lt+ mapM_ (\(HandlerT h) -> close h) allHandlers+ return $ Map.map (\l -> l {handlers = []}) lt {- | Traps exceptions that may occur, logging them, then passing them on.