Page MenuHomePhabricator

Pywikibot: avoid double logging of output
Closed, ResolvedPublicBUG REPORT


When printing output, if the log level is INFO or above, the output is logged twice:

#! /usr/bin/env python3

import pywikibot
import logging

pywikibot.output("Normal output")

logger = logging.getLogger('pywiki')

# set for other logging purposes

pywikibot.output("Double output")


pywikibot.output("No output")


Normal output
Double output
INFO:pywiki:Double output

The upshot of this is that it seems impossible to use the Python logging module at all without causing either double logging (which gets very verbose when outputting something like a diff), or no logging at all, if the log level is higher than INFO.

It would be helpful if:

  • The double logging can be avoided, and also
  • Output can be retained even if the log level is > INFO. For example, I might not want INFO level log spew, but I still want to see things printed by, say, showDiff.

Event Timeline

Xqt triaged this task as Medium priority.May 2 2021, 6:46 PM
Xqt changed the subtype of this task from "Task" to "Bug Report".Apr 25 2022, 2:15 PM

Change 785879 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [bugfix] Do not delegate logging output to the root logger

Change 785879 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] Do not delegate logging output to the root logger