Add a second ILogObserver to a service
I try to write a small service with twisted.
I created a simple Application, and try to add 2 ILogObservers to my service. But unfortunatly, it doesnt work. The last added Observer is always the observer that will be used.
def log(eventDict):
...
def mylog(eventDict):
...
LoopingCall(logSomething).start(1)
application = Application("twistd-logging")
application.setComponent(ILogObserver, log)
application.setComponent(开发者_运维知识库ILogObserver, mylog)
Thanks in advance for your help.
kay, I found the solution, it was far easier then I suspected.
I just have to add
from twisted.python.log import addObserver
if I have a secondary log observer
def mylogobserver(eventDict):
# doSth
I can add it VERY SIMPLE with
addObserver(mylogobserver)
Best regards
精彩评论