Skip to content

Commit 3830b97

Browse files
authored
[sairedis] Add comment api to recorder (sonic-net#883)
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.
1 parent 6a5f379 commit 3830b97

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

lib/inc/Recorder.h

+3
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,9 @@ namespace sairedis
379379

380380
void requestLogRotate();
381381

382+
void recordComment(
383+
_In_ const std::string& comment);
384+
382385
public: // static helper functions
383386

384387
static std::string getTimestamp();

lib/src/Recorder.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -1153,3 +1153,11 @@ void Recorder::recordBulkGenericResponse(
11531153
recordLine("E|" + sai_serialize_status(status) + "|" + statuses);
11541154
}
11551155
}
1156+
1157+
void Recorder::recordComment(
1158+
_In_ const std::string& comment)
1159+
{
1160+
SWSS_LOG_ENTER();
1161+
1162+
recordLine("#|" + comment);
1163+
}

lib/src/RedisRemoteSaiInterface.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ sai_status_t RedisRemoteSaiInterface::create(
194194

195195
auto hwinfo = getHardwareInfo(attr_count, attr_list);
196196

197+
if (hwinfo.size())
198+
{
199+
m_recorder->recordComment("SAI_SWITCH_ATTR_SWITCH_HARDWARE_INFO=" + hwinfo);
200+
}
201+
197202
switchId = m_virtualObjectIdManager->allocateNewSwitchObjectId(hwinfo);
198203

199204
*objectId = switchId;

0 commit comments

Comments
 (0)