From bc06f52905eae1f8ce4c5ee83b62764c7af14f57 Mon Sep 17 00:00:00 2001 From: Zafer Balkan Date: Sun, 17 Sep 2023 15:52:41 +0300 Subject: [PATCH] Improved logging --- src/hunter.py | 5 +++++ src/panhunt.py | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hunter.py b/src/hunter.py index a97327b..42c6736 100644 --- a/src/hunter.py +++ b/src/hunter.py @@ -1,3 +1,4 @@ +import logging import os from typing import Generator, Optional @@ -38,6 +39,8 @@ def get_scannable_files(self) -> Generator[tuple, None, None]: docs_found = 0 root_total_items: int = 0 + logging.info(f"Search base: {self.__conf.search_dir}") + for root, sub_ds, files in os.walk(top=self.__conf.search_dir): # list[str] sub_dirs: list = [check_dir for check_dir in sub_ds if os.path.join( @@ -64,8 +67,10 @@ def get_scannable_files(self) -> Generator[tuple, None, None]: yield docs_found, root_total_items, root_items_completed self.__all_files += doc_files + logging.info(f"Total number of files: {len(self.__all_files)}") # def scan_files(self) -> Generator[tuple[int, int], None, None]: + def scan_files(self) -> Generator[tuple, None, None]: """ Searches files in doc_files list for regular expressions""" diff --git a/src/panhunt.py b/src/panhunt.py index 4f3098b..cb3274d 100644 --- a/src/panhunt.py +++ b/src/panhunt.py @@ -24,6 +24,7 @@ from pbar import DocProgressbar from report import Report +APP_NAME: str = 'PANhunt' APP_VERSION: str = '1.4' @@ -124,7 +125,7 @@ def main() -> None: # datefmt="%Y-%m-%dT%H:%M:%S%z", # level=logging.INFO) - logging.basicConfig(filename=os.path.join(panutils.get_root_dir(), 'PANhunt.log'), + logging.basicConfig(filename=os.path.join(panutils.get_root_dir(), f'{APP_NAME}.log'), format='%(asctime)s:%(levelname)s:%(message)s', datefmt="%Y-%m-%dT%H:%M:%S%z", level=logging.INFO)