From 595f8cb0a60983c600e19f3156e220ac4105ca78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 7 Mar 2018 17:14:44 +0100 Subject: [PATCH] Log duration of CLI commands --- blender_asset_tracer/cli/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/blender_asset_tracer/cli/__init__.py b/blender_asset_tracer/cli/__init__.py index 966cda7..113da77 100644 --- a/blender_asset_tracer/cli/__init__.py +++ b/blender_asset_tracer/cli/__init__.py @@ -1,7 +1,9 @@ """Commandline entry points.""" import argparse +import datetime import logging +import time from . import common, pack, list_deps @@ -38,6 +40,7 @@ def cli_main(): if not args.func: parser.error('No subcommand was given') + start_time = time.time() if args.profile: import cProfile @@ -49,7 +52,9 @@ def cli_main(): print('Profiler exported data to', prof_fname) print('Run "pyprof2calltree -i %r -k" to convert and open in KCacheGrind' % prof_fname) else: - return args.func(args) + retval = args.func(args) + duration = datetime.timedelta(seconds=time.time() - start_time) + log.info('Command took %s to complete', duration) def config_logging(args):