MCPcopy Create free account
hub / github.com/codecombat/codecombat / productionLogging

Function productionLogging

server_setup.js:36–49  ·  view source on GitHub ↗
(tokens, req, res)

Source from the content-addressed store, hash-verified

34const {countries} = require('./app/core/utils');
35
36const productionLogging = function(tokens, req, res) {
37 const status = res.statusCode;
38 let color = 32;
39 if (status >= 500) { color = 31;
40 } else if (status >= 400) { color = 33;
41 } else if (status >= 300) { color = 36; }
42 const elapsed = (new Date()) - req._startTime;
43 const elapsedColor = elapsed < 500 ? 90 : 31;
44 if ((status === 404) && /\/feedback/.test(req.originalUrl)) { return null; } // We know that these usually 404 by design (bad design?)
45 if (((status !== 200) && (status !== 201) && (status !== 204) && (status !== 304) && (status !== 302)) || (elapsed > 500)) {
46 return `[${config.clusterID}] \x1b[90m${req.method} ${req.originalUrl} \x1b[${color}m${res.statusCode} \x1b[${elapsedColor}m${elapsed}ms\x1b[0m`;
47 }
48 return null;
49};
50
51const developmentLogging = function(tokens, req, res) {
52 const status = res.statusCode;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected