From 9c9323b170df3ab9a30c8db1d7d39987018b854f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 8 Mar 2018 11:00:09 +0100 Subject: [PATCH] Log instead of print --- blender_asset_tracer/cli/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/blender_asset_tracer/cli/__init__.py b/blender_asset_tracer/cli/__init__.py index 113da77..3078163 100644 --- a/blender_asset_tracer/cli/__init__.py +++ b/blender_asset_tracer/cli/__init__.py @@ -35,6 +35,10 @@ def cli_main(): from blender_asset_tracer import __version__ log = logging.getLogger(__name__) + + # Make sure the things we log in our local logger are visible + if args.profile and args.loglevel > logging.INFO: + log.setLevel(logging.INFO) log.debug('Running BAT version %s', __version__) if not args.func: @@ -45,12 +49,13 @@ def cli_main(): import cProfile prof_fname = 'bam.prof' + log.info('Running profiler') cProfile.runctx('args.func(args)', globals=globals(), locals=locals(), filename=prof_fname) - print('Profiler exported data to', prof_fname) - print('Run "pyprof2calltree -i %r -k" to convert and open in KCacheGrind' % prof_fname) + log.info('Profiler exported data to %s', prof_fname) + log.info('Run "pyprof2calltree -i %r -k" to convert and open in KCacheGrind', prof_fname) else: retval = args.func(args) duration = datetime.timedelta(seconds=time.time() - start_time)