From cd3048d4cf6d69ba95bf22ca55a2e9ddd6c91bff Mon Sep 17 00:00:00 2001 From: Kernc Date: Fri, 5 Jun 2020 01:48:11 +0200 Subject: [PATCH 1/3] Force root logger to be of FatalLogger class This enforces FatalLogger policy upon pelican plugins that might contain codes such as: import logging log = logging.getLogger() log.warning(...) # or logging.warning(...) --- pelican/log.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pelican/log.py b/pelican/log.py index 8b7869ac..325ac3ea 100644 --- a/pelican/log.py +++ b/pelican/log.py @@ -165,6 +165,8 @@ class FatalLogger(LimitLogger): logging.setLoggerClass(FatalLogger) +# force root logger to be of our preferred class +logging.getLogger().__class__ = FatalLogger def supports_color(): From 20067da9f52b56510c3a510b9fe175b60b344543 Mon Sep 17 00:00:00 2001 From: Kernc Date: Fri, 5 Jun 2020 14:24:55 +0200 Subject: [PATCH 2/3] Document how to logging in plugins --- docs/plugins.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/plugins.rst b/docs/plugins.rst index 76a88507..a4ef91d6 100644 --- a/docs/plugins.rst +++ b/docs/plugins.rst @@ -76,10 +76,14 @@ section. The only rule to follow for plugins is to define a ``register`` callable, in which you map the signals to your plugin logic. Let's take a simple example:: + import logging + from pelican import signals + log = logging.getLogger(__name__) + def test(sender): - print("{} initialized !!".format(sender)) + log.debug("%s initialized !!", sender) def register(): signals.initialized.connect(test) From d6623c642fc6999fb57a5bbf8ce5a11c03c752de Mon Sep 17 00:00:00 2001 From: Kernc Date: Fri, 5 Jun 2020 14:27:37 +0200 Subject: [PATCH 3/3] Docs: minor fix code block indent --- docs/settings.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/settings.rst b/docs/settings.rst index 5b255dcc..2b99072f 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -742,8 +742,8 @@ Time and Date .. parsed-literal:: - LOCALE = ('usa', 'jpn', # On Windows - 'en_US', 'ja_JP' # On Unix/Linux + LOCALE = ('usa', 'jpn', # On Windows + 'en_US', 'ja_JP' # On Unix/Linux ) For a list of available locales refer to `locales on Windows`_ or on