From 6a939e941a2f7a10bc0273093da2d213c621b533 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 27 Mar 2024 10:33:19 -0400 Subject: [PATCH] Log message send failures. (#32742) We're not actually clearly logging when messages fail to send (e.g. due to no route to host). We should be. --- src/transport/SessionManager.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/transport/SessionManager.cpp b/src/transport/SessionManager.cpp index 78f9d98d79600f..34237c048b11f2 100644 --- a/src/transport/SessionManager.cpp +++ b/src/transport/SessionManager.cpp @@ -446,7 +446,14 @@ CHIP_ERROR SessionManager::SendPreparedMessage(const SessionHandle & sessionHand if (mTransportMgr != nullptr) { - return mTransportMgr->SendMessage(*destination, std::move(msgBuf)); + CHIP_ERROR err = mTransportMgr->SendMessage(*destination, std::move(msgBuf)); +#if CHIP_ERROR_LOGGING + char addressStr[Transport::PeerAddress::kMaxToStringSize] = { 0 }; + destination->ToString(addressStr); + + ChipLogError(Inet, "SendMessage() to %s failed: %" CHIP_ERROR_FORMAT, addressStr, err.Format()); +#endif // CHIP_ERROR_LOGGING + return err; } ChipLogError(Inet, "The transport manager is not initialized. Unable to send the message");