Skip to content

Commit

Permalink
[server] More info logs at server for storage API request
Browse files Browse the repository at this point in the history
  • Loading branch information
csordasmarton committed Nov 18, 2021
1 parent 11dcdc7 commit a46603a
Showing 1 changed file with 35 additions and 14 deletions.
49 changes: 35 additions & 14 deletions web/server/codechecker_server/api/mass_store_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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)

Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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()

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit a46603a

Please sign in to comment.