Module: Validator::Log
- Defined in:
- spec/support/log_helpers.rb
Constant Summary collapse
- INDENT =
- '> '
Instance Method Summary collapse
- 
  
    
      #log(action)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    log the start of an action. 
- 
  
    
      #log_block(action, &block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    log the start and completion/error of a block of code. 
Instance Method Details
#log(action) ⇒ Object
log the start of an action
| 6 7 8 | # File 'spec/support/log_helpers.rb', line 6 def log action Validator.log "> #{action}", level: :test end | 
#log_block(action, &block) ⇒ Object
log the start and completion/error of a block of code
| 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # File 'spec/support/log_helpers.rb', line 11 def log_block action, &block @log_indentation ||= 0 previous_log_indentation = @log_indentation Validator.log "> #{INDENT*@log_indentation}#{action}", level: :test start_time = Time.now @log_indentation += 1 yield block #Validator.log " #{INDENT*previous_log_indentation}#{action}: OK", level: :test rescue StandardError => e Validator.log " #{INDENT*previous_log_indentation}#{action}: ERROR", level: :test raise rescue Async::TimeoutError => e Validator.log " #{INDENT*previous_log_indentation}#{action}: TIMEOUT", level: :test raise RSMP::TimeoutError.new "Timeout while #{action}" ensure @log_indentation = previous_log_indentation end |