Merge pull request #965 from chef/ssd/expand-path

Expand relative paths based on profile location
This commit is contained in:
Steven Danna 2016-08-24 09:29:26 +01:00 committed by GitHub
commit 622de28f0f
3 changed files with 12 additions and 4 deletions

View file

@ -134,7 +134,15 @@ module Inspec
# logging singleton Inspec::Log. Eventually it would be nice to
# move internal debug logging to use this logging singleton.
#
Inspec::Log.init(o.log_location)
loc = if o.log_location
o.log_location
elsif %w{json json-min}.include?(o['format'])
STDERR
else
STDOUT
end
Inspec::Log.init(loc)
Inspec::Log.level = get_log_level(o.log_level)
o[:logger] = Logger.new(STDOUT)

View file

@ -18,8 +18,8 @@ class Inspec::InspecCLI < Inspec::BaseCLI # rubocop:disable Metrics/ClassLength
class_option :log_level, aliases: :l, type: :string,
desc: 'Set the log level: info (default), debug, warn, error'
class_option :log_location, type: :string, default: STDOUT,
desc: 'Location to send diagnostic log messages to. (default: STDOUT)'
class_option :log_location, type: :string,
desc: 'Location to send diagnostic log messages to. (default: STDOUT or STDERR)'
class_option :diagnose, type: :boolean,
desc: 'Show diagnostics (versions, configurations)'

View file

@ -91,7 +91,7 @@ module Inspec
def source_url
if opts[:path]
"file://#{opts[:path]}"
"file://#{File.expand_path(opts[:path], @cwd)}"
elsif opts[:url]
opts[:url]
end