Skip to content

Commit

Permalink
log analyzer output in runner module
Browse files Browse the repository at this point in the history
  • Loading branch information
rizsotto committed Apr 16, 2016
1 parent de73dcc commit 5af208a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
11 changes: 3 additions & 8 deletions libscanbuild/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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):
Expand Down
13 changes: 12 additions & 1 deletion libscanbuild/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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())

0 comments on commit 5af208a

Please sign in to comment.