From a5f633961ff293cba0fc6679c482e9744e7ed650 Mon Sep 17 00:00:00 2001 From: Aditya Raisinghani Date: Sun, 2 Mar 2014 01:48:21 +0530 Subject: [PATCH] Added log setting for production. --- server_setup.coffee | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server_setup.coffee b/server_setup.coffee index 9f94da179..3332e0428 100644 --- a/server_setup.coffee +++ b/server_setup.coffee @@ -8,7 +8,6 @@ database = require './server/commons/database' baseRoute = require './server/routes/base' user = require './server/users/user_handler' logging = require './server/commons/logging' - config = require './server_config' ###Middleware setup functions implementation### @@ -20,9 +19,16 @@ setupRequestTimeoutMiddleware = (app) -> self.emit('pass',message) next() +productionLogging = (tokens, req, res)-> + status = res.statusCode + color = 31 + if(status != 200 && status != 304) + return '\x1b[90m' + req.method+ ' ' + req.originalUrl + ' '+ '\x1b[' + color + 'm' + res.statusCode+ ' \x1b[90m'+ (new Date - req._startTime)+ 'ms' + '\x1b[0m'; + setupExpressMiddleware = (app) -> setupRequestTimeoutMiddleware app - app.use(express.logger('dev')) + express.logger.format('prod', productionLogging) + app.use(express.logger('prod')) app.use(express.static(path.join(__dirname, 'public'))) app.use(useragent.express())