Thanks for the tip Ofer. And thanks Chad for the comment on my style. I often use allcaps for global variables. But it`s true that I should reserve them for constants... I guess that using _mayaLogingSetup would be better in that case
By the way we have setup a git of pymel at work. My goal is to add a few utilities methods to some nodes. I have a few ideas mainly for rendering nodes. for example, adding a place 2d node to a fileTexture node, or get the SG from a shader, get the connected objects or faces of a SG, etc. I don't know if this kind of addon can be part of pymel in the futur or not. I will send you patch file of my addons in a near future (I hope I get enough time to devlop this ) cheers On Wed, Oct 28, 2009 at 1:54 PM, Ofer Koren <[email protected]> wrote: > > > You'll need to remove the existing 'rootHandler' from the root logger which > also outputs to the standard output stream (the script editor). You should > be able to do this by modifying the pymel.conf or programmatically: > > del logging.root.handlers[:] > > > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of sberger > Sent: Wednesday, October 28, 2009 9:16 AM > To: python_inside_maya > Subject: [Maya-Python] logging and mayaHandler > > > Hi guys, I have setup this logging setup in the __init__.py file of > my mfxMaya package > > # setup logging > import logging > import maya.OpenMaya as OpenMaya > > MAYA_LOGGING_SETUP = False > > class MayaLogHandler(logging.Handler): > def emit(self, record): > if record.levelno > logging.ERROR: > # Critical > OpenMaya.MGlobal.displayError(record.getMessage()) > elif record.levelno > logging.WARNING: > # error > OpenMaya.MGlobal.displayError(record.getMessage()) > elif record.levelno > logging.INFO: > # warning > OpenMaya.MGlobal.displayWarning(record.getMessage()) > elif record.levelno <= logging.DEBUG: > # info and Debug > OpenMaya.MGlobal.displayInfo(record.getMessage()) > else: > OpenMaya.MGlobal.displayInfo(record.getMessage()) > > def setupMayaLogging(loggerName=''): > global MAYA_LOGGING_SETUP > > log = logging.getLogger(loggerName) > if MAYA_LOGGING_SETUP: > return log > > log.addHandler(MayaLogHandler()) > log.setLevel(logging.INFO) > MAYA_LOGGING_SETUP = True > return log > > # setup the mfxMaya logger > log = setupMayaLogging('mfxMaya') > > This allow me to control my logging, and when I use the logging menu > from the pymel.tool I can even change the logging level of my package > which is really nice. > > The problem I have is that because of the MayaLogHandler, I get double > logging, one from the handler and one from python. it looks somthing > like that in the script editor: > # Warning: Double underscores are not allowed in a description. # > mfxMaya.io.savesAs : WARNING : Double underscores are not allowed in a > description. > > Do you know how I could only force only the MayaLogHandler to output? > I want to use the maya handler so that I can use the Maya color coding > of the warning and error message. > > Thanks > > > > > -- "A pit would not be complete without a Freeman coming out of it." The Vortigaunt --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/python_inside_maya -~----------~----~----~----~------~----~------~--~---
