Make Test.TestLogger
and Test.LogRecord
part of the public API
#44016
Labels
logging
The logging framework
Test.TestLogger
and Test.LogRecord
part of the public API
#44016
This can make writing tests that interact with functions that log a lot easier. The
@test_logs
macros are useful, but work better for small short functions that log one or two things. For end-to-end tests of larger applications, one might want to test things differently, and having access to the actualLogRecord
s to inspect and test against is very useful. Moreover, one can do something likeThe benefit of this is you can suppress logs except when an error occurs, in which case being able to see the logs might be useful in understanding the error.
This is all doable already, but it's not part of the public API. My proposal is to simply document and export
Testlogger
andLogRecord
, to make the above usage not-involving-internals. We could also provide an accessor for thelogs
field if we don't want the field itself to be public API.xref #43641 (comment)
The text was updated successfully, but these errors were encountered: