Twisted与Twiggy日志库的集成。
twixx的Python项目详细描述
twixxy-twiggy+扭曲
twixxy主要由twisted log observer组成,可以安装到 将对log.msg和log.err的调用转发到适当的twiggy 日志方法。
与twistd一起使用
Twixxy提供了一个与 twistd --logger。
> twistd --logger=twixxy.observerFactory -n web --path=. 2012-06-19T22:09:43Z:INFO:twisted:Log opened. 2012-06-19T22:09:43Z:INFO:twisted:twistd 12.1.0 (/Users/dreid/.virtualenvs/twixxy/bin/python 2.7.1) starting up. 2012-06-19T22:09:43Z:INFO:twisted:reactor class: twisted.internet.selectreactor.SelectReactor. 2012-06-19T22:09:43Z:INFO:twisted:Site starting on 8080 2012-06-19T22:09:43Z:INFO:twisted:Starting factory <twisted.web.server.Site instance at 0x10b718fc8>
在不扭曲的情况下替换扭曲的日志。
import sys import twiggy from twisted.python import log from twixxy import TwiggyLoggingObserver twiggy.quickSetup(file=sys.stdout) observer = TwiggyLoggingObserver('example') log.startLoggingWithObserver(observer.emit) log.msg('Hello, World!')
与Twisted的日志一起使用。
import sys import twiggy from twisted.python import log from twixxy import TwiggyLoggingObserver twiggy.quickSetup(file='twiggy.log') observer = TwiggyLoggingObserver('example2') observer.start() log.startLogging(sys.stdout) log.msg('Hello, World!')