开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