Module: Deimos::Logging
- Defined in:
- lib/deimos/logging.rb
Class Method Summary collapse
- ._payloads(messages) ⇒ Object
- .log_add(method, msg) ⇒ Object
- .log_debug(*args) ⇒ Object
- .log_error(*args) ⇒ Object
- .log_info(*args) ⇒ Object
- .log_warn(*args) ⇒ Object
- .messages_log_text(payload_log, messages) ⇒ Object
- .metadata_log_text(metadata) ⇒ Object
Class Method Details
._payloads(messages) ⇒ Object
32 33 34 |
# File 'lib/deimos/logging.rb', line 32 def _payloads() end |
.log_add(method, msg) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/deimos/logging.rb', line 5 def log_add(method, msg) Karafka.logger.tagged('Deimos') do |logger| logger.send(method, msg.to_json) end end |
.log_debug(*args) ⇒ Object
16 17 18 |
# File 'lib/deimos/logging.rb', line 16 def log_debug(*args) log_add(:debug, *args) end |
.log_error(*args) ⇒ Object
20 21 22 |
# File 'lib/deimos/logging.rb', line 20 def log_error(*args) log_add(:error, *args) end |
.log_info(*args) ⇒ Object
12 13 14 |
# File 'lib/deimos/logging.rb', line 12 def log_info(*args) log_add(:info, *args) end |
.log_warn(*args) ⇒ Object
24 25 26 |
# File 'lib/deimos/logging.rb', line 24 def log_warn(*args) log_add(:warn, *args) end |
.messages_log_text(payload_log, messages) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/deimos/logging.rb', line 36 def (payload_log, ) = {} case payload_log when :keys keys = .map do |m| m.respond_to?(:payload) ? m.key || m.payload['message_id'] : m[:key] || m[:payload_key] || m[:payload]['message_id'] end .merge!( payload_keys: keys ) when :count .merge!( payloads_count: .count ) when :headers .merge!( payload_headers: .map { |m| m.respond_to?(:headers) ? m.headers : m[:headers] } ) else .merge!( payloads: .map do |m| { payload: m.respond_to?(:payload) ? m.payload : m[:payload], key: m.respond_to?(:payload) ? m.key : m[:key] } end ) end end |
.metadata_log_text(metadata) ⇒ Object
28 29 30 |
# File 'lib/deimos/logging.rb', line 28 def () .to_h.slice(:timestamp, :offset, :first_offset, :last_offset, :partition, :topic, :size) end |