Skip to content

Commit

Permalink
[sairedis] Add comment api to recorder (sonic-net#883)
Browse files Browse the repository at this point in the history
Use new api to record hardware info when creating switch for easy read. Since hardware info attribute type is s8list, it will be serialized as array of integers, so to actually improve readability of actual value, put it as comment in recording file.
  • Loading branch information
kcudnik authored Aug 6, 2021
1 parent 6a5f379 commit 3830b97
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/inc/Recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,9 @@ namespace sairedis

void requestLogRotate();

void recordComment(
_In_ const std::string& comment);

public: // static helper functions

static std::string getTimestamp();
Expand Down
8 changes: 8 additions & 0 deletions lib/src/Recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1153,3 +1153,11 @@ void Recorder::recordBulkGenericResponse(
recordLine("E|" + sai_serialize_status(status) + "|" + statuses);
}
}

void Recorder::recordComment(
_In_ const std::string& comment)
{
SWSS_LOG_ENTER();

recordLine("#|" + comment);
}
5 changes: 5 additions & 0 deletions lib/src/RedisRemoteSaiInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ sai_status_t RedisRemoteSaiInterface::create(

auto hwinfo = getHardwareInfo(attr_count, attr_list);

if (hwinfo.size())
{
m_recorder->recordComment("SAI_SWITCH_ATTR_SWITCH_HARDWARE_INFO=" + hwinfo);
}

switchId = m_virtualObjectIdManager->allocateNewSwitchObjectId(hwinfo);

*objectId = switchId;
Expand Down

0 comments on commit 3830b97

Please sign in to comment.