diff --git a/picireny/cli.py b/picireny/cli.py index de17937..2275a64 100644 --- a/picireny/cli.py +++ b/picireny/cli.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016-2022 Renata Hodovan, Akos Kiss. +# Copyright (c) 2016-2023 Renata Hodovan, Akos Kiss. # # Licensed under the BSD 3-Clause License # . @@ -120,11 +120,12 @@ def process_args(args): def log_tree(title, hdd_tree): - logger.debug('%s\n\theight: %s\n\tshape: %s\n\tnodes: %s\n', - title, - info.height(hdd_tree), - ', '.join(str(cnt) for cnt in info.shape(hdd_tree)), - ', '.join(f'{cnt} {ty}' for ty, cnt in sorted(info.count(hdd_tree).items()))) + if logger.isEnabledFor(logging.DEBUG): + logger.debug('%s\n\theight: %s\n\tshape: %s\n\tnodes: %s\n', + title, + info.height(hdd_tree), + ', '.join(str(cnt) for cnt in info.shape(hdd_tree)), + ', '.join(f'{cnt} {ty}' for ty, cnt in sorted(info.count(hdd_tree).items()))) logger.trace('%r', hdd_tree) diff --git a/picireny/hdd.py b/picireny/hdd.py index febe42e..459dc8e 100644 --- a/picireny/hdd.py +++ b/picireny/hdd.py @@ -1,5 +1,5 @@ # Copyright (c) 2007 Ghassan Misherghi. -# Copyright (c) 2016-2022 Renata Hodovan, Akos Kiss. +# Copyright (c) 2016-2023 Renata Hodovan, Akos Kiss. # Copyright (c) 2021 Daniel Vince # # Licensed under the BSD 3-Clause License @@ -73,7 +73,8 @@ def _collect_level_nodes(node, current_level): if not level_nodes: continue - logger.info('Checking level %d / %d ...', level, height(hdd_tree)) + if logger.isEnabledFor(logging.INFO): + logger.info('Checking level %d / %d ...', level, height(hdd_tree)) for trans_cnt, transformation in enumerate(transformations): hdd_tree, transformed = transformation(hdd_tree, level_nodes, diff --git a/picireny/hoist.py b/picireny/hoist.py index 4d9f494..bb699d9 100644 --- a/picireny/hoist.py +++ b/picireny/hoist.py @@ -80,7 +80,8 @@ def _collect_hoistables(desc): for run in itertools.count(): logger.info('Run #%d', run) logger.info('\tMapping size: %d', len(mapping)) - logger.debug('\tMapping: %r', {c.id: m.id for c, m in mapping.items()}) + if logger.isEnabledFor(logging.DEBUG): + logger.debug('\tMapping: %r', {c.id: m.id for c, m in mapping.items()}) for i, (c, m) in enumerate((c, m) for c in config for m in collect_hoistables(mapping.get(c, c))): new_mapping = mapping.copy()