Twisted: disable logging of Twisted-framework classes

北战南征 提交于 2019-12-01 21:17:41

Twisted's logging is all very naive. However, there is no reason this needs to be the case, since twisted.python.log is very featureful, and capable of the kind of selective reporting that you (and others) are interested in.

A log event is just a dictionary of arbitrary keys and values. The default observer knows about dictionaries with a 'message' key. Perhaps because of this, most log messages emitted by Twisted itself don't try to do anything except provide a human-readable string associated with this key (also, many of the emitted messages were added prior to the current Twisted logging system, and so had the older, more primitive system as a consumer).

Not too long ago, this problem bothered someone who was prompted to file a ticket and start working on a resolution to the UDP part of the problem in particular. The issue is mostly resolved, but a few things remain to be done.

The solution attempted is to log a structured message which conveys the same information, but has no message and so isn't recorded by the default observer. This avoids the messages appearing in the log by default, but allows an observer that's specifically interested in these events to observe them and handle them as desired.

The ticket has been sitting untouched for some time now. It would probably be easy for someone to pick up the patch and get it the last bit of the way to completion.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!