Class: ActionCable::Connection::TaggedLoggerProxy
- Inherits:
 - 
      Object
      
        
- Object
 - ActionCable::Connection::TaggedLoggerProxy
 
 
- Defined in:
 - lib/action_cable/connection/tagged_logger_proxy.rb
 
Overview
Action Cable Connection TaggedLoggerProxy
Allows the use of per-connection tags against the server logger. This wouldn’t work using the traditional ActiveSupport::TaggedLogging enhanced Rails.logger, as that logger will reset the tags between requests. The connection is long-lived, so it needs its own set of tags for its independent duration.
Instance Attribute Summary collapse
- 
  
    
      #tags  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute tags.
 
Instance Method Summary collapse
- #add_tags(*tags) ⇒ Object
 - 
  
    
      #initialize(logger, tags:)  ⇒ TaggedLoggerProxy 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of TaggedLoggerProxy.
 - #tag(logger, &block) ⇒ Object
 
Constructor Details
#initialize(logger, tags:) ⇒ TaggedLoggerProxy
Returns a new instance of TaggedLoggerProxy.
      13 14 15 16  | 
    
      # File 'lib/action_cable/connection/tagged_logger_proxy.rb', line 13 def initialize(logger, tags:) @logger = logger @tags = .flatten end  | 
  
Instance Attribute Details
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
      11 12 13  | 
    
      # File 'lib/action_cable/connection/tagged_logger_proxy.rb', line 11 def @tags end  | 
  
Instance Method Details
#add_tags(*tags) ⇒ Object
      18 19 20 21  | 
    
      # File 'lib/action_cable/connection/tagged_logger_proxy.rb', line 18 def (*) @tags += .flatten @tags = @tags.uniq end  | 
  
#tag(logger, &block) ⇒ Object
      23 24 25 26 27 28 29 30  | 
    
      # File 'lib/action_cable/connection/tagged_logger_proxy.rb', line 23 def tag(logger, &block) if logger.respond_to?(:tagged) = - logger.formatter. logger.tagged(*, &block) else yield end end  |