Module: Ukiryu::Debug
- Defined in:
- lib/ukiryu/debug.rb
Overview
Debug utility for conditional debug logging
Provides a single point of control for debug logging across the codebase. Debug logging is only enabled when UKIRYU_DEBUG environment variable is set.
Class Method Summary collapse
-
.enabled?(category = nil) ⇒ Boolean
Check if debug logging is enabled for a category.
-
.log(message, category: nil, context: {}) ⇒ Object
Log a debug message to stderr.
Class Method Details
.enabled?(category = nil) ⇒ Boolean
Check if debug logging is enabled for a category
24 25 26 27 28 29 30 31 |
# File 'lib/ukiryu/debug.rb', line 24 def enabled?(category = nil) case category when :executable ENV['UKIRYU_DEBUG_EXECUTABLE'] || (defined?(Platform) && Platform.windows? && ENV['CI']) else ENV['UKIRYU_DEBUG'] || ENV['UKIRYU_DEBUG_EXECUTABLE'] end end |
.log(message, category: nil, context: {}) ⇒ Object
Log a debug message to stderr
38 39 40 41 42 43 44 |
# File 'lib/ukiryu/debug.rb', line 38 def log(, category: nil, context: {}) return unless enabled?(category) prefix = "[UKIRYU DEBUG#{category ? " #{category.to_s.upcase}" : ''}]" details = context.empty? ? '' : " (#{context.map { |k, v| "#{k}=#{v.inspect}" }.join(', ')})" warn "#{prefix} #{}#{details}" end |