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

Add Close method to logp.Logger #205

Merged
merged 14 commits into from
May 22, 2024
Merged

Conversation

belimawr
Copy link
Contributor

@belimawr belimawr commented May 17, 2024

What does this PR do?

Add a close method to logp.Logger responsible for closing any underlying core/output. All of our implementations of zapcore.Core that use an output that can be closed now implement io.Closer.

This allows for closing any underlying files used by any output, which can prevent issues on Windows.

It also removes the workaround for testing the loggers on Windows.

Why is it important?

It allows us to correctly close any underlying file descriptor used by our loggers. This allows us to make sure no log data is lost as well as prevent issues on Windows where folders containing active log files cannot be removed by the Elastic-Agent

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works

## Author's Checklist

Related issues

Add a close method to logp.Logger responsible for closing any
underlying core/output. All of our implementations of zapcore.Core
that use an output that can be closed now implement io.Closer.

This allows for closing any underlying files used by any output, which
can prevent issues on Windows.
@belimawr belimawr added the Team:Elastic-Agent Label for the Agent team label May 17, 2024
@belimawr belimawr self-assigned this May 17, 2024
@belimawr belimawr requested a review from a team as a code owner May 17, 2024 21:13
@belimawr belimawr requested review from rdner and fearful-symmetry and removed request for a team May 17, 2024 21:13
This commit removes a workaround for windows because the log files
could not be closed.
@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label May 20, 2024
@pierrehilbert pierrehilbert requested a review from a team May 20, 2024 05:28
@rdner
Copy link
Member

rdner commented May 20, 2024

looks like the tests found some issues though.

@belimawr
Copy link
Contributor Author

buildkite test this

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @belimawr

@belimawr belimawr merged commit 212a3be into elastic:main May 22, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Elastic-Agent Label for the Agent team Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

logp.Logger should expose a Close method to close any open files
4 participants