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 2, 2023
1 parent 8ce240a commit 2d94735
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 2d94735

Please sign in to comment.