Skip to content

Commit

Permalink
Ensure proper log line/filename in warning/errors
Browse files Browse the repository at this point in the history
Fix #3037
  • Loading branch information
copperchin committed Sep 5, 2022
1 parent 062144a commit 023d26c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
3 changes: 3 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Release type: bugfix

Address issue with FatalLogger overriding the source of warning and error logs.
23 changes: 16 additions & 7 deletions pelican/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,24 @@ class FatalLogger(LimitLogger):
warnings_fatal = False
errors_fatal = False

def warning(self, *args, **kwargs):
super().warning(*args, **kwargs)
def callHandlers(self, record):
"""
Raise RuntimeError if log level is higher than acceptable.
Level limit set via the ``--fatal`` flag when running pelican.
"""
super().callHandlers(record)
level_limit = None

if FatalLogger.warnings_fatal:
raise RuntimeError('Warning encountered')
level_limit = logging.WARNING
elif FatalLogger.errors_fatal:
level_limit = logging.ERROR
else:
return

def error(self, *args, **kwargs):
super().error(*args, **kwargs)
if FatalLogger.errors_fatal:
raise RuntimeError('Error encountered')
if record.levelno == level_limit:
raise RuntimeError('%s encountered' % record.levelname)


logging.setLoggerClass(FatalLogger)
Expand Down

0 comments on commit 023d26c

Please sign in to comment.