From 280303f4616dee7d12a6f702163c97b39656edc5 Mon Sep 17 00:00:00 2001 From: X Date: Fri, 6 May 2022 11:54:00 +0200 Subject: [PATCH] changed filehandler level to INFO and changed Logger to files --- logging.config | 2 +- tiktok_hashtag_analysis/data_methods.py | 5 +++-- tiktok_hashtag_analysis/file_methods.py | 4 ++-- tiktok_hashtag_analysis/hashtag_frequencies.py | 5 +++-- tiktok_hashtag_analysis/run_downloader.py | 3 ++- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/logging.config b/logging.config index b0f5c59..506bb26 100644 --- a/logging.config +++ b/logging.config @@ -25,7 +25,7 @@ args=(sys.stdout,) [handler_fileHandler] class=FileHandler -level=WARNING +level=INFO formatter=fileFormatter args=("../logfile.log",) diff --git a/tiktok_hashtag_analysis/data_methods.py b/tiktok_hashtag_analysis/data_methods.py index 382e1f2..4e6d9b6 100644 --- a/tiktok_hashtag_analysis/data_methods.py +++ b/tiktok_hashtag_analysis/data_methods.py @@ -2,11 +2,12 @@ """ from typing import NamedTuple, List, Tuple, Set, Optional, Dict, Any -import logging +import logging, logging.config import file_methods -logger = logging.getLogger() +logging.config.fileConfig("../logging.config") +logger = logging.getLogger("Logger") class Diff(NamedTuple): diff --git a/tiktok_hashtag_analysis/file_methods.py b/tiktok_hashtag_analysis/file_methods.py index e9c7256..0666a91 100644 --- a/tiktok_hashtag_analysis/file_methods.py +++ b/tiktok_hashtag_analysis/file_methods.py @@ -11,7 +11,7 @@ from typing import Tuple, List, Optional, Dict, Any import logging, logging.config logging.config.fileConfig("../logging.config") -logger = logging.getLogger() +logger = logging.getLogger("Logger") def create_file(name: str, file_type: str): @@ -136,7 +136,7 @@ def log_writer(log_data: List[Tuple[str, Tuple[str, int]]]): now_str = datetime.now().strftime("%d-%m-%Y %H:%M:%S") data = {now_str: scraped_summary_dict} - logger.debug(f"Logged post data: {data}") + logger.info(f"Logged post data: {data}") logger.info(f"Successfully scraped {total} total entries") diff --git a/tiktok_hashtag_analysis/hashtag_frequencies.py b/tiktok_hashtag_analysis/hashtag_frequencies.py index aa3119c..37e70ac 100644 --- a/tiktok_hashtag_analysis/hashtag_frequencies.py +++ b/tiktok_hashtag_analysis/hashtag_frequencies.py @@ -12,7 +12,7 @@ import argparse from datetime import datetime import warnings from typing import List, Tuple, Dict, Any -import logging +import logging, logging.config import matplotlib.pyplot as plt import matplotlib.ticker as mtick @@ -23,7 +23,8 @@ from global_data import IMAGES, FILES warnings.filterwarnings("ignore", message="Glyph (.*) missing from current font") sns.set_theme(style="darkgrid") -logger = logging.getLogger() +logging.config.fileConfig("../logging.config") +logger = logging.getLogger("Logger") def create_parser() -> argparse.ArgumentParser: diff --git a/tiktok_hashtag_analysis/run_downloader.py b/tiktok_hashtag_analysis/run_downloader.py index 0746e24..3c51403 100644 --- a/tiktok_hashtag_analysis/run_downloader.py +++ b/tiktok_hashtag_analysis/run_downloader.py @@ -18,7 +18,8 @@ import global_data import file_methods import data_methods -logger = logging.getLogger() +logging.config.fileConfig("../logging.config") +logger = logging.getLogger("Logger") def create_parser() -> argparse.ArgumentParser: