Hey all,
Let's say I have an class called Model, and a class called View. The view
instance collects lots of Model instances and as the user manipulates the
models, the view is updated. In this case, one thing I want to have in the
view is a text area where my model objects can display messages as they are
manipulated, both for debugging and for user feedback.
I wanted to set this up by adding a logger instance to each Model instance
in it's __init__ method, so that other methods can call it to output
messages:
Model(object):
def __init__(self):
self.logger = logging.getLogger(self.__class__.__name__) #or whatever
inst_a = Model()
inst_b = Model()
The problem is that I want to connect and disconnect the different model
object's loggers to different text widgets (via a special handler),
filehandlers, etc. Loggers are cached by name, though, so now each of my
instances are sharing pointers to the same logger.
So - AFAIK, I have to do something like use a uuid in my getLogger call to
use the Logger class. This feels like an abuse of how loggers are designed
to work, and since the logging module seems to cache instances, I'm
concerned about memory leaks. Especially in a Maya situation where a user
has a long-running Python process.
Has anyone had a similar experience and found a clean solution for this
problem? Really, I'd just like a non-cached logger instance. The docs
lead me to believe it's not possible, but this seems like it would be a
fairly common scenario.
Thanks!
JP
--
John Patrick
404-242-2675
[email protected]
http://www.canyourigit.com
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.