From 8e8f127710e2bfdbe68ffcfd7a1749dc1a354436 Mon Sep 17 00:00:00 2001 From: Emilien Bauer Date: Wed, 11 Oct 2023 10:18:48 +0100 Subject: [PATCH] Add logging tweaks. --- devito/logger.py | 8 +++++++- devito/operator/profiling.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/devito/logger.py b/devito/logger.py index 2a7eed95a6..b104efd34b 100644 --- a/devito/logger.py +++ b/devito/logger.py @@ -16,12 +16,15 @@ # Add extra logging levels (note: INFO has value=20, WARNING has value=30) DEBUG = logging.DEBUG PERF = 19 +BENCH = logging.DEBUG INFO = logging.INFO WARNING = logging.WARNING ERROR = logging.ERROR CRITICAL = logging.CRITICAL logging.addLevelName(PERF, "PERF") +logging.addLevelName(BENCH, "BENCH") + logger_registry = { 'DEBUG': DEBUG, @@ -29,7 +32,8 @@ 'INFO': INFO, 'WARNING': WARNING, 'ERROR': ERROR, - 'CRITICAL': CRITICAL + 'CRITICAL': CRITICAL, + 'BENCH': BENCH } NOCOLOR = '%s' @@ -133,6 +137,8 @@ def warning(msg, *args, **kwargs): def error(msg, *args, **kwargs): log(msg, ERROR, *args, **kwargs) +def bench(msg, *args, **kwargs): + log(msg, BENCH, *args, **kwargs) def debug(msg, *args, **kwargs): log(msg, DEBUG, *args, **kwargs) diff --git a/devito/operator/profiling.py b/devito/operator/profiling.py index f7633a7404..2d576df5e5 100644 --- a/devito/operator/profiling.py +++ b/devito/operator/profiling.py @@ -460,7 +460,7 @@ def timings(self): def create_profile(name): """Create a new Profiler.""" - if configuration['log-level'] in ['DEBUG', 'PERF'] and \ + if configuration['log-level'] in ['DEBUG', 'PERF', 'BENCH'] and \ configuration['profiling'] == 'basic': # Enforce performance profiling in DEBUG mode level = 'advanced'