我想将 twistd.py 的日志记录重定向到 python 的日志记录。正常启动.tac文件时,我可以轻松地做到这一点:
from twisted.python.log import PythonLoggingObserver, ILogObserver
from twisted.application import service
application = service.Application("FooApp")
application.setComponent(ILogObserver, PythonLoggingObserver().emit)
但是,我Application在编写IPlugin. 相反,我只有一个实现IServiceMakerand的类IPlugin,其中makeService返回一个service.Service. 如何设置此日志观察器?
请注意,我不只是想添加一个 python 日志观察器,我想重定向twistd 的日志记录,以便它只通过 python 的内置日志记录系统。