I am using Maya 2018 and attemoting to setup logging. My warning and error level messages appear in the script editor, but not my debug level messages. I wondered if they are going somewhere else?
import pymel.core as pm
import logging
logging.basicConfig(level=logging.error)
def texture_swap_core(selected_nodes):
try:
if number_of_selected_nodes(selected_nodes) is False:
return False
except Exception as e:
logging.error(e)
def number_of_selected_nodes(selected_nodes):
"""Count the number of selected nodes.
:param:selected_nodes
:type:list
:return:True if an even number of nodes are selected
:rtype:bool
"""
if len(selected_nodes) % 2 == 0 and len(selected_nodes) > 1:
logging.debug('even number of nodes selected')
return True
else:
logging.error('odd number of nodes selected')
return False
There's two things going on
logging.basicConfig(level=logging.error)
is trying to telling the logger to ignore lower level errors. In ordinary Python it would be logging.basicConfig(level=logging.ERROR)
-- however it's actually overridden in Maya in any case by default so it's not really affecting the outcome.
If you want to set the global log level in Maya, this works:
import logging
root_logger = logging.getLogger()
root_logger.setLevel(logging.DEBUG) # or whatever level you want here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.