Skip to content

Commit

Permalink
Add more logging for GET api (sonic-net#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik authored Jan 26, 2017
1 parent d6e7827 commit b5ffbc6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
31 changes: 30 additions & 1 deletion lib/src/sai_redis_generic_get.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,35 @@ sai_status_t internal_redis_get_process(
return status;
}

std::string getSelectResultAsString(int result)
{
SWSS_LOG_ENTER();

std::string res;

switch (result)
{
case swss::Select::FD:
res = "FD";
break;

case swss::Select::ERROR:
res = "ERROR";
break;

case swss::Select::TIMEOUT:
res = "TIMEOUT";
break;

default:
SWSS_LOG_WARN("non recognized select result: %d", result);
res = std::to_string(result);
break;
}

return res;
}

sai_status_t internal_redis_generic_get(
_In_ sai_object_type_t object_type,
_In_ const std::string &serialized_object_id,
Expand Down Expand Up @@ -118,7 +147,7 @@ sai_status_t internal_redis_generic_get(
return status;
}

SWSS_LOG_ERROR("generic get failed to get response result: %d", result);
SWSS_LOG_ERROR("generic get failed due to SELECT operation result: %s", getSelectResultAsString(result).c_str());
break;
}

Expand Down
10 changes: 10 additions & 0 deletions syncd/syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,10 +559,14 @@ void internal_syncd_get_send(

std::string key = str_status;

SWSS_LOG_INFO("sending response for GET api with status: %s", str_status.c_str());

// since we have only one get at a time, we don't have to serialize
// object type and object id, only get status is required
// get response will not put any data to table only queue is used
getResponse->set(key, entry, "getresponse");

SWSS_LOG_INFO("response for GET api was send");
}

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

if (api == SAI_COMMON_API_GET)
{
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_WARN("get API for key: %s op: %s returned status: %s", key.c_str(), op.c_str(),
sai_serialize_status(status).c_str());
}

internal_syncd_get_send(object_type, str_object_id, status, attr_count, attr_list);
}
else if (status != SAI_STATUS_SUCCESS)
Expand Down

0 comments on commit b5ffbc6

Please sign in to comment.