@@ -102,6 +102,7 @@ module Hakyll.Core.Compiler
102102 , cached
103103 , unsafeCompiler
104104 , mapCompiler
105+ , timedCompiler
105106 ) where
106107
107108import Prelude hiding ((.), id)
@@ -124,6 +125,7 @@ import Hakyll.Core.Compiler.Internal
124125import Hakyll.Core.Store
125126import Hakyll.Core.Rules.Internal
126127import Hakyll.Core.Routes
128+import Hakyll.Core.Logger
127129
128130-- | Run a compiler, yielding the resulting target and it's dependencies. This
129131-- version of 'runCompilerJob' also stores the result
@@ -134,10 +136,12 @@ runCompiler :: Compiler () CompileRule -- ^ Compiler to run
134136 -> Routes -- ^ Route
135137 -> Store -- ^ Store
136138 -> Bool -- ^ Was the resource modified?
139+ -> Logger -- ^ Logger
137140 -> IO CompileRule -- ^ Resulting item
138−runCompiler compiler identifier provider routes store modified = do
141+runCompiler compiler identifier provider routes store modified logger = do
139142 -- Run the compiler job
140− result <- runCompilerJob compiler identifier provider routes store modified
143+ result <-
144+ runCompilerJob compiler identifier provider routes store modified logger
141145
142146 -- Inspect the result
143147 case result of
@@ -274,3 +278,12 @@ unsafeCompiler f = fromJob $ CompilerM . liftIO . f
274278mapCompiler :: Compiler a b
275279 -> Compiler [a] [b]
276280mapCompiler (Compiler d j) = Compiler d $ mapM j
281+
282+-- | Log and time a compiler
283+--
284+timedCompiler :: String -- ^ Message
285+ -> Compiler a b -- ^ Compiler to time
286+ -> Compiler a b -- ^ Resulting compiler
287+timedCompiler msg (Compiler d j) = Compiler d $ \x -> CompilerM $ do
288+ logger <- compilerLogger <$> ask
289+ timed logger msg $ unCompilerM $ j x