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

Function developmentLogging

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

Source from the content-addressed store, hash-verified

49};
50
51const developmentLogging = function(tokens, req, res) {
52 const status = res.statusCode;
53 let color = 32;
54 if (status >= 500) { color = 31;
55 } else if (status >= 400) { color = 33;
56 } else if (status >= 300) { color = 36; }
57 const elapsed = (new Date()) - req._startTime;
58 const elapsedColor = elapsed < 500 ? 90 : 31;
59 let s = `\x1b[90m${req.method} ${req.originalUrl} \x1b[${color}m${res.statusCode} \x1b[${elapsedColor}m${elapsed}ms\x1b[0m`;
60 if (req.proxied) { s += ' (proxied)'; }
61 return s;
62};
63
64const setupExpressMiddleware = function(app) {
65 if (config.isProduction) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected