Class: Rage::LogProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/rage/log_processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLogProcessor

Returns a new instance of LogProcessor.



9
10
11
# File 'lib/rage/log_processor.rb', line 9

def initialize
  rebuild!
end

Instance Attribute Details

#dynamic_contextObject (readonly)

Returns the value of attribute dynamic_context.



7
8
9
# File 'lib/rage/log_processor.rb', line 7

def dynamic_context
  @dynamic_context
end

#dynamic_tagsObject (readonly)

Returns the value of attribute dynamic_tags.



7
8
9
# File 'lib/rage/log_processor.rb', line 7

def dynamic_tags
  @dynamic_tags
end

Instance Method Details

#add_custom_context(context_objects) ⇒ Object



13
14
15
16
# File 'lib/rage/log_processor.rb', line 13

def add_custom_context(context_objects)
  @custom_context = context_objects
  rebuild!
end

#add_custom_tags(tag_objects) ⇒ Object



18
19
20
21
# File 'lib/rage/log_processor.rb', line 18

def add_custom_tags(tag_objects)
  @custom_tags = tag_objects
  rebuild!
end

#finalize_request_logger(env, response, params) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rage/log_processor.rb', line 23

def finalize_request_logger(env, response, params)
  logger = Thread.current[:rage_logger]

  duration = (
    (Process.clock_gettime(Process::CLOCK_MONOTONIC) - logger[:request_start]) * 1000
  ).round(2)

  logger[:final] = { env:, params:, response:, duration: }
  Rage.logger.info(nil)
  logger[:final] = nil
end