Class: Makit::Rake::TraceController
- Inherits:
-
Object
- Object
- Makit::Rake::TraceController
- Defined in:
- lib/makit/rake/trace_controller.rb
Overview
Enhanced trace controller for Rake with Makit-specific debugging information
This class provides enhanced tracing capabilities when –trace is passed to rake, adding makit-specific debugging information to help with troubleshooting and understanding command execution flow.
Class Method Summary collapse
-
.setup ⇒ void
Set up enhanced tracing for Rake tasks.
-
.setup_enhanced_tracing ⇒ void
Set up enhanced tracing by monkey patching Rake’s trace methods.
-
.should_enhance_trace? ⇒ Boolean
Check if trace enhancement should be enabled.
-
.trace_status ⇒ Hash
Get current trace status.
Class Method Details
.setup ⇒ void
This method returns an undefined value.
Set up enhanced tracing for Rake tasks
This method should be called early in the Rakefile to enable enhanced tracing when –trace is passed to rake.
25 26 27 28 29 30 31 |
# File 'lib/makit/rake/trace_controller.rb', line 25 def self.setup return unless should_enhance_trace? # Set up enhanced tracing setup_enhanced_tracing Makit::Logging.debug("Enhanced trace controller activated") if defined?(Makit::Logging) end |
.setup_enhanced_tracing ⇒ void
This method returns an undefined value.
Set up enhanced tracing by monkey patching Rake’s trace methods
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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/makit/rake/trace_controller.rb', line 59 def self.setup_enhanced_tracing # Store the original trace method if not already stored unless ::Rake::Task.method_defined?(:makit_original_trace) ::Rake::Task.class_eval do alias_method :makit_original_trace, :trace def trace(mode, ) # Call original trace makit_original_trace(mode, ) # Add makit-specific trace info add_makit_trace_info(mode, ) end private # Add makit-specific trace information # # @param mode [Symbol] trace mode (:execute, :invoke, :prereq, etc.) # @param message [String] trace message # @return [void] def add_makit_trace_info(mode, ) case mode when :execute trace_makit_execution() when :invoke trace_makit_invocation() when :prereq trace_makit_prerequisite() when :syntax trace_makit_syntax() end end # Trace makit execution with detailed information # # @param message [String] execution message # @return [void] def trace_makit_execution() if () puts " [MAKIT] Executing: #{}" puts " [MAKIT] Strategy: #{get_makit_strategy_info}" puts " [MAKIT] Environment: #{ENV["MAKIT_STRATEGY"] || "auto"}" puts " [MAKIT] Working Directory: #{Dir.pwd}" puts " [MAKIT] Timestamp: #{Time.now.iso8601}" puts " [MAKIT] Task: #{name}" end end # Trace makit invocation # # @param message [String] invocation message # @return [void] def trace_makit_invocation() if () puts " [MAKIT] Invoking: #{}" puts " [MAKIT] Task: #{name}" end end # Trace makit prerequisite # # @param message [String] prerequisite message # @return [void] def trace_makit_prerequisite() if () puts " [MAKIT] Prerequisite: #{}" puts " [MAKIT] Task: #{name}" end end # Trace makit syntax # # @param message [String] syntax message # @return [void] def trace_makit_syntax() if () puts " [MAKIT] Syntax: #{}" end end # Check if message is makit-related # # @param message [String] message to check # @return [Boolean] true if message is makit-related def () .downcase.include?("makit") || .include?("bundle") || .include?("gem") || .include?("dotnet") || .include?("protoc") || .include?("git") end # Get makit strategy information safely # # @return [String] strategy information def get_makit_strategy_info begin if defined?(Makit::Commands::Runner) runner = Makit::Commands::Runner.default info = runner.strategy_info "#{info[:type]} (#{info[:class]})" else "not available" end rescue => e "error: #{e.}" end end end end end |
.should_enhance_trace? ⇒ Boolean
Check if trace enhancement should be enabled
36 37 38 39 40 |
# File 'lib/makit/rake/trace_controller.rb', line 36 def self.should_enhance_trace? ENV["RAKE_TRACE"] || ARGV.include?("--trace") || ENV["MAKIT_TRACE"] == "true" end |
.trace_status ⇒ Hash
Get current trace status
45 46 47 48 49 50 51 52 |
# File 'lib/makit/rake/trace_controller.rb', line 45 def self.trace_status { rake_trace: ENV["RAKE_TRACE"], trace_flag: ARGV.include?("--trace"), makit_trace: ENV["MAKIT_TRACE"], enhanced: should_enhance_trace?, } end |