mercredi 8 août 2018

How should I log in my pytest plugin?

I'm building a pytest plugin and I currently log by adding something similar to the following two lines at the top of the plugin file:

logging.basicConfig()
log = logging.getLogger(PLUGIN_NAME)

However, this does not seem to take into account pytest configuration (through either command line options or ini file) such as the log file path, logger format, etc.

I can manually copy those into my basicConfig call, but I assume there's a better facility used across pytest and third party plugins for logging, is there not?

I found quite a bit of logging references in pytest's documentation and code, but all of it was discussing capturing test logs. I'm interesting in logging the pytest plugin itself.

Aucun commentaire:

Enregistrer un commentaire