From cbae3483500e887482502862aefaea97b77cb756 Mon Sep 17 00:00:00 2001 From: Niven Date: Sat, 13 Jan 2024 14:16:47 +0800 Subject: [PATCH 1/2] Clean up logs formatting --- src/rest.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/rest.cpp b/src/rest.cpp index 18bfd0faec..8dba617cfb 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -645,7 +645,7 @@ static bool rest_blockchain_readiness(HTTPRequest* req, const std::string&) { if (status["health_status"].get_bool()) { req->WriteHeader("Content-Type", "text/plain"); - req->WriteReply(HTTP_OK, "Health status: Ready - sync-to-tip: true, active-peers: true."); + req->WriteReply(HTTP_OK, "Health status: Ready - sync-to-tip: true, active-peers: true.\n"); return true; } else { std::string syncToTip = "false"; @@ -656,17 +656,17 @@ static bool rest_blockchain_readiness(HTTPRequest* req, const std::string&) { if (status["active_peer_nodes"].get_bool()) { activePeerNodes = "true"; } - RESTERR(req, HTTP_SERVICE_UNAVAILABLE, strprintf("Health status: Not ready - sync-to-tip: %s, active-peers: %s.", syncToTip, activePeerNodes)); + RESTERR(req, HTTP_SERVICE_UNAVAILABLE, strprintf("Health status: Not ready - sync-to-tip: %s, active-peers: %s.\n", syncToTip, activePeerNodes)); return false; } } catch (const UniValue& objError) { HTTPStatusCode nStatus = HTTP_INTERNAL_SERVER_ERROR; std::string msg = ""; int code = find_value(objError, "code").get_int(); - - if (code == RPC_CLIENT_P2P_DISABLED) + if (code == RPC_CLIENT_P2P_DISABLED) { nStatus = HTTP_SERVICE_UNAVAILABLE; - msg = "Error: Peer-to-peer functionality missing or disabled"; + msg = "Error: Peer-to-peer functionality missing or disabled\n"; + } RESTERR(req, nStatus, msg); return false; } catch (const std::exception& e) { From 1548d52c1f8633dda103d556bb773a0c0ae1b2f1 Mon Sep 17 00:00:00 2001 From: Niven Date: Sat, 13 Jan 2024 14:20:57 +0800 Subject: [PATCH 2/2] Better response --- src/rest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rest.cpp b/src/rest.cpp index 8dba617cfb..4dd58a31a7 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -665,7 +665,7 @@ static bool rest_blockchain_readiness(HTTPRequest* req, const std::string&) { int code = find_value(objError, "code").get_int(); if (code == RPC_CLIENT_P2P_DISABLED) { nStatus = HTTP_SERVICE_UNAVAILABLE; - msg = "Error: Peer-to-peer functionality missing or disabled\n"; + msg = "Health status: Not ready - peer-to-peer functionality missing or disabled.\n"; } RESTERR(req, nStatus, msg); return false;