forked from facebookarchive/scribe
-
Notifications
You must be signed in to change notification settings - Fork 1
Logging Messages
drallgood edited this page Jan 22, 2012
·
5 revisions
enum ResultCode
{
OK,
TRY_LATER
}
struct LogEntry
{
1: string category,
2: string message
}
service scribe extends fb303.FacebookService
{
ResultCode Log(1: list<LogEntry> messages);
}
To send a message to a Scribe Server running on a given machine and port, we simply need to create a Scribe Client and call Log(). Here is an example using Python:
from scribe import scribe
from thrift.transport import TTransport, TSocket
from thrift.protocol import TBinaryProtocol
category='test'
message='hello world'
log_entry = scribe.LogEntry(category, message)
# depending on thrift version
# log_entry = scribe.LogEntry(dict(category=category, message=message))
socket = TSocket.TSocket(host='localhost', port=1456)
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()