Optimizations (#4135)

* removes costly json serialization to InMemoryCacheAdapter

* Always cache a copy of the array

* Use own mapValues

* Makes sure we dont make unnecessary calls to the logger

* Do not bypass loggers with silent logging (only applies to stdout)

* warn is not warning

* use ===

* Wrap logRequest / logResponse in the loggerController for more granular control

Also give the ability to pass functions to the logger so we don't serialize too early in JSON (costly)

* reconfiguring winston would override the transports levels and make subsequent tests fail
This commit is contained in:
Florent Vilmart
2017-09-04 20:47:49 -04:00
committed by GitHub
parent 17f4dcd176
commit 3079270b3e
8 changed files with 118 additions and 33 deletions

View File

@@ -142,12 +142,13 @@ function makeExpressHandler(appId, promiseHandler) {
try {
const url = maskSensitiveUrl(req);
const body = Object.assign({}, req.body);
const stringifiedBody = JSON.stringify(body, null, 2);
log.verbose(`REQUEST for [${req.method}] ${url}: ${stringifiedBody}`, {
method: req.method,
url: url,
headers: req.headers,
body: body
const method = req.method;
const headers = req.headers;
log.logRequest({
method,
url,
headers,
body
});
promiseHandler(req).then((result) => {
if (!result.response && !result.location && !result.text) {
@@ -155,11 +156,7 @@ function makeExpressHandler(appId, promiseHandler) {
throw 'control should not get here';
}
const stringifiedResponse = JSON.stringify(result, null, 2);
log.verbose(
`RESPONSE from [${req.method}] ${url}: ${stringifiedResponse}`,
{result: result}
);
log.logResponse({ method, url, result });
var status = result.status || 200;
res.status(status);