Skip to content

Commit 5b85ac8

Browse files
Apply suggestions from code review
Signed-off-by: Shingo Nakayama <[email protected]> Co-authored-by: Daijiro Fukuda <[email protected]>
1 parent 1d496bd commit 5b85ac8

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/fluent/plugin/out_file.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,14 @@ def configure(conf)
172172
log.warn "symlink_path is unavailable on Windows platform. disabled."
173173
@symlink_path = nil
174174
else
175-
#add check if symlink_path has a tag placeholder.
176-
placeholder_validators(:symlink_path, @symlink_path).reject{|v| v.type == :time }.each do |v|
175+
placeholder_validators(:symlink_path, @symlink_path).reject{ |v| v.type == :time }.each do |v|
177176
begin
178177
v.validate!
178+
rescue Fluent::ConfigError => e
179+
log.warn "#{e}. This means multiple chunks are competing for a single symlink_path, so some logs may not be taken from the symlink."
179180
end
180-
rescue Fluent::ConfigError => e
181-
log.warn "#{e}. This means multiple chunks are competing for a single symlink_path, so some logs may not be taken from the symlink."
182181
end
183-
182+
184183
@buffer.extend SymlinkBufferMixin
185184
@buffer.symlink_path = @symlink_path
186185
@buffer.output_plugin_for_symlink = self

test/plugin/test_out_file.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ def create_driver(conf = CONFIG, opts = {})
184184
end
185185
end
186186

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

0 commit comments

Comments
 (0)