From 9dca421dc71bbbd96b1f2fc869ed56c2da9c5bea Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Sat, 30 Sep 2017 11:54:49 +0200 Subject: [PATCH] Render time --- utils/controllers.js | 3 +++ utils/log.js | 13 +++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/utils/controllers.js b/utils/controllers.js index 22c0bb7..1e3502a 100644 --- a/utils/controllers.js +++ b/utils/controllers.js @@ -40,7 +40,10 @@ module.exports = function(app, controllersDir = __dirname + '/../controllers') { let path = obj[url.view](req, res, function(template) { let templatePath = controllersDir + '/' + name + '/templates/' + template; + + let renderTime = Date.now(); res.render(templatePath, res.locals, function(err, out) { + log.debug('Template time: ' + (Date.now() - renderTime) + 'ms'); if (err !== null) { log.pugerror(err); } diff --git a/utils/log.js b/utils/log.js index c77670f..f1ffdcb 100644 --- a/utils/log.js +++ b/utils/log.js @@ -1,5 +1,6 @@ -var express = require('express'); -var http = require('http'); +const express = require('express'); +const http = require('http'); +const config = require('settings/config'); var log = {}; @@ -92,8 +93,12 @@ log.mailerror = function(error) { log.write('[MLE] ' + new Date() + ' ' + error, log.Color.RED); } -log.debug = function(info) { - log.write('[DBG] ' + (info !== undefined ? info : ''), log.Color.YELLOW); +if (config.DEBUG === true) { + log.debug = function(info) { + log.write('[DBG] ' + (info !== undefined ? info : ''), log.Color.YELLOW); + } +} else { + log.debug = function() {}; } log.pugerror = function(error) {