Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[server] More info logs at server for storage API request #3509

Merged
merged 1 commit into from
Nov 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -922,7 +936,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 @@ -943,6 +958,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 @@ -1013,9 +1032,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 @@ -1034,11 +1053,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 @@ -1091,11 +1112,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