Skip to content

Commit

Permalink
[FIX] Fix handlers addition to the clinica logger (#1184)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasGensollen authored May 17, 2024
1 parent 7f7a0b4 commit e1faa39
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions clinica/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,23 @@ def setup_clinica_logging(logging_level: str):
from colorlog import ColoredFormatter, StreamHandler

clinica_logger = logging.getLogger("clinica")
clinica_logger.setLevel(logging_level)
console_handler = StreamHandler(stream=sys.stdout)
console_handler.setFormatter(
ColoredFormatter("%(log_color)s%(asctime)s:%(levelname)s:%(message)s")
)
clinica_logger.addHandler(console_handler)
if not clinica_logger.level:
clinica_logger.setLevel(logging_level)
if (
len(
[
handler
for handler in clinica_logger.handlers
if isinstance(handler, StreamHandler)
]
)
== 0
):
console_handler = StreamHandler(stream=sys.stdout)
console_handler.setFormatter(
ColoredFormatter("%(log_color)s%(asctime)s:%(levelname)s:%(message)s")
)
clinica_logger.addHandler(console_handler)


@click.group(context_settings=CONTEXT_SETTINGS)
Expand Down

0 comments on commit e1faa39

Please sign in to comment.