Module: Yarder::TaggedLogging::Formatter
- Defined in:
- lib/yarder/tagged_logging.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#call(severity, timestamp, progname, msg) ⇒ Object
This method is invoked when a log event occurs.
- #clear_tags! ⇒ Object
- #current_request_tags ⇒ Object
- #current_tags ⇒ Object
- #pop_tags(size = 1) ⇒ Object
- #process_tags(tags) ⇒ Object
- #push_request_tags(tags) ⇒ Object
- #push_tags(*tags) ⇒ Object
- #tagged(*tags) ⇒ Object
Instance Method Details
#call(severity, timestamp, progname, msg) ⇒ Object
This method is invoked when a log event occurs.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/yarder/tagged_logging.rb', line 21 def call(severity, , progname, msg) @entry = nil if msg.class == Yarder::Event @entry = msg else @entry = Yarder::Event.new(Rails.logger) @entry['message'] = msg end @entry['severity'] = severity () () #TODO Should we do anything with progname? What about source? super(severity, , progname, @entry.to_json) end |
#clear_tags! ⇒ Object
70 71 72 73 |
# File 'lib/yarder/tagged_logging.rb', line 70 def .clear .clear end |
#current_request_tags ⇒ Object
79 80 81 |
# File 'lib/yarder/tagged_logging.rb', line 79 def Thread.current[:activesupport_tagged_logging_request_tags] ||= [] end |
#current_tags ⇒ Object
75 76 77 |
# File 'lib/yarder/tagged_logging.rb', line 75 def Thread.current[:activesupport_tagged_logging_tags] ||= [] end |
#pop_tags(size = 1) ⇒ Object
66 67 68 |
# File 'lib/yarder/tagged_logging.rb', line 66 def (size = 1) .pop size end |
#process_tags(tags) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/yarder/tagged_logging.rb', line 54 def () .each do |tag| if tag.class == Hash tag.each_pair do |k,v| @entry.fields[k] = v end else @entry['tags'] << tag end end end |
#push_request_tags(tags) ⇒ Object
50 51 52 |
# File 'lib/yarder/tagged_logging.rb', line 50 def () Thread.current[:activesupport_tagged_logging_request_tags] = end |
#push_tags(*tags) ⇒ Object
44 45 46 47 48 |
# File 'lib/yarder/tagged_logging.rb', line 44 def (*) .flatten.reject(&:blank?).tap do || .concat end end |
#tagged(*tags) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/yarder/tagged_logging.rb', line 37 def tagged(*) = (*) yield self ensure (.size) end |