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 @summary:
31 The client (i.e.application) side of an XMLRPC log connection.
32 @author: Ruben Reifenberg
33 """
34
35 from xmlrpclib import ServerProxy, Error, Binary
36 import pickle
37
38 from rrlog import Log
39
42 """
43 @param txt: some ascii error explanation text
44 @param msgid: msgid of the log-msg that caused the problem.
45 """
46 Exception.__init__(self, txt+"[msgid%s]"%(msgid))
47
49 """
50 Logging went wrong because of a connection issue.
51 """
52 pass
54 """
55 Logging went wrong because the server had a problem.
56 """
57 pass
58
60 """
61 Deactivated, activate for debugging only.
62 Here does the log logging itself.
63 """
64 pass
65
66
68 for port in ports:
69 server = ServerProxy("http://%s:%s"%(host,port))
70 try:
71 clientId = server.addClient()
72 except Exception,e:
73 loglog("Connect: no server at port%s:%s"%(port, e))
74 else:
75 loglog("Found server at %s/%s; got clientId=%s."%(host, port, clientId))
76 return server, clientId
77 raise Exception("no server at %s%s"%(host,str(ports)))
78
79
80
81
82
84 """
85 First method call must be addClient,
86 since this establishes the server connection.
87 """
89 """
90 """
91 self.host = host
92 self.ports = ports
93
95 """
96 Does the connection to the server.
97 """
98 self.server, clientId = connect(self.host,self.ports)
99 return clientId
100
101
102 - def log(self, pid, clientid, msgid, msg, special, cat, path, tblen, cfunc):
103 try:
104 ok = self.server.log(
105 Binary(pickle.dumps(
106 {
107 "pid":pid,
108 "clientid":clientid,
109 "msgid":msgid,
110 "msg":msg,
111 "special":special,
112 "cat":cat,
113 "path":path,
114 "tblen":tblen,
115 "cfunc":cfunc,
116 }
117 )),
118 )
119 except Exception, e:
120 raise XMLRPCConnectionException("%s"%(e),msgid=msgid)
121 else:
122 if ok != "":
123 raise XMLRPCServerException(ok,msgid=msgid)
124
125
126
127
128 -def createClientLog(host, ports, errorHandler=None, traceOffset=0, stackMax=5, extractStack=True, seFilesExclude=None):
140