vaguerent/lib/vagrant/util/logging_formatter.rb
Chris Roberts 6f663edad0 Scrub sensitive information prior to message output
This provides a simple wrapper around all output to
scrub any strings that have been registered as sensitive
before being output. Also included is a small change
to the initial debug output to only show vagrant specific
environment variables and not the full user environment.
2017-12-14 15:38:31 -08:00

29 lines
693 B
Ruby

require "vagrant/util/credential_scrubber"
require "log4r/formatter/formatter"
module Vagrant
module Util
# Wrapper for logging formatting to provide
# information scrubbing prior to being written
# to output target
class LoggingFormatter < Log4r::BasicFormatter
# @return [Log4r::PatternFormatter]
attr_reader :formatter
# Creates a new formatter wrapper instance.
#
# @param [Log4r::Formatter]
def initialize(formatter)
@formatter = formatter
end
# Format event and scrub output
def format(event)
msg = formatter.format(event)
CredentialScrubber.desensitize(msg)
end
end
end
end