Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Signed-off-by: Shingo Nakayama <[email protected]>

Co-authored-by: Daijiro Fukuda <[email protected]>
  • Loading branch information
Shingo-Nakayama and daipom authored May 24, 2024
1 parent 1d496bd commit 5b85ac8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 4 additions & 5 deletions lib/fluent/plugin/out_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,14 @@ def configure(conf)
log.warn "symlink_path is unavailable on Windows platform. disabled."
@symlink_path = nil
else
#add check if symlink_path has a tag placeholder.
placeholder_validators(:symlink_path, @symlink_path).reject{|v| v.type == :time }.each do |v|
placeholder_validators(:symlink_path, @symlink_path).reject{ |v| v.type == :time }.each do |v|
begin
v.validate!
rescue Fluent::ConfigError => e
log.warn "#{e}. This means multiple chunks are competing for a single symlink_path, so some logs may not be taken from the symlink."
end
rescue Fluent::ConfigError => e
log.warn "#{e}. This means multiple chunks are competing for a single symlink_path, so some logs may not be taken from the symlink."
end

@buffer.extend SymlinkBufferMixin
@buffer.symlink_path = @symlink_path
@buffer.output_plugin_for_symlink = self
Expand Down
5 changes: 3 additions & 2 deletions test/plugin/test_out_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ def create_driver(conf = CONFIG, opts = {})
end
end

test 'symlink path has not tag placeholder or key placeholder' do
test 'warning for symlink_path not including correct placeholders corresponding to chunk keys' do
omit "Windows doesn't support symlink" if Fluent.windows?
conf = config_element('match', '**', {
'path' => "#{TMP_DIR}/${tag}/${key1}/${key2}/conf_test.%Y%m%d.%H%M.log",
'symlink_path' => "#{TMP_DIR}/conf_test.current.log",
Expand All @@ -198,7 +199,7 @@ def create_driver(conf = CONFIG, opts = {})
assert_nothing_raised do
d = create_driver(conf)
assert do
d.logs.count { |log| log.include?("symlink_path:") } == 2
d.logs.count { |log| log.include?("multiple chunks are competing for a single symlink_path") } == 2
end
end
end
Expand Down

0 comments on commit 5b85ac8

Please sign in to comment.