Skip to content

Commit

Permalink
[Darwin] Add a MdnsContexts::Print method for debugging purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple committed Dec 9, 2024
1 parent af8d173 commit 807964f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/platform/Darwin/DnssdContexts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,36 @@ CHIP_ERROR MdnsContexts::Has(GenericContext * context)
return CHIP_ERROR_KEY_NOT_FOUND;
}

#ifdef DEBUG
void MdnsContexts::Print() const
{
ChipLogDetail(Discovery, "MdnsContexts:");
std::vector<GenericContext *>::const_iterator iter = mContexts.cbegin();
while (iter != mContexts.cend())
{
const char * contextType = "Unknown";
switch ((*iter)->type)
{
case ContextType::Register:
contextType = "Register";
break;
case ContextType::Browse:
contextType = "Browse";
break;
case ContextType::BrowseWithDelegate:
contextType = "BrowseWithDelegate";
break;
case ContextType::Resolve:
contextType = "Resolve";
break;
}

ChipLogDetail(Discovery, "\t%p: %s", *iter, contextType);
iter++;
}
}
#endif // DEBUG

CHIP_ERROR MdnsContexts::GetRegisterContextOfTypeAndName(const char * type, const char * name, RegisterContext ** context)
{
bool found = false;
Expand Down
3 changes: 3 additions & 0 deletions src/platform/Darwin/DnssdImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class MdnsContexts
CHIP_ERROR Remove(GenericContext * context);
CHIP_ERROR RemoveAllOfType(ContextType type);
CHIP_ERROR Has(GenericContext * context);
#ifdef DEBUG
void Print() const;
#endif

/**
* @brief
Expand Down

0 comments on commit 807964f

Please sign in to comment.