import firepython import logging class WSGILikeHeaders object def __in

 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
import firepython
import logging
class WSGILikeHeaders(object):
def __init__(self, response):
self.response = response
def add_header(self, name, value):
self.response[name] = value
class FirePythonMiddleware(object):
def __init__(self):
self.handler = firepython.FirePythonLogHandler()
self.root = logging.getLogger()
def process_request(self, request):
self.root.addHandler(self.handler)
self.root.setLevel(logging.DEBUG)
logging.debug('test')
def process_response(self, request, response):
self.root.removeHandler(self.handler)
response.headers = WSGILikeHeaders(response)
self.handler.flush(response)
return response