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 log-file-mode option to enable appending instead of truncating #11978

Closed
Leithal3 opened this issue Feb 15, 2024 · 0 comments · Fixed by #11979
Closed

Add log-file-mode option to enable appending instead of truncating #11978

Leithal3 opened this issue Feb 15, 2024 · 0 comments · Fixed by #11979
Labels
plugin: logging related to the logging builtin plugin type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature

Comments

@Leithal3
Copy link
Contributor

What's the problem this feature will solve?

I'm trying to add custom headers to my log-files before running pytest. This is currently impossible because the LoggingPlugin hard-codes the _FileHandler mode to be "w" which truncates the log-file before printing logs.

Describe the solution you'd like

I'd like to be able to pass a --log-file-mode=a option that is respected by the LoggingPlugin and enables it to append to, rather than truncate, the log-file.

This would allow me to add custom headers to my log-files, providing additional context of the test run and the state of the system. These log-files are provided to users for debugging purposes and, as such, additional context is valuable.

Alternative Solutions

It would be possible to achieve this post hoc by reading the contents of the log-file, adding the custom header, then rewriting the contents, but this seems inefficient.

Additional context

During my search, I found this seemingly related issue that was closed due to a lack of information.

I'm happy to provide a PR with the required changes and tests.

@bluetech bluetech added type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature plugin: logging related to the logging builtin plugin labels Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: logging related to the logging builtin plugin type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants