扭曲的启动/停止工厂/协议噪音更少的日志消息 [英] Twisted starting/stopping factory/protocol less noisy log messages
问题描述
有没有办法告诉twisted不记录所有工厂和协议的启动和停止.我使用多种类型的协议并执行大量连接……并且我的日志文件增长了很多.所以我正在寻找一种简单的方法来禁用这些消息.
Is there a way to tell to twistd to not log all factory and protocol start and stop. I use many type of protocols and performs a lot of connections ... and my log file grows a lot. So i'm looking for a simple way to disable those messages.
问候
推荐答案
您可以将工厂的 noisy
属性设置为 False
以防止它记录这些消息.另请参阅 http://twistedmatrix.com/trac/ticket/4021,这可能会通过以下方式解决下一个 Twisted 版本.
You can set the noisy
attribute of a factory to False
to prevent it from logging these messages. See also http://twistedmatrix.com/trac/ticket/4021 which will probably be resolved by the next Twisted release.
例如,这是一个有两个客户端的程序,但只有一个会记录其启动/停止消息:
For example, here's a program with two clients, but only one will log its start/stop messages:
import sys
from twisted.internet import reactor, protocol
from twisted.python import log
log.startLogging(sys.stdout)
f = protocol.ClientFactory()
f.protocol = protocol.Protocol
reactor.connectTCP('localhost', 22, f)
g = protocol.ClientFactory()
g.noisy = False
g.protocol = protocol.Protocol
reactor.connectTCP('localhost', 25, g)
reactor.run()
和输出:
2011-02-22 09:43:23-0500 [-] Log opened.
2011-02-22 09:43:23-0500 [-] Starting factory <twisted.internet.protocol.ClientFactory instance at 0x8f422cc>
^C
2011-02-22 09:43:26-0500 [-] Received SIGINT, shutting down.
2011-02-22 09:43:26-0500 [Protocol,client] Stopping factory <twisted.internet.protocol.ClientFactory instance at 0x8f422cc>
2011-02-22 09:43:26-0500 [-] Main loop terminated.
这篇关于扭曲的启动/停止工厂/协议噪音更少的日志消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!