summaryrefslogtreecommitdiffstats
path: root/src/blkin/babeltrace-plugins/scribe_client/scribe_client.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/blkin/babeltrace-plugins/scribe_client/scribe_client.py')
-rw-r--r--src/blkin/babeltrace-plugins/scribe_client/scribe_client.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/blkin/babeltrace-plugins/scribe_client/scribe_client.py b/src/blkin/babeltrace-plugins/scribe_client/scribe_client.py
new file mode 100644
index 000000000..b382ed995
--- /dev/null
+++ b/src/blkin/babeltrace-plugins/scribe_client/scribe_client.py
@@ -0,0 +1,31 @@
+#!/usr/bin/python
+# scribe_client.py
+
+from scribe import scribe
+from thrift.transport import TTransport, TSocket
+from thrift.protocol import TBinaryProtocol
+
+class ScribeClient(object):
+
+ def __init__(self, port, host):
+ print host
+ self.port = port
+ self.host = host
+ self.openConnection()
+
+ def openConnection(self):
+ socket = TSocket.TSocket(host=self.host, port=self.port)
+ self.transport = TTransport.TFramedTransport(socket)
+ protocol = TBinaryProtocol.TBinaryProtocol(trans=self.transport,
+ strictRead=False,
+ strictWrite=False)
+ self.client = scribe.Client(protocol)
+ self.transport.open()
+
+ def log(self, category, message):
+ log_entry = scribe.LogEntry(category, message)
+ result = self.client.Log(messages=[log_entry])
+ return result # 0 for success
+
+ def close(self):
+ self.transport.close()