Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt Console::Logger to Fluent::Log #3987

Merged
merged 13 commits into from
Jan 23, 2023
Merged
Prev Previous commit
Next Next commit
log/console_adapter: Add missing seek
Signed-off-by: Takuro Ashie <[email protected]>
ashie committed Jan 5, 2023
commit c3dadf7a821e85ab0d22c1f9ce6e7c3bcd5d3c9c
1 change: 1 addition & 0 deletions lib/fluent/log/console_adapter.rb
Original file line number Diff line number Diff line change
@@ -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)
15 changes: 15 additions & 0 deletions test/log/test_console_adapter.rb
Original file line number Diff line number Diff line change
@@ -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