Skip to content

Commit

Permalink
Log compiler actions verbosely
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdefreyne committed Jul 3, 2016
1 parent 2331305 commit a980c9d
Showing 1 changed file with 45 additions and 10 deletions.
55 changes: 45 additions & 10 deletions lib/nanoc/base/compilation/compiler.rb
Expand Up @@ -71,23 +71,58 @@ def initialize(site, compiled_content_cache:, checksum_store:, rule_memory_store
@stack = []
end

def log_time(msg)
# TODO: only verbose

raise ArgumentError unless block_given?

before = Time.now
puts "-> #{msg}…"

yield

after = Time.now
duration = after - before
puts "-> #{msg}: done [#{format '%3.2f', duration}s]"
end

def run_all
@action_provider.preprocess(@site)
build_reps
log_time 'Preprocessing' do
@action_provider.preprocess(@site)
end

log_time 'Building reps' do
build_reps
end

run
@action_provider.postprocess(@site, @reps)

log_time 'Postprocessing' do
@action_provider.postprocess(@site, @reps)
end
end

def run
load_stores
@site.freeze
log_time 'Loading stores' do
load_stores
end

# Determine which reps need to be recompiled
forget_dependencies_if_outdated
log_time 'Freezing' do
@site.freeze
end

@stack = []
compile_reps
store
log_time 'Unsetting dependencies for outdated items' do
forget_dependencies_if_outdated
end

log_time 'Compiling' do
@stack = []
compile_reps
end

log_time 'Storing caches' do
store
end
ensure
Nanoc::Int::TempFilenameFactory.instance.cleanup(
Nanoc::Filter::TMP_BINARY_ITEMS_DIR,
Expand Down

0 comments on commit a980c9d

Please sign in to comment.