I expect the text between â[â and â#â to be âad_hocâ, but it is auto-generated name instead. Am I doing something wrong or this is a bug?
This is indeed a bug! And a pretty serious one; it's explicitly documented to work otherwise. Please file it.
The reason that this happens is that the 'namespace' field is filled out by the descriptor (__get__ method) of the `Logger` object when it is bound to `self`.
You can work around this in the meanwhile by changing your example to be like so:
import sys
from twisted.logger import (Logger, textFileLogObserver)
observer = textFileLogObserver(sys.stdout)
class MyClass:
@property
def log(self):
return Logger(namespace="ad_hoc", observer=observer, source=self)
def __init__(self):
self.log.info("MyClass.__init__ called!")
def __del__(self):
self.log.info("Bye!")
obj = MyClass()
-glyph