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') logger.setLevel(logging.INFO) # set for other logging purposes logging.basicConfig(level=logging.WARNING) pywikibot.output("Double output") logger.setLevel(logging.WARNING) pywikibot.output("No output")
Produces
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.