开发者

Add a second ILogObserver to a service

开发者 https://www.devze.com 2023-04-01 04:16 出处:网络
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 obse

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

精彩评论

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