Incompatible with logging.addLevelName
Opened this issue · 0 comments
mottosso commented
Hi all,
To make levelname
more pleasant, a user can override the default e.g. INFO
and WARNING
labels with something else, such as..
import logging
log = logging.getLogger("myLogger")
fmt = logging.Formatter("%(levelname)s : %(message)s")
handler = logging.StreamHandler()
handler.setFormatter(fmt)
log.addHandler(handler)
log.propagate = False
log.info("Hello!")
# INFO : Hello!
logging.addLevelName(logging.INFO, "Info")
log.info("Hello!")
# Info : Hello!
However, this breaks PyMEL. :(
# Error: root : Uncaught exception:
Traceback (most recent call last):
File "<maya console>", line 2, in <module>
File "/opt/autodesk/maya-2019.2/lib/python2.7/site-packages/pymel/core/init.py", line 13, in <module>
import pymel.internal.factories as _factories
File "/opt/autodesk/maya-2019.2/lib/python2.7/site-packages/pymel/internal/factories.py", line 27, in <module>
from . import apicache
File "/opt/autodesk/maya-2019.2/lib/python2.7/site-packages/pymel/internal/apicache.py", line 13, in <module>
from pymel.api.plugins import mpxNamesToApiEnumNames
File "/opt/autodesk/maya-2019.2/lib/python2.7/site-packages/pymel/api/plugins.py", line 319, in <module>
_logger.raiseLog(_logger.WARNING, 'found new MPx classes: %s. Run pymel.api.plugins._suggestNewMPxValues()'
AttributeError: 'Logger' object has no attribute 'WARNING' #
# Error: AttributeError: 'Logger' object has no attribute 'WARNING' #
Because of this here.
pymel/pymel/internal/plogging.py
Lines 216 to 219 in a2dc935
Would recommend explicitly storing the exact labels, since they are assumed elsewhere. For example..
logger.INFO = logging.INFO
logger.WARNING = logging.WARNING
logger.CRITICAL = logging.CRITICAL
Or better yet, use the original values to avoid confusion.