module PactBroker::Config::RuntimeConfigurationLoggingMethods::InstanceMethods
Public Instance Methods
log_configuration(logger)
click to toggle source
base_url raises a not implemented error
# File lib/pact_broker/config/runtime_configuration_logging_methods.rb, line 26 def log_configuration(logger) source_info = to_source_trace attributes_to_log.collect(&:to_s).each_with_object({}) do | key, new_hash | new_hash[key] = { value: self.send(key.to_sym), source: source_info.dig(key, :source) || source_info.dig(key) || { type: :defaults } } end.sort_by { |key, _| key }.each { |key, value| log_config_inner(key, value, logger) } print_warnings(logger) end
Private Instance Methods
attributes_to_log()
click to toggle source
# File lib/pact_broker/config/runtime_configuration_logging_methods.rb, line 37 def attributes_to_log self.class.config_attributes - [:base_url] end
log_config_inner(key, value, logger)
click to toggle source
# File lib/pact_broker/config/runtime_configuration_logging_methods.rb, line 42 def log_config_inner(key, value, logger) # TODO fix the source display for webhook_certificates set by environment variables if !value.has_key? :value value.sort_by { |inner_key, _| inner_key }.each { |inner_key, inner_value| log_config_inner("#{key}.#{inner_key}", inner_value, logger) } elsif self.class.sensitive_value?(key) logger.info "#{key}=#{redact(key, value[:value])} source=#{value[:source]}" else logger.info "#{key}=#{value[:value].inspect} source=#{value[:source]}" end end
print_warnings(logger)
click to toggle source
# File lib/pact_broker/config/runtime_configuration_logging_methods.rb, line 75 def print_warnings(logger) if self.webhook_redact_sensitive_data == false logger.warn("WARNING!!! webhook_redact_sensitive_data is set to false. This will allow authentication information to be included in the webhook logs. This should only be used for debugging purposes. Do not run the application permanently in production with this value.") end end
redact(name, value)
click to toggle source
# File lib/pact_broker/config/runtime_configuration_logging_methods.rb, line 54 def redact name, value if value && name.to_s.end_with?("_url") begin uri = URI(value) if uri.password uri.password = "*****" uri.to_s else value end rescue StandardError "*****" end elsif !value.nil? "*****" else nil end end