From c90c030904dbe690ef060dc1b0b00aaf70be2cf4 Mon Sep 17 00:00:00 2001 From: jomo Date: Sat, 10 Jan 2015 23:34:27 +0100 Subject: [PATCH] prepend uuid to "status: " logs --- routes/avatars.js | 16 ++++++++-------- routes/renders.js | 16 ++++++++-------- routes/skins.js | 16 ++++++++-------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/routes/avatars.js b/routes/avatars.js index 3c6185b..2bb68ab 100644 --- a/routes/avatars.js +++ b/routes/avatars.js @@ -65,20 +65,20 @@ module.exports = function(req, res) { } logging.debug("Etag: " + req.headers["if-none-match"]); logging.debug("matches: " + matches); - sendimage(http_status, status, image); + sendimage(http_status, status, image, uuid); } else { - handle_default(404, status); + handle_default(404, status, uuid); } }); } catch(e) { logging.error(uuid + " error:"); logging.error(e); - handle_default(500, status); + handle_default(500, status, uuid); } - function handle_default(http_status, img_status) { + function handle_default(http_status, img_status, uuid) { if (def && def != "steve" && def != "alex") { - logging.log("status: 301"); + logging.log(uuid + " status: 301"); res.writeHead(301, { "Cache-Control": "max-age=" + config.browser_cache_time + ", public", "Response-Time": new Date() - start, @@ -90,13 +90,13 @@ module.exports = function(req, res) { } else { def = def || skins.default_skin(uuid); skins.resize_img("public/images/" + def + ".png", size, function(err, image) { - sendimage(http_status, img_status, image); + sendimage(http_status, img_status, image, uuid); }); } } - function sendimage(http_status, img_status, image) { - logging.log("status: " + http_status); + function sendimage(http_status, img_status, image, uuid) { + logging.log(uuid + " status: " + http_status); res.writeHead(http_status, { "Content-Type": "image/png", "Cache-Control": "max-age=" + config.browser_cache_time + ", public", diff --git a/routes/renders.js b/routes/renders.js index 0b4e0db..9c1d62b 100644 --- a/routes/renders.js +++ b/routes/renders.js @@ -75,24 +75,24 @@ module.exports = function(req, res) { } logging.log("matches: " + matches); logging.log("Etag: " + req.headers["if-none-match"]); - sendimage(http_status, status, image); + sendimage(http_status, status, image, uuid); } else { logging.log("image not found, using default."); - handle_default(404, status); + handle_default(404, status, uuid); } }); } catch(e) { logging.error(uuid + " error:"); logging.error(e); - handle_default(500, status); + handle_default(500, status, uuid); } // default alex/steve images can be rendered, but // custom images will not be - function handle_default(http_status, img_status) { + function handle_default(http_status, img_status, uuid) { if (def && def != "steve" && def != "alex") { - logging.log("status: 301"); + logging.log(uuid + " status: 301"); res.writeHead(301, { "Cache-Control": "max-age=" + config.browser_cache_time + ", public", "Response-Time": new Date() - start, @@ -113,14 +113,14 @@ module.exports = function(req, res) { if (err) { logging.log("error while rendering default image: " + err); } - sendimage(http_status, img_status, def_img); + sendimage(http_status, img_status, def_img, uuid); }); }); } } - function sendimage(http_status, img_status, image) { - logging.log("status: " + http_status); + function sendimage(http_status, img_status, image, uuid) { + logging.log(uuid + " status: " + http_status); res.writeHead(http_status, { "Content-Type": "image/png", "Cache-Control": "max-age=" + config.browser_cache_time + ", public", diff --git a/routes/skins.js b/routes/skins.js index 116ecc7..58ef711 100644 --- a/routes/skins.js +++ b/routes/skins.js @@ -41,20 +41,20 @@ module.exports = function(req, res) { } logging.debug("Etag: " + req.headers["if-none-match"]); logging.debug("matches: " + matches); - sendimage(http_status, image); + sendimage(http_status, image, uuid); } else { - handle_default(404); + handle_default(404, uuid); } }); } catch(e) { logging.error(uuid + " error:"); logging.error(e); - handle_default(500); + handle_default(500, uuid); } - function handle_default(http_status) { + function handle_default(http_status, uuid) { if (def && def != "steve" && def != "alex") { - logging.log("status: 301"); + logging.log(uuid + " status: 301"); res.writeHead(301, { "Cache-Control": "max-age=" + config.browser_cache_time + ", public", "Response-Time": new Date() - start, @@ -67,14 +67,14 @@ module.exports = function(req, res) { def = def || skins.default_skin(uuid); lwip.open("public/images/" + def + "_skin.png", function(err, image) { image.toBuffer("png", function(err, buffer) { - sendimage(http_status, buffer); + sendimage(http_status, buffer, uuid); }); }); } } - function sendimage(http_status, image) { - logging.log("status: " + http_status); + function sendimage(http_status, image, uuid) { + logging.log(uuid + " status: " + http_status); res.writeHead(http_status, { "Content-Type": "image/png", "Cache-Control": "max-age=" + config.browser_cache_time + ", public",