Skip to content

Conversation

srebhan
Copy link
Member

@srebhan srebhan commented Feb 21, 2025

Summary

This PR makes closing of the logging infrastructure more robust by

  • not closing stderr in structured-logging
  • avoid returning an error in closing already files
  • avoid closing already closed EventLog handles

and fixes the unit tests by

  • removing prefix EventLog fixing integration tests on Windows
  • close logging everywhere we setup logging before to make sure all files are closed
  • use t.TempDir everywhere to make sure we clean up
  • close files created with os.CreateTemp to not leave open files behind

Checklist

  • No AI generated code was used in this PR

Related issues

replaces #16459

@telegraf-tiger telegraf-tiger bot added the fix pr to fix corresponding bug label Feb 21, 2025
Copy link
Collaborator

@zak-pawel zak-pawel left a comment

Choose a reason for hiding this comment

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

Seems that these

const (
	LogTargetFile   = "file"
	LogTargetStderr = "stderr"
)

are unused in text_logger.go

@srebhan
Copy link
Member Author

srebhan commented Feb 24, 2025

Seems that these

const (
	LogTargetFile   = "file"
	LogTargetStderr = "stderr"
)

are unused in text_logger.go

I know and this is on purpose. PR #15514 has the details...

@srebhan srebhan self-assigned this Feb 24, 2025
@zak-pawel
Copy link
Collaborator

Seems that these

const (
	LogTargetFile   = "file"
	LogTargetStderr = "stderr"
)

are unused in text_logger.go

I know and this is on purpose. PR #15514 has the details...

@srebhan
A comment in the code explaining why this was left would be useful because in 0.5–1 year, someone might accidentally want to remove it again ;)

@srebhan srebhan requested a review from zak-pawel February 24, 2025 11:43
@telegraf-tiger
Copy link
Contributor

@srebhan srebhan 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 Feb 24, 2025
@srebhan srebhan assigned mstrandboge and unassigned srebhan Feb 24, 2025
@mstrandboge mstrandboge merged commit 26fc051 into influxdata:master Feb 24, 2025
25 of 27 checks passed
@github-actions github-actions bot added this to the v1.33.3 milestone Feb 24, 2025
srebhan added a commit that referenced this pull request Feb 25, 2025
asaharn pushed a commit to asaharn/telegraf that referenced this pull request Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/logging 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.

3 participants