logRequest method
Log client side request
Implementation
@override
Future<RequestResponse<FrappeLog?>> logRequest(
{RequestResponse<dynamic>? r, List<String>? tags}) {
if (r == null) {
throw EmptyResponseError();
}
final _tags = ['frontend-request'];
if (tags != null) {
_tags.addAll(tags);
}
final req = r.rawResponse!.requestOptions;
final requestInfo =
'Headers:\n${req.headers}\nParams:\n${json.encode(req.data)}';
final headersInfo = <List<String>>[];
r.rawResponse!.headers.map.forEach((String k, List<String> value) {
headersInfo.add([k, ...value]);
});
var header = '';
headersInfo.forEach((List<String> headerInfo) {
header += '${headerInfo[0]}: ${headerInfo[1]}\n';
});
final responseInfo =
'Status: ${r.rawResponse!.statusCode}\nHeaders:\n$header\n\nBody:\n${json.encode(r.rawResponse!.data)}';
return invokeLogger(
cmd: 'renovation_core.utils.logging.log_client_request',
request: requestInfo,
response: responseInfo,
tags: _tags);
}