Improve logs

This commit is contained in:
Ming Ming 2021-05-24 01:26:28 +08:00
parent 0ad8454c7a
commit f765767ee2

View file

@ -73,10 +73,16 @@ class Api {
final response =
await http.Response.fromStream(await http.Client().send(req));
if (!_isHttpStatusGood(response.statusCode)) {
_log.severe(
"[request] HTTP $method (${response.statusCode}): $endpoint",
response.body,
);
if (response.statusCode == 404) {
_log.severe(
"[request] HTTP $method (${response.statusCode}): $endpoint",
);
} else {
_log.severe(
"[request] HTTP $method (${response.statusCode}): $endpoint",
response.body,
);
}
}
return Response(response.statusCode, response.headers,
isResponseString ? response.body : response.bodyBytes);