diff --git a/xnat_ingest/cli/upload.py b/xnat_ingest/cli/upload.py index e9b7a32..7526b2f 100644 --- a/xnat_ingest/cli/upload.py +++ b/xnat_ingest/cli/upload.py @@ -69,7 +69,7 @@ type=str, multiple=True, default=(), - envvar="XINGEST_LOGGERS", + envvar="XINGEST_ADDITIONALLOGGERS", help=( "The loggers to use for logging. By default just the 'xnat-ingest' logger is used. " "But additional loggers can be included (e.g. 'xnat') can be " diff --git a/xnat_ingest/tests/test_cli.py b/xnat_ingest/tests/test_cli.py index d665282..5d3cdc5 100644 --- a/xnat_ingest/tests/test_cli.py +++ b/xnat_ingest/tests/test_cli.py @@ -200,10 +200,11 @@ def test_stage_and_upload( str(associated_files_dir) + "/{PatientName.family_name}_{PatientName.given_name}*.ptd", r".*/[^\.]+.[^\.]+.[^\.]+.(?P\d+)\.[A-Z]+_(?P[^\.]+).*", - "--log-file", - str(log_file), + "--logger", + "file", "info", - "--add-logger", + str(log_file), + "--additional-logger", "xnat", "--raise-errors", "--delete", @@ -220,10 +221,11 @@ def test_stage_and_upload( upload, [ str(staging_dir / STAGED_NAME_DEFAULT), - "--log-file", - str(log_file), + "--logger", + "file", "info", - "--add-logger", + str(log_file), + "--additional-logger", "xnat", "--always-include", "medimage/dicom-series", diff --git a/xnat_ingest/utils.py b/xnat_ingest/utils.py index 045c25a..f62e584 100644 --- a/xnat_ingest/utils.py +++ b/xnat_ingest/utils.py @@ -139,10 +139,10 @@ def set_logger_handling( for config in logger_configs: log_handle: logging.Handler if config.type == "file": - Path(config.location).parent.mkdir(exist_ok=True) + Path(config.location).parent.mkdir(parents=True, exist_ok=True) log_handle = logging.FileHandler(config.location) elif config.type == "stream": - stream = sys.stdout if config.location == "stdout" else sys.stderr + stream = sys.stderr if config.location == "stderr" else sys.stdout log_handle = logging.StreamHandler(stream) elif config.type == "discord": log_handle = DiscordHandler(config.location)