From 64973c4873e0783b4d0588f10224467f80aea21a Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Tue, 15 Jun 2021 16:16:27 -0700 Subject: [PATCH] Remove old logging code --- amanuensis/log/__init__.py | 5 ----- amanuensis/log/setup.py | 45 -------------------------------------- 2 files changed, 50 deletions(-) delete mode 100644 amanuensis/log/__init__.py delete mode 100644 amanuensis/log/setup.py diff --git a/amanuensis/log/__init__.py b/amanuensis/log/__init__.py deleted file mode 100644 index 1352ce0..0000000 --- a/amanuensis/log/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from .setup import init_logging - -__all__ = [member.__name__ for member in [ - init_logging -]] diff --git a/amanuensis/log/setup.py b/amanuensis/log/setup.py deleted file mode 100644 index 6c7d24d..0000000 --- a/amanuensis/log/setup.py +++ /dev/null @@ -1,45 +0,0 @@ -import logging -import logging.handlers - - -basic_formatter = logging.Formatter( - fmt='[{levelname}] {message}', - style='{') -detailed_formatter = logging.Formatter( - fmt='[{asctime}] [{levelname}:{filename}:{lineno}] {message}', - style='{') -basic_console_handler = logging.StreamHandler() -basic_console_handler.setLevel(logging.INFO) -basic_console_handler.setFormatter(basic_formatter) -detailed_console_handler = logging.StreamHandler() -detailed_console_handler.setLevel(logging.DEBUG) -detailed_console_handler.setFormatter(detailed_formatter) - - -def get_file_handler(filename: str) -> logging.Handler: - handler = logging.handlers.RotatingFileHandler( - filename=filename, - maxBytes=1000000, - backupCount=10, - delay=True, - encoding='utf8', - ) - handler.setLevel(logging.DEBUG) - handler.setFormatter(detailed_formatter) - return handler - - -def init_logging(verbose: bool, log_filename: str): - """ - Initializes the Amanuensis logger settings - """ - logger = logging.getLogger("amanuensis") - if log_filename: - logger.addHandler(get_file_handler(log_filename)) - logger.setLevel(logging.DEBUG) - elif verbose: - logger.addHandler(detailed_console_handler) - logger.setLevel(logging.DEBUG) - else: - logger.addHandler(basic_console_handler) - logger.setLevel(logging.INFO)