From c0b0f31f41c2e55c45bd3f6f6d893ff25ae1e869 Mon Sep 17 00:00:00 2001 From: retoor Date: Tue, 17 Dec 2024 13:03:41 +0100 Subject: [PATCH] Made logger more advanced. --- src/ragnar/__init__.py | 5 +++++ src/ragnar/cli.py | 6 +----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ragnar/__init__.py b/src/ragnar/__init__.py index 6c397ad..3c8099a 100644 --- a/src/ragnar/__init__.py +++ b/src/ragnar/__init__.py @@ -1,11 +1,16 @@ import logging import sys + +file_handler = logging.FileHandler('ragnar.log') +file_handler.setLevel(logging.INFO) + logging.basicConfig( level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", handlers=[ logging.StreamHandler(sys.stdout), + file_handler ], ) diff --git a/src/ragnar/cli.py b/src/ragnar/cli.py index 1a46822..a549485 100644 --- a/src/ragnar/cli.py +++ b/src/ragnar/cli.py @@ -28,13 +28,9 @@ def bot_task(username, password): try: bot.fight() except Exception as ex: - print(ex) - with pathlib.Path("errors.log").open("a+") as f: - f.write(str(ex)) - f.write("\n") + log.critical(ex, exc_info=True) break - def main(): args = parse_args() usernames = [