Skip to content

Commit b5ffbc6

Browse files
authoredJan 26, 2017
Add more logging for GET api (sonic-net#153)
1 parent d6e7827 commit b5ffbc6

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed
 

‎lib/src/sai_redis_generic_get.cpp

+30-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,35 @@ sai_status_t internal_redis_get_process(
3939
return status;
4040
}
4141

42+
std::string getSelectResultAsString(int result)
43+
{
44+
SWSS_LOG_ENTER();
45+
46+
std::string res;
47+
48+
switch (result)
49+
{
50+
case swss::Select::FD:
51+
res = "FD";
52+
break;
53+
54+
case swss::Select::ERROR:
55+
res = "ERROR";
56+
break;
57+
58+
case swss::Select::TIMEOUT:
59+
res = "TIMEOUT";
60+
break;
61+
62+
default:
63+
SWSS_LOG_WARN("non recognized select result: %d", result);
64+
res = std::to_string(result);
65+
break;
66+
}
67+
68+
return res;
69+
}
70+
4271
sai_status_t internal_redis_generic_get(
4372
_In_ sai_object_type_t object_type,
4473
_In_ const std::string &serialized_object_id,
@@ -118,7 +147,7 @@ sai_status_t internal_redis_generic_get(
118147
return status;
119148
}
120149

121-
SWSS_LOG_ERROR("generic get failed to get response result: %d", result);
150+
SWSS_LOG_ERROR("generic get failed due to SELECT operation result: %s", getSelectResultAsString(result).c_str());
122151
break;
123152
}
124153

‎syncd/syncd.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,14 @@ void internal_syncd_get_send(
559559

560560
std::string key = str_status;
561561

562+
SWSS_LOG_INFO("sending response for GET api with status: %s", str_status.c_str());
563+
562564
// since we have only one get at a time, we don't have to serialize
563565
// object type and object id, only get status is required
564566
// get response will not put any data to table only queue is used
565567
getResponse->set(key, entry, "getresponse");
568+
569+
SWSS_LOG_INFO("response for GET api was send");
566570
}
567571

568572
swss::ProducerTable *getResponse = NULL;
@@ -1289,6 +1293,12 @@ sai_status_t processEvent(swss::ConsumerTable &consumer)
12891293

12901294
if (api == SAI_COMMON_API_GET)
12911295
{
1296+
if (status != SAI_STATUS_SUCCESS)
1297+
{
1298+
SWSS_LOG_WARN("get API for key: %s op: %s returned status: %s", key.c_str(), op.c_str(),
1299+
sai_serialize_status(status).c_str());
1300+
}
1301+
12921302
internal_syncd_get_send(object_type, str_object_id, status, attr_count, attr_list);
12931303
}
12941304
else if (status != SAI_STATUS_SUCCESS)

0 commit comments

Comments
 (0)