同时使用Python tail多个文件并将日志文件推送到Facebook/Scrib

2024-04-29 07:39:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我想同时使用Python跟踪多个文件,并将日志发送给Scribe到相应的bucket

我用的是桶:

dict(Config.items('files')).keys()

我使用以下方法获取文件:

^{pr2}$

我想同时跟踪所有文件,然后将日志推送到特定的存储桶中:

log_entry = scribe.LogEntry(category, message)

socket = TSocket.TSocket(host='localhost', port=1463)
transport = TTransport.TFramedTransport(socket)
protocol = TBinaryProtocol.TBinaryProtocol(trans=transport, strictRead=False, strictWrite=False)
client = scribe.Client(iprot=protocol, oprot=protocol)

transport.open()
result = client.Log(messages=[log_entry])
transport.close()

Tags: 文件clientlogfalsebucketsocketprotocoldict