From 5af208a12be6798f09692421398451bca91ba646 Mon Sep 17 00:00:00 2001 From: Laszlo Nagy Date: Mon, 11 Apr 2016 23:04:25 +1000 Subject: [PATCH] log analyzer output in runner module --- libscanbuild/analyze.py | 11 +++-------- libscanbuild/runner.py | 13 ++++++++++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/libscanbuild/analyze.py b/libscanbuild/analyze.py index 7f82686..c765cc9 100644 --- a/libscanbuild/analyze.py +++ b/libscanbuild/analyze.py @@ -21,7 +21,7 @@ import multiprocessing from libscanbuild import initialize_logging, tempdir from libscanbuild import command_entry_point, wrapper_entry_point -from libscanbuild.runner import run +from libscanbuild.runner import run, logging_analyzer_output from libscanbuild.intercept import capture from libscanbuild.report import report_directory, document from libscanbuild.clang import get_checkers @@ -116,10 +116,7 @@ def exclude(filename): # when verbose output requested execute sequentially pool = multiprocessing.Pool(1 if args.verbose > 2 else None) for current in pool.imap_unordered(run, generator): - if current is not None: - # display error message from the static analyzer - for line in current['error_output']: - logging.info(line.rstrip()) + logging_analyzer_output(current) pool.close() pool.join() @@ -174,9 +171,7 @@ def analyze_build_wrapper(**kwargs): logging.debug('analyzer parameters %s', parameters) current = run(parameters) # display error message from the static analyzer - if current is not None: - for line in current['error_output']: - logging.info(line.rstrip()) + logging_analyzer_output(current) def analyzer_params(args): diff --git a/libscanbuild/runner.py b/libscanbuild/runner.py index 628ad90..f0e9543 100644 --- a/libscanbuild/runner.py +++ b/libscanbuild/runner.py @@ -16,7 +16,7 @@ from libscanbuild.clang import get_version, get_arguments from libscanbuild.shell import decode -__all__ = ['run'] +__all__ = ['run', 'logging_analyzer_output'] # To have good results from static analyzer certain compiler options shall be # omitted. The compiler flag filtering only affects the static analyzer run. @@ -311,3 +311,14 @@ def classify_parameters(command): result['flags'].append(arg) return result + + +def logging_analyzer_output(entry): + """ Write analyzer output to log. + + :param entry: contains the analyzer execution result or None if the + analyzer was not executed. """ + + if entry and 'error_output' in entry: + for line in entry['error_output']: + logging.info(line.rstrip())