Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在创建一个扭曲的插件。这里有关于如何控制 .tac 文件中扭曲应用程序的日志记录的文档。但是,没有用于控制插件日志记录的类似文档。
由于插件不创建 Application() 对象,我们如何控制/自定义发生的日志记录?
(这里的邮件列表上提出了一个几乎相同的问题,但似乎没有得到答案)
插件不应配置日志记录。日志记录通常由twistd命令行选项直接配置--logfile。随意以通常的方式在插件中发出日志消息twisted.python.log.msg()
twistd
--logfile
twisted.python.log.msg()
请记住,这twistd是一种方便,它并不是您所有扭曲的应用程序容器需求的开始和结束。如果您确实需要比 twistd 提供的更高级的东西,那么实例化插件并自己启动反应器是非常好的。