summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Higgins <pete@peterhiggins.org>2020-11-13 16:43:56 -0800
committerPete Higgins <pete@peterhiggins.org>2020-12-01 16:12:04 -0800
commit5cbf53934e3773827a6115e7d2b7ba8a303c221d (patch)
tree2b3a0fe06e2c37ba965207d3398db9ef1c8d82e4
parentecfaf8e3ad3469aae084e6a4ee7564788b236f99 (diff)
downloadchef-5cbf53934e3773827a6115e7d2b7ba8a303c221d.tar.gz
Use node's logger rather than Chef::Log.
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
-rw-r--r--lib/chef/audit/runner.rb24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/chef/audit/runner.rb b/lib/chef/audit/runner.rb
index d1f5cd4dd1..2aa5b1bd71 100644
--- a/lib/chef/audit/runner.rb
+++ b/lib/chef/audit/runner.rb
@@ -51,7 +51,7 @@ class Chef
def report(report = generate_report)
if report.empty?
- Chef::Log.error "Audit report was not generated properly, skipped reporting"
+ logger.error "Audit report was not generated properly, skipped reporting"
return
end
@@ -65,7 +65,7 @@ class Chef
waivers = Array(audit_attributes["waiver_file"]).select do |file|
return true if File.exist?(file)
- Chef::Log.error "The specified InSpec waiver file #{file} is missing, skipping it..."
+ logger.error "The specified InSpec waiver file #{file} is missing, skipping it..."
false
end
@@ -73,7 +73,7 @@ class Chef
"report" => true,
"reporter" => ["json-automate"],
"output" => audit_attributes["quiet"] ? ::File::NULL : STDOUT,
- "logger" => Chef::Log,
+ "logger" => logger,
backend_cache: audit_attributes["inspec_backend_cache"],
inputs: audit_attributes["attributes"],
waiver_file: waivers,
@@ -93,7 +93,7 @@ class Chef
end
def generate_report(opts: inspec_opts, profiles: inspec_profiles)
- Chef::Log.debug "Options are set to: #{opts}"
+ logger.debug "Options are set to: #{opts}"
runner = ::Inspec::Runner.new(opts)
if profiles.empty?
@@ -103,10 +103,10 @@ class Chef
profiles.each { |target| runner.add_target(target) }
- Chef::Log.info "Running profiles from: #{profiles.inspect}"
+ logger.info "Running profiles from: #{profiles.inspect}"
runner.run
r = runner.report
- Chef::Log.debug "Audit Report #{r}"
+ logger.debug "Audit Report #{r}"
r
=begin
rescue Inspec::FetcherFailure => e
@@ -120,8 +120,8 @@ class Chef
# In case InSpec raises a runtime exception without providing a valid report,
# we make one up and add two new fields to it: `status` and `status_message`
def failed_report(err)
- Chef::Log.error "InSpec has raised a runtime exception. Generating a minimal failed report."
- Chef::Log.error err
+ logger.error "InSpec has raised a runtime exception. Generating a minimal failed report."
+ logger.error err
{
"platform": {
"name": "unknown",
@@ -161,7 +161,7 @@ class Chef
end
def send_report(reporter, report)
- Chef::Log.info "Reporting to #{reporter}"
+ logger.info "Reporting to #{reporter}"
insecure = audit_attributes["insecure"]
run_time_limit = audit_attributes["run_time_limit"]
@@ -194,16 +194,16 @@ class Chef
}
Chef::Audit::Reporter::ChefServer.new(opts).send_report(report)
else
- Chef::Log.warn "unable to determine chef-server url required by inspec report collector '#{reporter}'. Skipping..."
+ logger.warn "unable to determine chef-server url required by inspec report collector '#{reporter}'. Skipping..."
end
when "json-file"
path = audit_attributes["json_file"]["location"]
- Chef::Log.info "Writing report to #{path}"
+ logger.info "Writing report to #{path}"
Chef::Audit::Reporter::JsonFile.new(file: path).send_report(report)
when "audit-enforcer"
Chef::Audit::Reporter::AuditEnforcer.new.send_report(report)
else
- Chef::Log.warn "#{reporter} is not a supported InSpec report collector"
+ logger.warn "#{reporter} is not a supported InSpec report collector"
end
end
end