Better error logging if a plugin refuses to load

This commit is contained in:
MinchinWeb 2024-01-14 13:45:51 -07:00
commit f0beb81a97
2 changed files with 8 additions and 3 deletions

View file

@ -80,7 +80,8 @@ class Pelican:
plugin.register() plugin.register()
self.plugins.append(plugin) self.plugins.append(plugin)
except Exception as e: except Exception as e:
logger.error("Cannot register plugin `%s`\n%s", name, e) logger.error("Cannot register plugin `%s`\n%s", name, e, stacklevel=3)
print(e.stacktrace)
self.settings["PLUGINS"] = [get_plugin_name(p) for p in self.plugins] self.settings["PLUGINS"] = [get_plugin_name(p) for p in self.plugins]

View file

@ -88,12 +88,16 @@ class FatalLogger(LimitLogger):
# adding `stacklevel=2` means that the displayed filename and line number # adding `stacklevel=2` means that the displayed filename and line number
# will match the "original" calling location, rather than the wrapper here # will match the "original" calling location, rather than the wrapper here
def warning(self, *args, **kwargs): def warning(self, *args, **kwargs):
super().warning(*args, stacklevel=2, **kwargs) if "stacklevel" not in kwargs.keys():
kwargs["stacklevel"] = 2
super().warning(*args, **kwargs)
if FatalLogger.warnings_fatal: if FatalLogger.warnings_fatal:
raise RuntimeError("Warning encountered") raise RuntimeError("Warning encountered")
def error(self, *args, **kwargs): def error(self, *args, **kwargs):
super().error(*args, stacklevel=2, **kwargs) if "stacklevel" not in kwargs.keys():
kwargs["stacklevel"] = 2
super().error(*args, **kwargs)
if FatalLogger.errors_fatal: if FatalLogger.errors_fatal:
raise RuntimeError("Error encountered") raise RuntimeError("Error encountered")