Page MenuHomePhabricator

Pywikibot: avoid double logging of output
Open, MediumPublic


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.