A request logger for requests and responses from the requests and flask libraries that logs in a standard format
{
"meta":{
},
"request":{
"headers":[
[
"Host",
"localhost"
],
[
"Content-Length",
"0"
],
[
"Content-Type",
""
]
],
"url":"http://localhost/",
"method":"GET",
"payload": null
},
"response":{
"status":"200 OK",
"headers":[
[
"Content-Type",
"text/html; charset=utf-8"
],
[
"Content-Length",
"12"
]
],
"data":"Hello World!"
}
}
class FlaskApp(flask.Flask):
def log_it(self, response):
logger.log(response)
return response
logger = frl.server.ServerRequestLogger(
'logger-name',
['card_number', 'password']
)
app = FlaskApp(__name__)
app.after_request(app.log_it)
logger = frl.client.ClientRequestLogger(
'logger-name',
['card_number', 'password']
)
response = requests.get('http://google.com')
logger.log(response)
You can add additional data into the meta field.
logger = frl.client.ClientRequestLogger(
'logger-name',
['card_number', 'password']
)
def meta_logger(response):
return {'foo': 'bar'}
logger.meta_population_methods.append(meta_logger)