Skip to content

Commit

Permalink
log/console_adapter: Add missing seek
Browse files Browse the repository at this point in the history
Signed-off-by: Takuro Ashie <[email protected]>
  • Loading branch information
ashie committed Jan 5, 2023
1 parent a64fc37 commit c3dadf7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/fluent/log/console_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def call(subject = nil, *arguments, name: nil, severity: 'info', **options, &blo
level = 'warn'
end

@io.seek(0)
@io.truncate(0)
super
@logger.send(severity, @io.string.chomp)
Expand Down
15 changes: 15 additions & 0 deletions test/log/test_console_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,19 @@ def test_block(level)
],
@logdev.logs)
end

data(debug: :debug,
info: :info,
warn: :warn,
error: :error,
fatal: :fatal)
def test_multiple_entries(level)
@console_logger.send(level, "subject1")
@console_logger.send(level, "line2")
assert_equal([
"#{@timestamp_str} [#{level}]: 0.0s: subject1\n",
"#{@timestamp_str} [#{level}]: 0.0s: line2\n"
],
@logdev.logs)
end
end

0 comments on commit c3dadf7

Please sign in to comment.