/
scribe_cat.c
55 lines (43 loc) · 1.58 KB
/
scribe_cat.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <transport/thrift_transport.h>
#include <transport/thrift_socket.h>
#include <transport/thrift_server_transport.h>
#include <transport/thrift_server_socket.h>
#include <transport/thrift_framed_transport.h>
#include <protocol/thrift_protocol.h>
#include <protocol/thrift_binary_protocol.h>
#include "gen-c_glib/scribe.h"
#include "gen-c_glib/scribe_types.h"
#ifndef NOMAIN
int main(int argc, char **argv) {
#else
int log(){
#endif /* NOMAIN */
g_type_init();
ThriftTransport *transport = NULL;
ThriftSocket *tsocket = NULL;
ThriftBinaryProtocol *protocol = NULL;
scribeClient *client = NULL;
scribeIf *iface = NULL;
ResultCode result;
LogEntry *log = NULL;
GPtrArray * messages = NULL;
GError *error = NULL;
tsocket = g_object_new(THRIFT_TYPE_SOCKET, "hostname", "localhost",
"port", 1463, NULL);
transport = g_object_new(THRIFT_TYPE_FRAMED_TRANSPORT, "transport",
THRIFT_TRANSPORT(tsocket), NULL);
protocol = g_object_new(THRIFT_TYPE_BINARY_PROTOCOL, "transport",
THRIFT_TRANSPORT(transport), NULL);
client = g_object_new(TYPE_SCRIBE_CLIENT,
"input_protocol", THRIFT_PROTOCOL(protocol),
"output_protocol", THRIFT_PROTOCOL(protocol), NULL);
iface = SCRIBE_IF(client);
thrift_transport_open(THRIFT_TRANSPORT(tsocket), NULL);
messages = g_ptr_array_new();
log = g_object_new(TYPE_LOG_ENTRY, NULL);
log->category = "TEST";
log->message = "This is a test message\n\0";
g_ptr_array_add(messages, log);
scribe_client_log(iface, &result, messages, &error);
return 0;
}