Class: Nanoc::CLI::CompileListeners::DebugPrinter Private
- Defined in:
- lib/nanoc/cli/compile_listeners/debug_printer.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- COLOR_MAP =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ 'compilation' => "\e[31m", 'content' => "\e[32m", 'filtering' => "\e[33m", 'dependency_tracking' => "\e[34m", 'phase' => "\e[35m", 'stage' => "\e[36m", }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #log(progname, msg) ⇒ Object private
- #logger ⇒ Object private
- #start ⇒ Object private
Methods inherited from Abstract
#initialize, #on, #run_while, #start_safely, #stop, #stop_safely, #wrapped_start, #wrapped_stop
Constructor Details
This class inherits a constructor from Nanoc::CLI::CompileListeners::Abstract
Class Method Details
.enable_for?(command_runner, _site) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 |
# File 'lib/nanoc/cli/compile_listeners/debug_printer.rb', line 6 def self.enable_for?(command_runner, _site) command_runner.debug? end |
Instance Method Details
#log(progname, msg) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
87 88 89 |
# File 'lib/nanoc/cli/compile_listeners/debug_printer.rb', line 87 def log(progname, msg) logger.info(progname) { msg } end |
#logger ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
91 92 93 94 95 96 97 98 |
# File 'lib/nanoc/cli/compile_listeners/debug_printer.rb', line 91 def logger @_logger ||= Logger.new($stdout).tap do |l| l.formatter = proc do |_severity, datetime, progname, msg| "*** #{datetime.strftime('%H:%M:%S.%L')} #{COLOR_MAP[progname]}#{msg}\e[0m\n" end end end |
#start ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/nanoc/cli/compile_listeners/debug_printer.rb', line 20 def start on(:compilation_started) do |rep| log('compilation', "Started compilation of #{rep}") end on(:compilation_ended) do |rep| log('compilation', "Ended compilation of #{rep}") log('compilation', '') end on(:compilation_suspended) do |rep, target_rep, snapshot_name| log('compilation', "Suspended compilation of #{rep}: depends on #{target_rep}, snapshot #{snapshot_name}") end on(:cached_content_used) do |rep| log('content', "Used cached compiled content for #{rep} instead of recompiling") end on(:snapshot_created) do |rep, snapshot_name| log('content', "Snapshot #{snapshot_name} created for #{rep}") end on(:filtering_started) do |rep, filter_name| log('filtering', "Started filtering #{rep} with #{filter_name}") end on(:filtering_ended) do |rep, filter_name| log('filtering', "Ended filtering #{rep} with #{filter_name}") end on(:dependency_created) do |src, dst| log('dependency_tracking', "Dependency created from #{src.inspect} onto #{dst.inspect}") end on(:phase_started) do |phase_name, rep| log('phase', "Phase started: #{phase_name} (rep: #{rep})") end on(:phase_yielded) do |phase_name, rep| log('phase', "Phase yielded: #{phase_name} (rep: #{rep})") end on(:phase_resumed) do |phase_name, rep| log('phase', "Phase resumed: #{phase_name} (rep: #{rep})") end on(:phase_ended) do |phase_name, rep| log('phase', "Phase ended: #{phase_name} (rep: #{rep})") end on(:phase_aborted) do |phase_name, rep| log('phase', "Phase aborted: #{phase_name} (rep: #{rep})") end on(:stage_started) do |stage_name| log('stage', "Stage started: #{stage_name}") end on(:stage_ended) do |stage_name| log('stage', "Stage ended: #{stage_name}") end on(:stage_aborted) do |stage_name| log('stage', "Stage aborted: #{stage_name}") end end |