pelican icon indicating copy to clipboard operation
pelican copied to clipboard

Warning and Error logs messages show wrong source

Open copperchin opened this issue 2 years ago • 0 comments

  • [x] I have read the Filing Issues and subsequent “How to Get Help” sections of the documentation.

  • [x] I have searched the issues (including closed ones) and believe that this is not a duplicate.

  • OS version and name: Ubuntu 18.04.4 LTS (bionic) ; via WSL 1 on Windows 10

  • Python version: 3.8.0

  • Pelican version: 4.8.0

Issue

Any time an error or warning message is logged, the logger reports the message as coming from the log.py instead of the true source of the message.

Very simple test is to add the following to pelican.conf:

import logging
logging.warning("This is a warning")
logging.error("This is an error.")

Then run the pelican listener in the terminal: pelican -l

which yields:

[10:24:40] WARNING  This is a warning                                       log.py:91
           ERROR    This is an error.                                       log.py:96

whereas I'd expect this:

[10:19:03] WARNING  This is a warning                                       pelicanconf.py:2
           ERROR    This is an error.                                       pelicanconf.py:3

This appears to be because FatalLogger overrides the Logger error and warning methods: first checking whether to raise a RuntimeError, then making a call to the log method with super().

I'm proposing a fix which would work by making the fatal check in the logger handler, rather than redefining the Logger's logging methods.

copperchin avatar Sep 05 '22 17:09 copperchin