From 917829539cfe61a55bb1dd16bf91b00011ce8dd2 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Mon, 21 Feb 2011 13:15:11 +0100 Subject: Add report function to logger --- src/Hakyll/Core/Compiler.hs | 2 ++ src/Hakyll/Core/Logger.hs | 9 +++++++++ 2 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/Hakyll/Core/Compiler.hs b/src/Hakyll/Core/Compiler.hs index d6090e9..e4922dd 100644 --- a/src/Hakyll/Core/Compiler.hs +++ b/src/Hakyll/Core/Compiler.hs @@ -254,9 +254,11 @@ cached :: (Binary a, Typeable a, Writable a) -> Compiler Resource a -> Compiler Resource a cached name (Compiler d j) = Compiler d $ const $ CompilerM $ do + logger <- compilerLogger <$> ask identifier <- compilerIdentifier <$> ask store <- compilerStore <$> ask modified <- compilerResourceModified <$> ask + report logger $ "Checking cache: " ++ if modified then "modified" else "OK" if modified then do v <- unCompilerM $ j $ Resource identifier liftIO $ storeSet store name identifier v diff --git a/src/Hakyll/Core/Logger.hs b/src/Hakyll/Core/Logger.hs index 8f5a4f9..720dee0 100644 --- a/src/Hakyll/Core/Logger.hs +++ b/src/Hakyll/Core/Logger.hs @@ -7,6 +7,7 @@ module Hakyll.Core.Logger , flushLogger , section , timed + , report ) where import Control.Monad (forever) @@ -79,3 +80,11 @@ timed logger msg action = do formatted = printf " [%4dms] %s" ms msg liftIO $ message logger formatted return result + +-- | Log something at the same level as 'timed', but without the timing +-- +report :: MonadIO m + => Logger -- ^ Logger + -> String -- ^ Message + -> m () -- ^ No result +report logger msg = liftIO $ message logger $ " [ ] " ++ msg -- cgit v1.2.3