From d1d0decf7c7fd91997c8572ac9169e82f1803ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Mon, 27 Nov 2023 15:17:52 +0100 Subject: [PATCH] fix: fixed logging --- aw_notify/main.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/aw_notify/main.py b/aw_notify/main.py index 0967088..81533a4 100644 --- a/aw_notify/main.py +++ b/aw_notify/main.py @@ -18,6 +18,7 @@ import aw_client.queries import click +from aw_core.log import setup_logging from desktop_notifier import DesktopNotifier from typing_extensions import TypeAlias @@ -244,15 +245,12 @@ def test_category_alert(): @click.group(invoke_without_command=True) @click.pass_context -@click.option("-v", "--verbose", is_flag=True, help="Enables verbose mode.") -def main(ctx, verbose: bool): - logging.basicConfig( - level=logging.DEBUG if verbose else logging.INFO, - format="%(asctime)s [%(levelname)5s] %(message)s" - + (" (%(name)s.%(funcName)s:%(lineno)d)" if verbose else ""), - datefmt="%Y-%m-%d %H:%M:%S", - ) +@click.option("-v", "--verbose", is_flag=True, help="Verbose logging.") +@click.option("--testing", is_flag=True, help="Enables testing mode.") +def main(ctx, verbose: bool, testing: bool): + setup_logging("aw-notify", testing=testing, verbose=verbose, log_file=True) logging.getLogger("urllib3").setLevel(logging.WARNING) + logger.info("Starting...") if ctx.invoked_subcommand is None: ctx.invoke(start)