Module: LogjamAgent::LoggingAttributes
- Extended by:
- LoggingAttributes
- Included in:
- LoggingAttributes
- Defined in:
- lib/logjam_agent/logging_attributes.rb
Instance Method Summary collapse
- #attributes ⇒ Object
- #attributes=(attributes) ⇒ Object
- #non_nil_attributes ⇒ Object
- #render_attributes ⇒ Object
- #reset_attributes ⇒ Object
- #set_attribute(name, value) ⇒ Object
Instance Method Details
#attributes ⇒ Object
10 11 12 13 |
# File 'lib/logjam_agent/logging_attributes.rb', line 10 def attributes Thread.current.thread_variable_get(:__logjam_agent_logging_attributes__) || Thread.current.thread_variable_set(:__logjam_agent_logging_attributes__, []) end |
#attributes=(attributes) ⇒ Object
6 7 8 |
# File 'lib/logjam_agent/logging_attributes.rb', line 6 def attributes=(attributes) Thread.current.thread_variable_set(:__logjam_agent_logging_attributes__, attributes) end |
#non_nil_attributes ⇒ Object
32 33 34 |
# File 'lib/logjam_agent/logging_attributes.rb', line 32 def non_nil_attributes attributes.select{|k,v| !k.nil? } end |
#render_attributes ⇒ Object
27 28 29 30 |
# File 'lib/logjam_agent/logging_attributes.rb', line 27 def render_attributes attrs = non_nil_attributes attrs.empty? ? nil : attrs.map{|k,v| "#{k}=#{v}"}.join(" ") end |
#reset_attributes ⇒ Object
23 24 25 |
# File 'lib/logjam_agent/logging_attributes.rb', line 23 def reset_attributes self.attributes = [] end |
#set_attribute(name, value) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/logjam_agent/logging_attributes.rb', line 15 def set_attribute(name, value) if attribute = attributes.detect{|n,v| n == name} attribute[1] = value else attributes << [name, value] end end |