Skip to content

Commit

Permalink
Merge pull request fluent#4090 from daipom/fix-command-option-quiet
Browse files Browse the repository at this point in the history
Fix command option `--quiet`
  • Loading branch information
ashie authored Mar 13, 2023
2 parents bbb304b + bb00264 commit 4e24866
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/fluent/command/fluentd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
op.on('-q', '--quiet', "decrease verbose level (-q: warn, -qq: error)", TrueClass) {|b|
return unless b
cur_level = cmd_opts.fetch(:log_level, default_opts[:log_level])
cmd_opts[:log_level] = [cur_level + 1, Fluent::Log::LEVEL_TRACE].max
cmd_opts[:log_level] = [cur_level + 1, Fluent::Log::LEVEL_ERROR].min
}

op.on('--suppress-config-dump', "suppress config dumping when fluentd starts", TrueClass) {|b|
Expand Down
13 changes: 9 additions & 4 deletions test/command/test_fluentd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,9 @@ def multi_workers_ready?; true; end
patterns_not_match: ["[trace]"])
end

test 'trace' do
data("Trace" => "-vv")
data("Invalid low level should be treated as Trace level": "-vvv")
test 'trace' do |option|
conf = <<CONF
<source>
@type sample
Expand All @@ -1194,7 +1196,7 @@ def multi_workers_ready?; true; end
CONF
conf_path = create_conf_file('sample.conf', conf)
assert File.exist?(conf_path)
assert_log_matches(create_cmdline(conf_path, "-vv"),
assert_log_matches(create_cmdline(conf_path, option),
"[trace]",)
end

Expand All @@ -1212,7 +1214,10 @@ def multi_workers_ready?; true; end
patterns_not_match: ["[info]"])
end

test 'error' do
data("Error" => "-qq")
data("Fatal should be treated as Error level" => "-qqq")
data("Invalid high level should be treated as Error level": "-qqqq")
test 'error' do |option|
conf = <<CONF
<source>
@type plugin_not_found
Expand All @@ -1221,7 +1226,7 @@ def multi_workers_ready?; true; end
CONF
conf_path = create_conf_file('plugin_not_found.conf', conf)
assert File.exist?(conf_path)
assert_log_matches(create_cmdline(conf_path, "-qq"),
assert_log_matches(create_cmdline(conf_path, option),
"[error]",
patterns_not_match: ["[warn]"])
end
Expand Down

0 comments on commit 4e24866

Please sign in to comment.