Skip to content

Commit

Permalink
Improve server logging on subscription failures. (#33372)
Browse files Browse the repository at this point in the history
* Improve server logging on subscription failures.

1) When logging "session inactive", log which session it is.
2) When a subscription ReadHandler closes, log the relevant subscription ID and
   peer node.

* Address review comment.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Jul 25, 2024
1 parent bf30e5a commit 5262950
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/app/ReadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ void ReadHandler::Close(CloseOptions options)
}
}
#endif // CHIP_CONFIG_PERSIST_SUBSCRIPTIONS

#if CHIP_PROGRESS_LOGGING
if (IsType(InteractionType::Subscribe))
{
const ScopedNodeId & peer = mSessionHandle ? mSessionHandle->GetPeer() : ScopedNodeId();
ChipLogProgress(DataManagement, "Subscription id 0x%" PRIx32 " from node " ChipLogFormatScopedNodeId " torn down",
mSubscriptionId, ChipLogValueScopedNodeId(peer));
}
#endif // CHIP_PROGRESS_LOGGING

MoveToState(HandlerState::AwaitingDestruction);
mManagementCallback.OnDone(*this);
}
Expand Down
7 changes: 6 additions & 1 deletion src/messaging/ExchangeMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,13 @@ ExchangeContext * ExchangeManager::NewContext(const SessionHandle & session, Exc
{
if (!session->IsActiveSession())
{
#if CHIP_ERROR_LOGGING
const ScopedNodeId & peer = session->GetPeer();
ChipLogError(ExchangeManager, "NewContext failed: session %u to " ChipLogFormatScopedNodeId " is inactive",
session->SessionIdForLogging(), ChipLogValueScopedNodeId(peer));
#endif // CHIP_ERROR_LOGGING

// Disallow creating exchange on an inactive session
ChipLogError(ExchangeManager, "NewContext failed: session inactive");
return nullptr;
}
return mContextPool.CreateObject(this, mNextExchangeId++, session, isInitiator, delegate);
Expand Down

0 comments on commit 5262950

Please sign in to comment.