Twisted Scribe客户端/服务器
scrivener的Python项目详细描述
scrivener是一个用于Twisted应用程序的Scribe客户机/服务器框架。
客户端API
fromtwisted.internetimportreactorfromtwisted.internet.endpointsimportTCP4ClientEndpointfromscrivenerimportScribeClientdefmain():client=ScribeClient(TCP4ClientEndpoint(reactor,'127.0.0.1',1234))client.log('category','message1')client.log('category','message2')if__name__=='__main__':reactor.callWhenRunning(main)reactor.run()
服务器API
importsysfromtwisted.internetimportreactorfromtwisted.internet.endpointsimportTCP4ServerEndpointfromtwisted.python.logimportstartLoggingfromscrivenerimportScribeServerServicefromscrivener.handlersimportTwistedLogHandlerdefmain():service=ScribeServerService(TCP4ServerEndpoint(reactor,1234),TwistedLogHandler())service.startService()if__name__=='__main__':startLogging(sys.stdout)reactor.callWhenRunning(main)reactor.run()
服务器插件
> twistd -n scrivener --help Usage: twistd [options] scrivener [scrivener options] Options: -p, --port= Port to listen on for scribe service. [default: tcp:0] -H, --handlerFactory= Fully Qualified Name of a callable that returns an ILogHandler --version Display Twisted version and exit. --help Display this help and exit. > twistd -n scrivener -p 1234 -H example.MyLogHandler
许可证
Copyright (C) 2012 Rackspace Hosting, Inc Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.