一个Python 3-兼容的客户机
facebook-scribe-py3的Python项目详细描述
这是一个用于scribe的python客户端,可以使用pip安装:
pip install facebook-scribe
用法
使用thrift连接到HOST:9999:
from scribe import scribe from thrift.transport import TTransport, TSocket from thrift.protocol import TBinaryProtocol socket = TSocket.TSocket(host="HOST", port=9999) transport = TTransport.TFramedTransport(socket) protocol = TBinaryProtocol.TBinaryProtocol(trans=transport, strictRead=False, strictWrite=False) client = scribe.Client(protocol) transport.open() category = 'LOGS' message = 'hello world' log_entry = scribe.LogEntry(category, message) result = client.Log(messages=[log_entry]) if result == 0: print 'success'