From 7bf0c38883a93db5d374bdf25b76e7fb61d42f27 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Sat, 30 Dec 2023 17:25:40 +0100 Subject: [PATCH] Feat: add option for debugging --- pdf_oralia/scripts.py | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/pdf_oralia/scripts.py b/pdf_oralia/scripts.py index ba4be5f..c4fb4cc 100644 --- a/pdf_oralia/scripts.py +++ b/pdf_oralia/scripts.py @@ -7,28 +7,31 @@ import click from .extract import extract_save from .join import join_excel -logging_config = dict( - version=1, - formatters={"f": {"format": "%(levelname)-8s %(name)-12s %(message)s"}}, - handlers={ - "h": { - "class": "logging.StreamHandler", - "formatter": "f", - "level": logging.DEBUG, - } - }, - root={ - "handlers": ["h"], - "level": logging.DEBUG, - }, -) - -dictConfig(logging_config) - @click.group() -def main(): - pass +@click.option("--debug/--no-debug", default=False) +def main(debug): + if debug: + logging_level = logging.DEBUG + else: + logging_level = logging.INFO + logging_config = dict( + version=1, + formatters={"f": {"format": "%(levelname)-8s %(name)-12s %(message)s"}}, + handlers={ + "h": { + "class": "logging.StreamHandler", + "formatter": "f", + "level": logging_level, + } + }, + root={ + "handlers": ["h"], + "level": logging_level, + }, + ) + + dictConfig(logging_config) @main.group()