-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
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.