jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/415248 )
Change subject: logging.py: Add a last resort logging handler for python 2 ......................................................................
logging.py: Add a last resort logging handler for python 2
Python 3 loggers already have a lastResort handler.[1] This patch adds a similar one for them in Python 2.
The config uses the warning logger, but its handler is not initialized at that point. Loggers get initialized inside bot.py, but we cannot use those initializer inside config2.py because of circular dependency issue.
[1]: https://docs.python.org/3.2/library/logging.html#logging.lastResort
Bug: T188417 Change-Id: I24ce4de6c4bec5ece6401aa14227add713c60659 --- M pywikibot/logging.py 1 file changed, 5 insertions(+), 1 deletion(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/logging.py b/pywikibot/logging.py index e576d3b..fe66905 100644 --- a/pywikibot/logging.py +++ b/pywikibot/logging.py @@ -12,7 +12,8 @@ import sys
# logging levels -from logging import DEBUG, INFO, WARNING, ERROR, CRITICAL +from logging import DEBUG, INFO, WARNING, ERROR, CRITICAL, StreamHandler + STDOUT = 16 VERBOSE = 18 INPUT = 25 @@ -73,6 +74,9 @@ else: logger = logging.getLogger("pywiki")
+ if not logger.handlers: # lastResort for Python 2 (T188417) + logger.handlers.append(StreamHandler()) + # invoke any init routines if _init_routines: _init()
pywikibot-commits@lists.wikimedia.org