summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2011-02-21 13:15:11 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2011-02-21 13:15:11 +0100
commit917829539cfe61a55bb1dd16bf91b00011ce8dd2 (patch)
tree764e7f54d87696d980cbeb45bf479fb894c456dd /src
parent8b57ab509f9fbf7bb2058251beb60f39e8b476ca (diff)
downloadhakyll-917829539cfe61a55bb1dd16bf91b00011ce8dd2.tar.gz
Add report function to logger
Diffstat (limited to 'src')
-rw-r--r--src/Hakyll/Core/Compiler.hs2
-rw-r--r--src/Hakyll/Core/Logger.hs9
2 files changed, 11 insertions, 0 deletions
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