Skip to content

Commit

Permalink
[analyzer] debug_analyzer log level for analyzer commands
Browse files Browse the repository at this point in the history
The debug_analyzer log level should be used only for printing analyzer
commands and their output.
  • Loading branch information
bruntib committed Feb 27, 2025
1 parent cc3b806 commit c86881f
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 50 deletions.
4 changes: 2 additions & 2 deletions analyzer/codechecker_analyzer/analysis_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ def handle_analysis_result(success, zip_file=zip_file):
result_file, action.source

except Exception as e:
LOG.debug_analyzer(str(e))
LOG.debug(str(e))
traceback.print_exc(file=sys.stdout)
return 1, False, reanalyzed, action.analyzer_type, None, \
action.source
Expand Down Expand Up @@ -830,7 +830,7 @@ def signal_handler(signum, _):
LOG.info("----==== Summary ====----")

for skp in skipped_actions:
LOG.debug_analyzer("%s is skipped", skp.source)
LOG.debug("%s is skipped", skp.source)

LOG.info("Total analyzed compilation commands: %d",
compile_cmd_count.analyze)
Expand Down
2 changes: 1 addition & 1 deletion analyzer/codechecker_analyzer/analyzers/analyzer_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def check_supported_analyzers(analyzers):
def construct_analyzer(buildaction, analyzer_config):
analyzer_type = buildaction.analyzer_type

LOG.debug_analyzer('Constructing %s analyzer.', analyzer_type)
LOG.debug('Constructing %s analyzer.', analyzer_type)
if analyzer_type in supported_analyzers:
analyzer = \
supported_analyzers[analyzer_type](analyzer_config, buildaction)
Expand Down
4 changes: 2 additions & 2 deletions analyzer/codechecker_analyzer/analyzers/clangsa/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,8 @@ def construct_config_handler(cls, args):
try:
cmdline_checkers = args.ordered_checkers
except AttributeError:
LOG.debug_analyzer('No checkers were defined in '
'the command line for %s', cls.ANALYZER_NAME)
LOG.debug('No checkers were defined in the command line for %s',
cls.ANALYZER_NAME)
cmdline_checkers = []

handler.initialize_checkers(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def generate_invocation_list(triple_arch, action, source, config):
{str(source_path): cmd},
width=maxsize, Dumper=LLVMComatibleYamlDumper)

LOG.debug_analyzer("Appending invocation list item '%s'", invocation_line)
LOG.debug("Appending invocation list item '%s'", invocation_line)

# Append the next entry into the invocation list yaml.
with invocation_list.open('a', encoding='utf-8', errors='ignore') as \
Expand Down
9 changes: 4 additions & 5 deletions analyzer/codechecker_analyzer/analyzers/clangtidy/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,10 +698,10 @@ def construct_config_handler(cls, args):
encoding='utf-8', errors='ignore') as tidy_config:
handler.checker_config = tidy_config.read()
except IOError as ioerr:
LOG.debug_analyzer(ioerr)
LOG.debug(ioerr)
except AttributeError as aerr:
# No clang tidy config file was given in the command line.
LOG.debug_analyzer(aerr)
LOG.debug(aerr)

handler.analyzer_config = analyzer_config

Expand All @@ -717,9 +717,8 @@ def construct_config_handler(cls, args):
try:
cmdline_checkers = args.ordered_checkers
except AttributeError:
LOG.debug_analyzer('No checkers were defined in '
'the command line for %s',
cls.ANALYZER_NAME)
LOG.debug('No checkers were defined in the command line for %s',
cls.ANALYZER_NAME)
cmdline_checkers = []

