From 072c6630bf3b4fdc61ea8ccf0c1beec1ff359f30 Mon Sep 17 00:00:00 2001 From: Joscha Date: Tue, 12 May 2020 18:19:23 +0000 Subject: [PATCH] Avoid logging import in config --- PFERD/pferd.py | 12 +++++++++++- example_config.py | 3 +-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/PFERD/pferd.py b/PFERD/pferd.py index 5fff1b8..ca1c13a 100644 --- a/PFERD/pferd.py +++ b/PFERD/pferd.py @@ -14,7 +14,7 @@ from .ilias import (IliasAuthenticator, IliasCrawler, IliasDirectoryFilter, IliasDownloader, IliasDownloadInfo, IliasDownloadStrategy, KitShibbolethAuthenticator, download_modified_or_new) from .location import Location -from .logging import PrettyLogger +from .logging import PrettyLogger, enable_logging from .organizer import Organizer from .tmp_dir import TmpDir from .transform import TF, Transform, apply_transform @@ -45,6 +45,16 @@ class Pferd(Location): self._tmp_dir = TmpDir(self.resolve(tmp_dir)) self._test_run = test_run + + @staticmethod + def enable_logging() -> None: + """ + Enable and configure logging via the logging module. + """ + + enable_logging() + + @staticmethod def _print_transformables(transformables: List[TF]) -> None: LOGGER.info("") diff --git a/example_config.py b/example_config.py index e945f73..5da95de 100644 --- a/example_config.py +++ b/example_config.py @@ -2,7 +2,6 @@ import argparse from pathlib import Path, PurePath from PFERD import Pferd -from PFERD.logging import enable_logging from PFERD.transform import (attempt, do, glob, keep, move, move_dir, optionally, re_move, re_rename) @@ -72,8 +71,8 @@ def main() -> None: parser.add_argument("synchronizers", nargs="*") args = parser.parse_args() - enable_logging() pferd = Pferd(Path(__file__).parent, test_run=args.test_run) + pferd.enable_logging() if not args.synchronizers or "numerik" in args.synchronizers: pferd.ilias_kit(