diff --git a/infer/lib/python/BuckAnalyze b/infer/lib/python/BuckAnalyze index 3783e8159..cc8268657 100755 --- a/infer/lib/python/BuckAnalyze +++ b/infer/lib/python/BuckAnalyze @@ -432,7 +432,7 @@ if __name__ == '__main__': help='Build targets to analyze') args = parser.parse_args() - utils.configure_logging(args.verbose) + utils.configure_logging(args) timer = utils.Timer(logging.info) temp_files = [] diff --git a/infer/lib/python/infer b/infer/lib/python/infer index 391db8e50..452136a35 100755 --- a/infer/lib/python/infer +++ b/infer/lib/python/infer @@ -32,9 +32,6 @@ MODULE_TO_COMMAND = { 'mvn': ['mvn'] } -FORMAT = '[%(levelname)s] %(message)s' -LOG_FILE = 'toplevel.log' - def get_commands(): """Return all commands that are supported.""" #flatten and dedup the list of commands @@ -95,16 +92,6 @@ def create_argparser(parents=[]): return parser -def configure_logging(infer_dir, log_to_stderr): - if log_to_stderr: - logging.basicConfig(level=logging.INFO, format=FORMAT) - else: - logging.basicConfig(level=logging.INFO, - format=FORMAT, - filename=os.path.join(infer_dir, LOG_FILE), - filemode='w') - - def main(): to_parse, cmd = split_args_to_parse() # get the module name (if any), then load it @@ -132,7 +119,7 @@ def main(): if imported_module: analyze.create_results_dir(args.infer_out) - configure_logging(args.infer_out, args.log_to_stderr) + utils.configure_logging(args) logging.info('Running command %s', ' '.join(sys.argv)) logging.info('Path to infer script %s (%s)', __file__, os.path.realpath(__file__)) diff --git a/infer/lib/python/inferlib/analyze.py b/infer/lib/python/inferlib/analyze.py index ae53ea903..1c4b7499d 100644 --- a/infer/lib/python/inferlib/analyze.py +++ b/infer/lib/python/inferlib/analyze.py @@ -101,9 +101,6 @@ base_group.add_argument('-l', '--llvm', action='store_true', help='''[experimental] Analyze C or C++ file using the experimental LLVM frontend''') -base_group.add_argument('--log_to_stderr', action='store_true', - help='''When set, all logging will go to stderr instead - of the log file''') base_parser.add_argument('-v', '--version', help='''Print the version of Infer and exit''', action=VersionAction) @@ -247,8 +244,6 @@ class Infer: help_exit('Unknown analysis mode \"{0}\"' .format(self.args.analyzer)) - utils.configure_logging(self.args.debug) - self.javac = jwlib.CompilerCall(javac_args) if not self.javac.args.version: diff --git a/infer/lib/python/inferlib/config.py b/infer/lib/python/inferlib/config.py index 31ceb7449..c482adb77 100644 --- a/infer/lib/python/inferlib/config.py +++ b/infer/lib/python/inferlib/config.py @@ -45,6 +45,8 @@ BUGS_FILENAME = 'bugs.txt' IOS_CAPTURE_ERRORS = 'errors' IOS_BUILD_OUTPUT = 'build_output' +LOG_FILE = 'toplevel.log' + BUCK_INFER_OUT = 'infer' CLASS_SOURCE_MAP_OUTPUT_FILENAME_OPTION = 'classSourceMapOutputFilename' diff --git a/infer/lib/python/inferlib/utils.py b/infer/lib/python/inferlib/utils.py index fe2add660..5a3f72aa5 100644 --- a/infer/lib/python/inferlib/utils.py +++ b/infer/lib/python/inferlib/utils.py @@ -58,7 +58,7 @@ def locale_csv_reader(iterable, dialect='excel', **kwargs): yield [unicode(cell, config.LOCALE) for cell in row] -def configure_logging(debug, quiet=False): +def configure_logging(args): """Configures the default logger. This can be called only once and has to be called before any logging is done. """ @@ -69,12 +69,14 @@ def configure_logging(debug, quiet=False): logging.log(logging.TIMING, msg, *args, **kwargs) logging.timing = timing - if quiet: - logging.basicConfig(level=logging.TIMING, format=FORMAT) - elif not debug: - logging.basicConfig(level=logging.INFO, format=FORMAT) - else: + if args.debug: logging.basicConfig(level=logging.DEBUG, format=DEBUG_FORMAT) + else: + logging.basicConfig(level=logging.INFO, + format=FORMAT, + filename=os.path.join(args.infer_out, + config.LOG_FILE), + filemode='w') def elapsed_time(start_time):