diff --git a/web/server/codechecker_server/api/mass_store_run.py b/web/server/codechecker_server/api/mass_store_run.py index 42885c711d..a126691f8b 100644 --- a/web/server/codechecker_server/api/mass_store_run.py +++ b/web/server/codechecker_server/api/mass_store_run.py @@ -48,6 +48,20 @@ LOG = get_logger('server') +class LogTask: + def __init__(self, run_name: str, message: str): + self.__run_name = run_name + self.__msg = message + self.__start_time = time.time() + + def __enter__(self, *args): + LOG.info("[%s] %s...", self.__run_name, self.__msg) + + def __exit__(self, *args): + LOG.info("[%s] %s done... (duration: %s sec)", self.__run_name, + self.__msg, round(time.time() - self.__start_time, 2)) + + # FIXME: when these types are introduced we need to use those. SourceLineComments = List[Any] @@ -940,7 +954,8 @@ def get_skip_handler( enabled_checkers: Set[str] = set() disabled_checkers: Set[str] = set() - # Processing PList files. + # Processing analyzer result files. + processed_result_file_count = 0 for root_dir_path, _, report_file_paths in os.walk(report_dir): LOG.debug("Get reports from '%s' directory", root_dir_path) @@ -961,6 +976,10 @@ def get_skip_handler( report_file_path, session, source_root, run_id, file_path_to_id, run_history_time, skip_handler, hash_map_reports) + processed_result_file_count += 1 + + LOG.info("[%s] Processed %d analyzer result file(s).", self.__name, + processed_result_file_count) # If a checker was found in a plist file it can not be disabled so we # will add this to the enabled checkers list and remove this checker @@ -1031,9 +1050,9 @@ def store(self) -> int: with TemporaryDirectory( dir=self.__context.codechecker_workspace ) as zip_dir: - LOG.info("[%s] Unzip storage file...", self.__name) - zip_size = unzip(self.__b64zip, zip_dir) - LOG.info("[%s] Unzip storage file done.", self.__name) + with LogTask(run_name=self.__name, + message="Unzip storage file"): + zip_size = unzip(self.__b64zip, zip_dir) if zip_size == 0: raise codechecker_api_shared.ttypes.RequestFailed( @@ -1052,11 +1071,13 @@ def store(self) -> int: filename_to_hash = \ util.load_json_or_empty(content_hash_file, {}) - LOG.info("[%s] Store source files...", self.__name) - file_path_to_id = self.__store_source_files( - source_root, filename_to_hash) - self.__add_blame_info(blame_root, filename_to_hash) - LOG.info("[%s] Store source files done.", self.__name) + with LogTask(run_name=self.__name, + message="Store source files"): + LOG.info("[%s] Storing %d source file(s).", self.__name, + len(filename_to_hash.keys())) + file_path_to_id = self.__store_source_files( + source_root, filename_to_hash) + self.__add_blame_info(blame_root, filename_to_hash) run_history_time = datetime.now() @@ -1109,11 +1130,11 @@ def store(self) -> int: run_id, update_run = self.__add_or_update_run( session, run_history_time) - LOG.info("[%s] Store reports...", self.__name) - self.__store_reports( - session, report_dir, source_root, run_id, - file_path_to_id, run_history_time) - LOG.info("[%s] Store reports done.", self.__name) + with LogTask(run_name=self.__name, + message="Store reports"): + self.__store_reports( + session, report_dir, source_root, run_id, + file_path_to_id, run_history_time) self.finish_checker_run(session, run_id)