Skip to content

Commit

Permalink
Add logging tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
PapyChacal committed Oct 11, 2023
1 parent e2bc198 commit 8e8f127
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion devito/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,24 @@
# 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,
'PERF': PERF,
'INFO': INFO,
'WARNING': WARNING,
'ERROR': ERROR,
'CRITICAL': CRITICAL
'CRITICAL': CRITICAL,
'BENCH': BENCH
}

NOCOLOR = '%s'
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion devito/operator/profiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 8e8f127

Please sign in to comment.