Replies: 1 comment
-
|
In case you are in control of the loggers you care about, this could work import logging
def xdist_logger(base_logger):
class WorkerLoggerAdapter(logging.LoggerAdapter):
"""Logger adapter that adds xdist worker id to log messages."""
def process(self, msg, kwargs):
worker_id = os.environ.get('PYTEST_XDIST_WORKER', 'main')
return f'[{worker_id}] {msg}', kwargs
return WorkerLoggerAdapter(base_logger, {})
logger = xdist_logger(logging.getLogger(__name__)) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have been able to generate separate logs per worker, but there are times when it would be nice to have all the logging in 1 file, including the worker name in each entry. Is there a way to do accomplish that?
Beta Was this translation helpful? Give feedback.
All reactions