Page MenuHomePhabricator

debug() missing 1 required positional argument: 'layer'
Closed, ResolvedPublicBUG REPORT

Description

pywikibot/site/_tokenwallet.py
from pywikibot import debug

debug('Token {!r} was replaced by {!r}'.format(key, 'csrf'))

Not sure what to put there.

Event Timeline

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

[pywikibot/core@master] [bugfix] Solve TypeError debug() missing 1 required positional argument: 'layer'

https://gerrit.wikimedia.org/r/754107

Xqt triaged this task as High priority.

@matej_suchanek: @JJMC89: The layer parameter is mandatory for debug() function.[1]

Usually a global _logger variable is used and passed to debug() [2][3] but I don't see any benefit to have different logger for debug() (which does not mean to have different files) whereas other logging functions like log() or output() could have different logger but all of them uses our default 'pywiki' logger. The log file does not use the logger name. I propose to remove the global _logger variables and make the layer parameter optional for debug().

See also: T85620

[1] https://doc.wikimedia.org/pywikibot/master/api_ref/pywikibot.html?highlight=debug#pywikibot.debug
[2] https://codesearch.wmcloud.org/pywikibot/?q=debug%5C(&i=nope&files=&excludeFiles=&repos=
[3] https://codesearch.wmcloud.org/pywikibot/?q=_logger&i=nope&files=&excludeFiles=&repos=

Change 754107 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] Solve TypeError debug() missing 1 required positional argument: 'layer'

https://gerrit.wikimedia.org/r/754107

@matej_suchanek: @JJMC89: The layer parameter is mandatory for debug() function.[1]

Usually a global _logger variable is used and passed to debug() [2][3] but I don't see any benefit to have different logger for debug() (which does not mean to have different files) whereas other logging functions like log() or output() could have different logger but all of them uses our default 'pywiki' logger. The log file does not use the logger name. I propose to remove the global _logger variables and make the layer parameter optional for debug().

Sorry about this. I always forget that the layer is required for debug(). I thought the purpose was that so only part of the debug logging can be enabled.
In any case, making all of the logging interfaces the same is a good idea. If we don't want to remove the layer for some reason, at least defaulting it would be good.