From 9d91a3873c7a6d409a4f6deb04fb4aaefd698ee7 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Mon, 8 Aug 2011 17:45:44 +0100 Subject: [PATCH] added logging for http api calls --- node/server.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/node/server.js b/node/server.js index aab3cda5b..7b8cec6c0 100644 --- a/node/server.js +++ b/node/server.js @@ -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); });