handler.initialize_checkers(
Expand Down
5 changes: 2 additions & 3 deletions analyzer/codechecker_analyzer/analyzers/cppcheck/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,8 @@ def construct_config_handler(cls, args):
try:
cmdline_checkers = args.ordered_checkers
except AttributeError:
LOG.debug_analyzer('No checkers were defined in '
'the command line for %s',
cls.ANALYZER_NAME)
LOG.debug('No checkers were defined in the command line for %s',
cls.ANALYZER_NAME)
cmdline_checkers = []

handler.initialize_checkers(
Expand Down
5 changes: 2 additions & 3 deletions analyzer/codechecker_analyzer/analyzers/gcc/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,8 @@ def construct_config_handler(cls, args):
try:
cmdline_checkers = args.ordered_checkers
except AttributeError:
LOG.debug_analyzer('No checkers were defined in '
'the command line for %s',
cls.ANALYZER_NAME)
LOG.debug('No checkers were defined in the command line for %s',
cls.ANALYZER_NAME)
cmdline_checkers = []

handler.initialize_checkers(
Expand Down
5 changes: 2 additions & 3 deletions analyzer/codechecker_analyzer/analyzers/infer/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,8 @@ def construct_config_handler(cls, args):
try:
cmdline_checkers = args.ordered_checkers
except AttributeError:
LOG.debug_analyzer('No checkers were defined in '
'the command line for %s',
cls.ANALYZER_NAME)
LOG.debug('No checkers were defined in the command line for %s',
cls.ANALYZER_NAME)
cmdline_checkers = []

handler.initialize_checkers(
Expand Down
7 changes: 3 additions & 4 deletions analyzer/codechecker_analyzer/buildlog/build_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def perform_build_command(logfile, command, keep_link, silent=False,
try:
original_env_file = os.environ.get('CODECHECKER_ORIGINAL_BUILD_ENV')
if original_env_file:
LOG.debug_analyzer('Loading original build env from: %s',
original_env_file)
LOG.debug('Loading original build env from: %s', original_env_file)

with open(original_env_file, 'rb') as env_file:
original_env = pickle.load(env_file, encoding='utf-8')
Expand Down Expand Up @@ -134,13 +133,13 @@ def perform_build_command(logfile, command, keep_link, silent=False,
"guidance.")
sys.exit(1)

LOG.debug_analyzer(log_env)
LOG.debug(log_env)
try:
ret_code = execute_buildcmd(command, silent, log_env)

if ret_code == 0:
LOG.info("Build finished successfully.")
LOG.debug_analyzer("The logfile is: %s", logfile)
LOG.debug("The logfile is: %s", logfile)
else:
LOG.info("Build failed.")
sys.exit(ret_code)
Expand Down
16 changes: 8 additions & 8 deletions analyzer/codechecker_analyzer/cmd/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -1328,14 +1328,14 @@ def main(args):
skipped=skipped_cmp_cmd_count,
removed_by_uniqueing=removed_during_uniqueing)

LOG.debug_analyzer("Total number of compile commands without "
"skipping or uniqueing: %d", compile_cmd_count.total)
LOG.debug_analyzer("Compile commands removed by uniqueing: %d",
compile_cmd_count.removed_by_uniqueing)
LOG.debug_analyzer("Compile commands skipped during log processing: %d",
compile_cmd_count.skipped)
LOG.debug_analyzer("Compile commands forwarded for analysis: %d",
compile_cmd_count.analyze)
LOG.debug("Total number of compile commands without "
"skipping or uniqueing: %d", compile_cmd_count.total)
LOG.debug("Compile commands removed by uniqueing: %d",
compile_cmd_count.removed_by_uniqueing)
LOG.debug("Compile commands skipped during log processing: %d",
compile_cmd_count.skipped)
LOG.debug("Compile commands forwarded for analysis: %d",
compile_cmd_count.analyze)

analyzer.perform_analysis(args, skip_handlers, filter_handlers,
rs_handler, actions, metadata_tool,
Expand Down
7 changes: 3 additions & 4 deletions analyzer/codechecker_analyzer/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def get_original_env():
try:
original_env_file = os.environ.get('CODECHECKER_ORIGINAL_BUILD_ENV')
if original_env_file:
LOG.debug_analyzer('Loading original build env from: %s',
original_env_file)
LOG.debug('Loading original build env from: %s', original_env_file)

with open(original_env_file, 'rb') as env_file:
original_env = pickle.load(env_file, encoding='utf-8')
Expand All @@ -76,7 +75,7 @@ def extend(path_env_extra, ld_lib_path_extra):

if path_env_extra:
extra_path = ':'.join(path_env_extra)
LOG.debug_analyzer(
LOG.debug(
'Extending PATH environment variable with: ' + extra_path)

try:
Expand All @@ -86,7 +85,7 @@ def extend(path_env_extra, ld_lib_path_extra):

if ld_lib_path_extra:
extra_lib = ':'.join(ld_lib_path_extra)
LOG.debug_analyzer(
LOG.debug(
'Extending LD_LIBRARY_PATH environment variable with: ' +
extra_lib)
try:
Expand Down
14 changes: 7 additions & 7 deletions analyzer/codechecker_analyzer/host_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def check_analyzer(compiler_bin):
Simple check if clang is available.
"""
clang_version_cmd = [compiler_bin, '--version']
LOG.debug_analyzer(' '.join(clang_version_cmd))
LOG.debug(' '.join(clang_version_cmd))
environ = analyzer_context.get_context().get_env_for_bin(
compiler_bin)
try:
Expand Down Expand Up @@ -56,7 +56,7 @@ def has_analyzer_config_option(clang_bin, config_option_name):
"""Check if an analyzer config option is available."""
cmd = [clang_bin, "-cc1", "-analyzer-config-help"]

LOG.debug('run: "%s"', ' '.join(cmd))
LOG.debug_analyzer('run: "%s"', ' '.join(cmd))
context = analyzer_context.get_context()

try:
Expand All @@ -67,8 +67,8 @@ def has_analyzer_config_option(clang_bin, config_option_name):
env=context.get_env_for_bin(clang_bin),
encoding="utf-8", errors="ignore")
out, err = proc.communicate()
LOG.debug("stdout:\n%s", out)
LOG.debug("stderr:\n%s", err)
LOG.debug_analyzer("stdout:\n%s", out)
LOG.debug_analyzer("stderr:\n%s", err)

match = re.search(config_option_name, out)
if match:
Expand All @@ -91,7 +91,7 @@ def has_analyzer_option(clang_bin, feature):
cmd.extend(feature)
cmd.extend([input_file.name, "-o", "-"])

LOG.debug('run: "%s"', ' '.join(cmd))
LOG.debug_analyzer('run: "%s"', ' '.join(cmd))
try:
proc = subprocess.Popen(
cmd,
Expand All @@ -100,8 +100,8 @@ def has_analyzer_option(clang_bin, feature):
env=analyzer_context.get_context().get_env_for_bin(clang_bin),
encoding="utf-8", errors="ignore")
out, err = proc.communicate()
LOG.debug("stdout:\n%s", out)
LOG.debug("stderr:\n%s", err)
LOG.debug_analyzer("stdout:\n%s", out)
LOG.debug_analyzer("stderr:\n%s", err)

return proc.returncode == 0
except OSError:
Expand Down
6 changes: 3 additions & 3 deletions analyzer/codechecker_analyzer/pre_analysis_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def collect_statistics(action, source, clangsa_config, statistics_data):
ret_code, analyzer_out, analyzer_err = \
analyzer_base.SourceAnalyzer.run_proc(cmd)

LOG.debug(analyzer_out)
LOG.debug(analyzer_err)
LOG.debug_analyzer(analyzer_out)
LOG.debug_analyzer(analyzer_err)
if ret_code:
LOG.error("Failed to collect statistics for %s", source)
return ret_code
Expand Down Expand Up @@ -140,7 +140,7 @@ def pre_analyze(params):
statistics_data)

except Exception as ex:
LOG.debug_analyzer(str(ex))
LOG.debug(str(ex))
traceback.print_exc(file=sys.stdout)
raise

Expand Down
6 changes: 2 additions & 4 deletions web/codechecker_web/shared/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ def extend(path_env_extra, ld_lib_path_extra):

if path_env_extra:
extra_path = ':'.join(path_env_extra)
LOG.debug_analyzer(
'Extending PATH environment variable with: ' + extra_path)
LOG.debug('Extending PATH environment variable with: %s', extra_path)

try:
new_env['PATH'] = extra_path + ':' + new_env['PATH']
Expand All @@ -91,8 +90,7 @@ def extend(path_env_extra, ld_lib_path_extra):

if ld_lib_path_extra:
extra_lib = ':'.join(ld_lib_path_extra)
LOG.debug_analyzer(
'Extending LD_LIBRARY_PATH environment variable with: ' +
LOG.debug('Extending LD_LIBRARY_PATH environment variable with: %s',
extra_lib)
try:
original_ld_library_path = new_env['LD_LIBRARY_PATH']
Expand Down

0 comments on commit c86881f

Please sign in to comment.