added logging for http api calls

pull/85/merge
Peter 'Pita' Martischka 2011-08-08 17:45:44 +01:00
parent 4670cbc60a
commit 9d91a3873c
1 changed files with 13 additions and 0 deletions

View File

@ -240,6 +240,8 @@ async.waterfall([
importHandler.doImport(req, res, req.params.pad);
});
var apiLogger = log4js.getLogger("API");
//This is a api call, collect all post informations and pass it to the apiHandler
app.all('/api/1/:func', function(req, res)
{
@ -252,6 +254,17 @@ async.waterfall([
{
if(err) throw err;
apiLogger.info("REQUEST, " + req.params.func + ", " + JSON.stringify(fields));
//wrap the send function so we can log the response
res._send = res.send;
res.send = function(response)
{
response = JSON.stringify(response);
apiLogger.info("RESPONSE, " + req.params.func + ", " + response);
res._send(response);
}
//call the api handler
apiHandler.handle(req.params.func, fields, req, res);
});