Skip to content

Commit d06b275

Browse files
committed
logging: Corner case for PETSc
1 parent a8f11a7 commit d06b275

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

devito/logger.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ def log(msg, level=INFO, *args, **kwargs):
134134
ERROR, CRITICAL``.
135135
"""
136136
color = COLORS[level] if sys.stdout.isatty() and sys.stderr.isatty() else '%s'
137+
# TODO: Think about a proper fix for this:
138+
# When running with PETSc, `PetscFinalize` will helpfully close the stream
139+
# that is being used for logging before all messages are displayed. Specifically
140+
# the operator `info` logging.
141+
if logger.handlers[0] is stream_handler and logger.handlers[0].stream.closed:
142+
logger.handlers[0].stream = sys.stdout
137143
logger.log(level, color % msg, *args, **kwargs)
138144

139145

0 commit comments

Comments
 (0)