Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug that log level in system config doesn't affect #2730

Merged
merged 1 commit into from
Dec 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/fluent/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ def build_system_config(conf)
opt = {}
Fluent::SystemConfig::SYSTEM_CONFIG_PARAMETERS.each do |param|
if @cl_opt.key?(param) && !@cl_opt[param].nil?
if param == :log_level && opt[:log_level] == Fluent::Log::LEVEL_INFO
if param == :log_level && @cl_opt[:log_level] == Fluent::Log::LEVEL_INFO
# info level can't be specified via command line option.
# log_level is info here, it is default value and <system>'s log_level should be applied if exists.
next
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/system_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SystemConfig

config_param :workers, :integer, default: 1
config_param :root_dir, :string, default: nil
config_param :log_level, :enum, list: [:trace, :debug, :info, :warn, :error, :fatal], default: nil
config_param :log_level, :enum, list: [:trace, :debug, :info, :warn, :error, :fatal], default: 'info'
config_param :suppress_repeated_stacktrace, :bool, default: nil
config_param :emit_error_log_interval, :time, default: nil
config_param :suppress_config_dump, :bool, default: nil
Expand Down
2 changes: 1 addition & 1 deletion test/config/test_system_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def parse_text(text)
sc.overwrite_variables(s.for_system_config)
assert_equal(1, sc.workers)
assert_nil(sc.root_dir)
assert_nil(sc.log_level)
assert_equal(Fluent::Log::LEVEL_INFO, sc.log_level)
assert_nil(sc.suppress_repeated_stacktrace)
assert_nil(sc.emit_error_log_interval)
assert_nil(sc.suppress_config_dump)
Expand Down
11 changes: 11 additions & 0 deletions test/test_supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,17 @@ def test_inline_config
assert_equal inline_config, sv.instance_variable_get(:@inline_config)
end

def test_log_level_affects
opts = Fluent::Supervisor.default_options
sv = Fluent::Supervisor.new(opts)

c = Fluent::Config::Element.new('system', '', { 'log_level' => 'error' }, [])
stub(sv).read_config { config_element('ROOT', '', {}, [c]) }

sv.configure
assert_equal Fluent::Log::LEVEL_ERROR, $log.level
end

def create_debug_dummy_logger
dl_opts = {}
dl_opts[:log_level] = ServerEngine::DaemonLogger::DEBUG
Expand Down