Module: KeyValueLogging::TaggedLogging::Formatter
- Defined in:
- lib/key_value_logging/tagged_logging.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#key_value_format ⇒ Object
Returns the value of attribute key_value_format.
Instance Method Summary collapse
-
#call(severity, timestamp, progname, msg) ⇒ Object
This method is invoked when a log event occurs.
- #clear_tags! ⇒ Object
- #current_tags ⇒ Object
- #pop_tags(keys) ⇒ Object
- #push_tags(tags) ⇒ Object
- #tagged(tags) ⇒ Object
Instance Attribute Details
#key_value_format ⇒ Object
Returns the value of attribute key_value_format.
11 12 13 |
# File 'lib/key_value_logging/tagged_logging.rb', line 11 def key_value_format @key_value_format end |
Instance Method Details
#call(severity, timestamp, progname, msg) ⇒ Object
This method is invoked when a log event occurs.
14 15 16 17 |
# File 'lib/key_value_logging/tagged_logging.rb', line 14 def call(severity, , progname, msg) formatted_msg = self.send("process_#{key_value_format}", msg) super(severity, , progname, formatted_msg) end |
#clear_tags! ⇒ Object
38 39 40 |
# File 'lib/key_value_logging/tagged_logging.rb', line 38 def .clear end |
#current_tags ⇒ Object
42 43 44 |
# File 'lib/key_value_logging/tagged_logging.rb', line 42 def Thread.current[:key_value_tagged_logging_tags] ||= {} end |
#pop_tags(keys) ⇒ Object
34 35 36 |
# File 'lib/key_value_logging/tagged_logging.rb', line 34 def (keys) keys.each { |key| .delete(key) } end |
#push_tags(tags) ⇒ Object
28 29 30 31 32 |
# File 'lib/key_value_logging/tagged_logging.rb', line 28 def () .tap do || .merge! end end |
#tagged(tags) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/key_value_logging/tagged_logging.rb', line 19 def tagged() # Add temporary tags to current tags = () yield self ensure # Remove the temporary tags from current tags (.keys) end |