Skip to content

Commit

Permalink
updated loggers syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Sep 28, 2024
1 parent 27eb978 commit 4869b92
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion xnat_ingest/cli/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
14 changes: 8 additions & 6 deletions xnat_ingest/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,11 @@ def test_stage_and_upload(
str(associated_files_dir)
+ "/{PatientName.family_name}_{PatientName.given_name}*.ptd",
r".*/[^\.]+.[^\.]+.[^\.]+.(?P<id>\d+)\.[A-Z]+_(?P<resource>[^\.]+).*",
"--log-file",
str(log_file),
"--logger",
"file",
"info",
"--add-logger",
str(log_file),
"--additional-logger",
"xnat",
"--raise-errors",
"--delete",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions xnat_ingest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 148 in xnat_ingest/utils.py

View check run for this annotation

Codecov / codecov/patch

xnat_ingest/utils.py#L144-L148

Added lines #L144 - L148 were not covered by tests
Expand Down

0 comments on commit 4869b92

Please sign in to comment.