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

fix(logging): Add Close() func for redirectLogger #16219

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

zmyzheng
Copy link
Contributor

@zmyzheng zmyzheng commented Nov 21, 2024

Summary

Telegraf provides the function RedirectLogging(w io.Writer) which allows the user to optionally redirect the log to a customized sink by wrapping the instance.impl as a redirectLogger. In this case, when the user tries to close this sink by calling logger.CloseLogging() func (which internally calls handler.close()), the sink closing will not take effect because redirectLogger is not an io.Closer, while the handler only do the close after checking it is an io.Closer. This PR fixes this issue by implementing the Close() function for redirectLogger to make it as an io.Closer().

This issue only happens when redirectLogger is used. In comparion, other sink interface implementations (like textLogger and structuredLogger don't have this issue as both of them have already implemented the Close() function.

Checklist

  • No AI generated code was used in this PR

Related issues

resolves #16218

@telegraf-tiger telegraf-tiger bot added the fix pr to fix corresponding bug label Nov 21, 2024
Copy link
Member

@DStrand1 DStrand1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@DStrand1 DStrand1 added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Nov 22, 2024
Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution @zmyzheng!

@srebhan srebhan merged commit 16401c7 into influxdata:master Nov 25, 2024
35 checks passed
@github-actions github-actions bot added this to the v1.33.0 milestone Nov 25, 2024
justinwwhuang pushed a commit to justinwwhuang/telegraf_fork that referenced this pull request Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix pr to fix corresponding bug ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File cannot be closed when redirectLogger is used.
3 participants