Skip to content

Commit

Permalink
config: yaml_parser: Handle $log_level element for special case
Browse files Browse the repository at this point in the history
Backported from 236d87d.

---

This is because `@log_level` is invalid for YAML.
Instead, we should interpret $log_level as `@log_level` on YAML parser.

Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 authored and daipom committed May 7, 2024
1 parent 44d132c commit 26d5a3e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/fluent/config/yaml_parser/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ def section_build(name, config, indent: 0, arg: nil)
sb.add_line('@id', v)
end

if (v = config.delete('$log_level'))
sb.add_line('@log_level', v)
end

config.each do |key, val|
if val.is_a?(Array)
val.each do |v|
Expand Down
6 changes: 6 additions & 0 deletions test/test_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def test_included
tag: tag.dummy
- source:
$type: tcp
$log_level: info
tag: tag.tcp
parse:
$arg:
Expand All @@ -176,6 +177,7 @@ def test_included
- match:
$tag: tag.*
$type: stdout
$log_level: debug
buffer:
$type: memory
flush_interval: 1s
Expand Down Expand Up @@ -208,10 +210,12 @@ def test_included
'tag.dummy',
'tcp',
'tag.tcp',
'info',
'none',
'why.parse.section.doesnot.have.arg,huh',
'stdout',
'tag.*',
'debug',
'null',
'**',
'@FLUENT_LOG',
Expand All @@ -224,10 +228,12 @@ def test_included
dummy_source_conf['tag'],
tcp_source_conf['@type'],
tcp_source_conf['tag'],
tcp_source_conf['@log_level'],
parse_tcp_conf['@type'],
parse_tcp_conf.arg,
match_conf['@type'],
match_conf.arg,
match_conf['@log_level'],
fluent_log_conf['@type'],
fluent_log_conf.arg,
label_conf.arg,
Expand Down

0 comments on commit 26d5a3e

Please sign in to comment.