log4hs 0.7.0.0 → 0.7.1.0
raw patch · 4 files changed
+42/−32 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +20/−17
- log4hs.cabal +2/−2
- src/Logging/Class/Handler.hs +13/−6
- src/Logging/Global/Internal.hs +7/−7
ChangeLog.md view
@@ -1,15 +1,18 @@ # Changelog for log4hs -## V0.3.0-- Add `RotatingFileHandler` (without unit tests)+## V0.7.1+- Fix error handling issue -## V0.3.1-- Fix `defaultRoot` format bug+## V0.7.0+- Fix `RotatingFileHandler` rollover bug+- Flatten `Logging.Types`+- Make timezone of logging environment configurable+- Add `TimeRotatingFileHandler` -## V0.4.0-- Add `Config` module to decode `Manager` from json and yaml-- Mark `Logging.Aeson` as deprecated-- Remove `Logging.Deprecated` module+## V0.6.0+- Add local logging (run in monad)+- Redesign global logging+- Remove `stderrHandler` `stdoutHandler` `defaultRoot` ## V0.5.0 - Mark `stderrHandler` `stdoutHandler` `defaultRoot` as deprecated@@ -18,13 +21,13 @@ - Refine tests - Fix `callHandler` redundant check -## V0.6.0-- Add local logging (run in monad)-- Redesign global logging-- Remove `stderrHandler` `stdoutHandler` `defaultRoot`+## V0.4.0+- Add `Config` module to decode `Manager` from json and yaml+- Mark `Logging.Aeson` as deprecated+- Remove `Logging.Deprecated` module -## V0.7.0-- Fix `RotatingFileHandler` rollover bug-- Flatten `Logging.Types`-- Make timezone of logging environment configurable-- Add `TimeRotatingFileHandler`+## V0.3.1+- Fix `defaultRoot` format bug++## V0.3.0+- Add `RotatingFileHandler` (without unit tests)
log4hs.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: cbfd6363e7bbeaee5e3e8cc995db591bf20b5f5ae9b3c4e159ad8501ed2a3cfe+-- hash: 40bf737c00b6bef41f168df6d0a764776ea87f6bd584dc12b6e12ce2764770b6 name: log4hs-version: 0.7.0.0+version: 0.7.1.0 synopsis: A python logging style log library description: Please see the http://hackage.haskell.org/package/log4hs category: logging
src/Logging/Class/Handler.hs view
@@ -6,6 +6,7 @@ module Logging.Class.Handler ( SomeHandler(..), Handler(..) ) where +import Control.Exception (SomeException, catch) import Control.Lens (set, view) import Control.Monad (when) import Data.Generics.Product.Typed@@ -80,12 +81,18 @@ -- -- Note: You can override the default implementation. handle :: a -> LogRecord -> IO Bool- handle hdl rcd@LogRecord{level=level'}- | level' < view (typed @Level) hdl = return False- | otherwise =- if filter (view (typed @Filterer) hdl) rcd- then emit hdl rcd >> return True- else return False+ handle hdl rcd@LogRecord{level=level', message=message}+ | level' < view (typed @Level) hdl = return False+ | not (filter (view (typed @Filterer) hdl) rcd) = return False+ | otherwise = catch (emit hdl rcd >> return True) handleError+ where+ -- TODO How to test+ handleError :: SomeException -> IO Bool+ handleError e = do+ putStrLn "--- Logging error ---"+ putStrLn $ show e+ putStrLn $ "Message: " ++ message+ return False fromHandler :: SomeHandler -> Maybe a fromHandler (SomeHandler h) = cast h
src/Logging/Global/Internal.hs view
@@ -11,7 +11,6 @@ import Control.Monad import Control.Monad.IO.Class import Data.IORef-import GHC.Conc import Prelude hiding (log) import System.IO.Unsafe @@ -67,13 +66,14 @@ -} run :: Manager -> IO a -> IO a run manager@Manager{..} io = do- oldHandler <- getUncaughtExceptionHandler- when catchUncaughtException $ setUncaughtExceptionHandler logException bracket_ (initialize manager >> atomicWriteIORef ref manager)- (terminate manager >> setUncaughtExceptionHandler oldHandler)- io+ (terminate manager)+ (runInner catchUncaughtException io) where unknownLoc = ("unknown file", "unknown package", "unknown module", 0) - logException :: SomeException -> IO ()- logException e = log "" "ERROR" (show e) unknownLoc+ runInner :: Bool -> IO a -> IO a+ runInner False io = io+ runInner True io = catch io $ \e -> do+ log "" "ERROR" (show (e :: SomeException)) unknownLoc+ runInner True io