Skip to content

Commit

Permalink
Avoid erroring when debug flag is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
dspinellis committed Jun 21, 2024
1 parent b958aee commit f2a728d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/alexandria3k/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ def log(flag, message, flush=True, end="\n"):
:param message: Message to output.
:type message: str
"""
if not flag in enabled_flags:
return
# The CSV output closes stdout, so check and raise.
if output.closed:
# Cannot use Alexandria3kError here, due to circular import
raise ValueError(
"Attempting to log onto closed stdout. Log to stderr."
)
if flag in enabled_flags:
print(message, file=output, flush=flush, end=end)
print(message, file=output, flush=flush, end=end)

0 comments on commit f2a728d

Please sign in to comment.