Class: LogTagger
- Inherits:
 - 
      Object
      
        
- Object
 - LogTagger
 
 
- Defined in:
 - lib/ucb_rails/log_tagger.rb
 
Overview
Wraps another logger and tags output.
Constant Summary collapse
- LOGGER_METHODS =
 [:debug, :error, :fatal, :info, :unknown, :warn]
Instance Attribute Summary collapse
- 
  
    
      #logger  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute logger.
 - 
  
    
      #tag  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute tag.
 
Instance Method Summary collapse
- 
  
    
      #initialize(tag, logger)  ⇒ LogTagger 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of LogTagger.
 - #method_missing(method, *args) ⇒ Object
 
Constructor Details
#initialize(tag, logger) ⇒ LogTagger
Returns a new instance of LogTagger.
      7 8 9 10  | 
    
      # File 'lib/ucb_rails/log_tagger.rb', line 7 def initialize(tag, logger) self.tag = tag self.logger = logger end  | 
  
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
      12 13 14 15 16 17 18  | 
    
      # File 'lib/ucb_rails/log_tagger.rb', line 12 def method_missing(method, *args) if LOGGER_METHODS.include?(method) logger.send(method, "[#{tag}] #{args.first}") else super end end  | 
  
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
      5 6 7  | 
    
      # File 'lib/ucb_rails/log_tagger.rb', line 5 def logger @logger end  | 
  
#tag ⇒ Object
Returns the value of attribute tag.
      5 6 7  | 
    
      # File 'lib/ucb_rails/log_tagger.rb', line 5 def tag @tag end  |