Skip to content

Commit

Permalink
Merge pull request #2730 from ganmacs/fix-log_level-doesnot-affect
Browse files Browse the repository at this point in the history
Fix bug that log level in system config doesn't affect
  • Loading branch information
repeatedly authored Dec 12, 2019
2 parents 7482802 + fc46178 commit 201cfdf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
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

0 comments on commit 201cfdf

Please sign in to comment.