Skip to content

Commit

Permalink
feat: print final value of configuration attribute rather than source…
Browse files Browse the repository at this point in the history
… value
  • Loading branch information
bethesque committed Mar 21, 2022
1 parent 5bce7ce commit 9c0fd3c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/pact_broker/config/runtime_configuration_logging_methods.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
require "uri"
require "pact_broker/hash_refinements"

module PactBroker
module Config
module RuntimeConfigurationLoggingMethods
using PactBroker::HashRefinements

module ClassMethods
def sensitive_values(*values)
@sensitive_values ||= []
Expand All @@ -19,8 +22,11 @@ def sensitive_value?(value)
end

module InstanceMethods
# base_url raises a not implemented error
def log_configuration(logger)
to_source_trace.sort_by { |key, _| key }.each { |key, value| log_config_inner(key, value, logger) }
to_source_trace.without("base_url").each_with_object({})do | (key, details), new_hash |
new_hash[key] = details.merge(value: self.send(key.to_sym))
end.sort_by { |key, _| key }.each { |key, value| log_config_inner(key, value, logger) }
end

def log_config_inner(key, value, logger)
Expand All @@ -29,7 +35,7 @@ def log_config_inner(key, value, logger)
elsif self.class.sensitive_value?(key)
logger.info "#{key}=#{redact(key, value[:value])} source=#{value[:source]}"
else
logger.info "#{key}=#{value[:value]} source=#{value[:source]}"
logger.info "#{key}=#{value[:value].inspect} source=#{value[:source]}"
end
end
private :log_config_inner
Expand Down

0 comments on commit 9c0fd3c

Please sign in to comment.