Class: DVLA::Herodotus::HerodotusLogger

Inherits:
Logger
  • Object
show all
Defined in:
lib/dvla/herodotus/herodotus_logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#correlation_idsObject

Returns the value of attribute correlation_ids.



6
7
8
# File 'lib/dvla/herodotus/herodotus_logger.rb', line 6

def correlation_ids
  @correlation_ids
end

#mergeObject

Returns the value of attribute merge.



6
7
8
# File 'lib/dvla/herodotus/herodotus_logger.rb', line 6

def merge
  @merge
end

#requires_pidObject

Returns the value of attribute requires_pid.



6
7
8
# File 'lib/dvla/herodotus/herodotus_logger.rb', line 6

def requires_pid
  @requires_pid
end

#system_nameObject

Returns the value of attribute system_name.



6
7
8
# File 'lib/dvla/herodotus/herodotus_logger.rb', line 6

def system_name
  @system_name
end

Instance Method Details

#merge_correlation_ids(new_scenario: nil) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/dvla/herodotus/herodotus_logger.rb', line 18

def merge_correlation_ids(new_scenario: nil)
  ObjectSpace.each_object(DVLA::Herodotus::HerodotusLogger) do |logger|
    unless logger == self # This copies the correlation ids this logger has over to all other loggers and (assuming a new scenario has just been switched to) updates the those loggers to the current scenario
      logger.merge = false if logger.merge #Stops the other logger from trying to propagate its correlation ids to all other loggers, otherwise this code ends up in an infinite loop
      logger.correlation_ids = self.correlation_ids
      logger.new_scenario(new_scenario) unless new_scenario.nil?
    end
  end
end

#new_scenario(scenario_id) ⇒ Object



13
14
15
16
# File 'lib/dvla/herodotus/herodotus_logger.rb', line 13

def new_scenario(scenario_id)
  update_format(scenario_id)
  merge_correlation_ids(new_scenario: scenario_id) if @merge
end

#register_default_correlation_idObject



8
9
10
11
# File 'lib/dvla/herodotus/herodotus_logger.rb', line 8

def register_default_correlation_id
  @correlation_ids = { default: SecureRandom.uuid[0, 8] }
  reset_format
end