Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 1x 1x 1x 5x 7x 1x 1x 2x | "use strict";
const _ = require("lodash");
/**
* Send informations about response and request to the logger
*
* @param {Object} logger instance of class which implements log functions
* @param {Number} counter sequence number of current HTTP request/response
* @param {String} requestUrl endpoint which send response
* @param {Object} opts options passed to fetch
* @param {Object} res response from the HTTP server
*
* @memberof Agent
*/
module.exports.logResponse = function (logger, counter, requestUrl, opts, res) {
logger.debug(
`Response #${counter}\t${
opts.method || "GET"
}\t${requestUrl}\t${JSON.stringify(
_.pickBy(
res,
(value, key) =>
_.isString(key) &&
_.find([/status/, /headers/], (regex) => key.match(regex))
)
)}`
);
};
/**
* Send informations about request to the logger
*
* @param {Object} logger instance of class which implements log functions
* @param {Number} counter sequence number of current HTTP request/response
* @param {String} requestUrl endpoint which send response
* @param {Object} opts options passed to fetch
*
* @memberof Agent
*/
module.exports.logRequest = function (logger, counter, requestUrl, opts) {
logger.debug(
`Request #${counter}\t${
opts.method || "GET"
}\t${requestUrl}\t${JSON.stringify(
_.pickBy(opts, (value, key) => {
return key !== "method";
})
)}`
);
};
|