From 52f70504883f880531f7659e29fc3cb7d96ae373 Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Apr 17 2019 09:39:14 +0000 Subject: New global CLI option --traceback Option --traceback controls when to print the full traceback and when to just print a single line of message raised from underlying code. The latter is default. For debug purpose, add --traceback to command line. Signed-off-by: Chenxiong Qi --- diff --git a/ursa_major/cli.py b/ursa_major/cli.py index 39b088d..8a18dae 100644 --- a/ursa_major/cli.py +++ b/ursa_major/cli.py @@ -115,6 +115,11 @@ def main(args=None): default=DEFAULT_TAG_CONFIG_FILE, type=validate_json_file, help='tag config file, default to "ursa-major.json" in current working directory') + global_args_parser.add_argument( + '--traceback', + action='store_true', + default=False, + help='Print traceback if something wrong that ursa-major cannot do the job.') module_config_parser = argparse.ArgumentParser(add_help=False) module_config_parser.add_argument( @@ -280,5 +285,8 @@ def main(args=None): except KeyboardInterrupt: sys.exit(0) except Exception as e: - log.exception(str(e)) + if args.traceback: + log.exception(str(e)) + else: + log.error(str(e)) sys.exit(1)