Add log-file-mode
option to enable appending instead of truncating
#11978
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
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 theLoggingPlugin
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.
The text was updated successfully, but these errors were encountered: