Class: DVLA::Herodotus::HerodotusLogger
- Inherits:
-
Logger
- Object
- Logger
- DVLA::Herodotus::HerodotusLogger
- Defined in:
- lib/dvla/herodotus/herodotus_logger.rb
Instance Attribute Summary collapse
-
#correlation_ids ⇒ Object
Returns the value of attribute correlation_ids.
-
#merge ⇒ Object
Returns the value of attribute merge.
-
#requires_pid ⇒ Object
Returns the value of attribute requires_pid.
-
#system_name ⇒ Object
Returns the value of attribute system_name.
Instance Method Summary collapse
- #merge_correlation_ids(new_scenario: nil) ⇒ Object
- #new_scenario(scenario_id) ⇒ Object
- #register_default_correlation_id ⇒ Object
Instance Attribute Details
#correlation_ids ⇒ Object
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 |
#merge ⇒ Object
Returns the value of attribute merge.
6 7 8 |
# File 'lib/dvla/herodotus/herodotus_logger.rb', line 6 def merge @merge end |
#requires_pid ⇒ Object
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_name ⇒ Object
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_id ⇒ Object
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 |