@@ -27,7 +27,8 @@ import Hakyll.Core.Compiler.Require
27import Hakyll.Core.Configuration
27import Hakyll.Core.Configuration
28import Hakyll.Core.Dependencies
28import Hakyll.Core.Dependencies
29import Hakyll.Core.Identifier
29import Hakyll.Core.Identifier
30−import Hakyll.Core.Logger
30+import Hakyll.Core.Logger (Logger)
31+import qualified Hakyll.Core.Logger as Logger
31import Hakyll.Core.ResourceProvider
32import Hakyll.Core.ResourceProvider
32import Hakyll.Core.Routes
33import Hakyll.Core.Routes
33import Hakyll.Core.Rules.Internal
34import Hakyll.Core.Rules.Internal
@@ -41,13 +42,15 @@ import Hakyll.Core.Writable
41run :: Configuration -> Rules a -> IO RuleSet
42run :: Configuration -> Rules a -> IO RuleSet
42run configuration rules = do
43run configuration rules = do
43 -- Initialization
44 -- Initialization
44− logger <- makeLogger putStrLn
45+ logger <- Logger.new Logger.Debug putStrLn
45− section logger "Initialising"
46+ Logger.header logger "Initialising"
46− store <- timed logger "Creating store" $
47+ Logger.item logger ["Creating store"]
47− Store.new (inMemoryCache configuration) $ storeDirectory configuration
48+ store <- Store.new (inMemoryCache configuration) $
49+ storeDirectory configuration
48− provider <- timed logger "Creating provider" $
50+ Logger.item logger ["Creating provider"]
49− newResourceProvider store (ignoreFile configuration) "."
51+ provider <- newResourceProvider store (ignoreFile configuration) "."
52+ Logger.item logger ["Running rules"]
50− ruleSet <- timed logger "Running rules" $ runRules rules provider
53+ ruleSet <- runRules rules provider
52 -- Get old facts
55 -- Get old facts
53 mOldFacts <- Store.get store factsKey
56 mOldFacts <- Store.get store factsKey
@@ -73,11 +76,11 @@ run configuration rules = do
73 -- Run the program and fetch the resulting state
76 -- Run the program and fetch the resulting state
74 result <- runErrorT $ runRWST build read' state
77 result <- runErrorT $ runRWST build read' state
75 case result of
78 case result of
76− Left e -> thrown logger e
79+ Left e -> Logger.error logger e
77 Right (_, s, _) -> Store.set store factsKey $ runtimeFacts s
80 Right (_, s, _) -> Store.set store factsKey $ runtimeFacts s
79 -- Flush and return
82 -- Flush and return
80− flushLogger logger
83+ Logger.flush logger
81 return ruleSet
84 return ruleSet
83 factsKey = ["Hakyll.Core.Runtime.run", "facts"]
86 factsKey = ["Hakyll.Core.Runtime.run", "facts"]
@@ -109,23 +112,25 @@ type Runtime a = RWST RuntimeRead () RuntimeState (ErrorT String IO) a
109--------------------------------------------------------------------------------
112--------------------------------------------------------------------------------
110build :: Runtime ()
113build :: Runtime ()
111build = do
114build = do
115+ logger <- runtimeLogger <$> ask
116+ Logger.header logger "Checking for out-of-date items"
112 scheduleOutOfDate
117 scheduleOutOfDate
118+ Logger.header logger "Compiling"
113 pickAndChase
119 pickAndChase
120+ Logger.header logger "Success"
116--------------------------------------------------------------------------------
123--------------------------------------------------------------------------------
117scheduleOutOfDate :: Runtime ()
124scheduleOutOfDate :: Runtime ()
118scheduleOutOfDate = do
125scheduleOutOfDate = do
119− logger <- runtimeLogger <$> ask
120 provider <- runtimeProvider <$> ask
126 provider <- runtimeProvider <$> ask
121 universe <- runtimeUniverse <$> ask
127 universe <- runtimeUniverse <$> ask
122 facts <- runtimeFacts <$> get
128 facts <- runtimeFacts <$> get
123 todo <- runtimeTodo <$> get
129 todo <- runtimeTodo <$> get
125 let identifiers = map fst universe
131 let identifiers = map fst universe
126− modified <- timed logger "Checking for modified items" $
127− fmap S.fromList $ flip filterM identifiers $
132+ modified <- fmap S.fromList $ flip filterM identifiers $
128− liftIO . resourceModified provider
133+ liftIO . resourceModified provider
129 let (ood, facts', _) = outOfDate identifiers modified facts
134 let (ood, facts', _) = outOfDate identifiers modified facts
130 todo' = M.fromList
135 todo' = M.fromList
131 [(id', c) | (id', c) <- universe, id' `S.member` ood]
136 [(id', c) | (id', c) <- universe, id' `S.member` ood]
@@ -163,7 +168,6 @@ chase trail id'
163 store <- runtimeStore <$> ask
168 store <- runtimeStore <$> ask
164 config <- runtimeConfiguration <$> ask
169 config <- runtimeConfiguration <$> ask
166− section logger $ "Processing " ++ show id'
167 let compiler = todo M.! id'
171 let compiler = todo M.! id'
168 read' = CompilerRead
172 read' = CompilerRead
169 { compilerIdentifier = id'
173 { compilerIdentifier = id'
@@ -174,18 +178,25 @@ chase trail id'
174 , compilerLogger = logger
178 , compilerLogger = logger
177− result <- timed logger "Compiling" $ liftIO $ runCompiler compiler read'
181+ result <- liftIO $ runCompiler compiler read'
178 case result of
182 case result of
179 -- Rethrow error
183 -- Rethrow error
180 CompilerError e -> throwError e
184 CompilerError e -> throwError e
182 -- Huge success
186 -- Huge success
183− CompilerDone (CompiledItem compiled) facts -> do
187+ CompilerDone (CompiledItem compiled) cwrite -> do
188+ let facts = compilerDependencies cwrite
190+ | compilerCacheHits cwrite <= 0 = "modified"
191+ | otherwise = "cache hit"
192+ Logger.item logger [show id', cacheHits]
184 -- Write if necessary
194 -- Write if necessary
185 case runRoutes routes id' of
195 case runRoutes routes id' of
186 Nothing -> return ()
196 Nothing -> return ()
187− Just url -> timed logger ("Routing to " ++ url) $ do
197+ Just url -> do
188 let path = destinationDirectory config </> url
198 let path = destinationDirectory config </> url
199+ Logger.subitem logger ["-> " ++ path]
189 liftIO $ makeDirectories path
200 liftIO $ makeDirectories path
190 liftIO $ write path compiled
201 liftIO $ write path compiled