Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import time
2from logging import getLogger, INFO
4log = getLogger(__name__)
7class Proxy:
8 def __init__(self, server, client):
9 self.server = server
10 self.client = client
12 def serve(self):
13 self.server.serve(self.dispatcher)
15 def paramfilter(self, method, param):
16 return method, param
18 def dispatcher(self, method: str, params=None):
19 m, p = self.paramfilter(method, params)
20 return self.client.call(m, p)
23class LoggingProxy(Proxy):
24 def __init__(self, server, client):
25 super().__init__(server, client)
26 log.setLevel(INFO)
28 def dispatcher(self, method: str, params=None):
29 ts = time.time()
30 res = super().dispatcher(method, params)
31 log.info("%s %.3f arg=%s, res=%s", method,
32 time.time() - ts, params, res)
33 return res