File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
packages/tests/src/pytest_plugins/custom_logging Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -255,6 +255,19 @@ def pytest_addoption(parser: pytest.Parser) -> None: # noqa: D103
255255 ),
256256 )
257257
258+ # Allow specifying a directory for log files explicitly
259+ logging_group .addoption (
260+ "--log-to" ,
261+ action = "store" ,
262+ default = None ,
263+ dest = "eest_log_dir" ,
264+ help = (
265+ "Directory to write log files. If not provided, falls back to "
266+ "{basetemp}/logs when --basetemp is set, then ${TOX_WORK_DIR}/logs, "
267+ "and finally ./logs."
268+ ),
269+ )
270+
258271
259272@functools .cache
260273def get_log_stem (argv0 : str , argv1 : Optional [str ]) -> str :
@@ -301,10 +314,15 @@ def pytest_configure(config: pytest.Config) -> None:
301314
302315 worker_id = os .getenv ("PYTEST_XDIST_WORKER" , "main" )
303316 log_filename = f"{ log_stem } -{ worker_id } .log"
317+
318+ # Determine base logs directory by precedence:
319+ explicit_dir = getattr (config .option , "eest_log_dir" , None )
304320 basetemp_opt = getattr (config .option , "basetemp" , None )
305321 tox_work_dir = os .environ .get ("TOX_WORK_DIR" )
306322
307- if basetemp_opt :
323+ if explicit_dir :
324+ base_logs_dir = Path (str (explicit_dir ))
325+ elif basetemp_opt :
308326 base_logs_dir = Path (str (basetemp_opt )) / "logs"
309327 elif tox_work_dir :
310328 base_logs_dir = Path (tox_work_dir ) / "logs"
You can’t perform that action at this time.
0 commit comments