Skip to content

Commit

Permalink
Add missing SWSS_LOG_ENTER macros (sonic-net#282)
Browse files Browse the repository at this point in the history
* Add missing SWSS_LOG_ENTER macros

* Fix missing include
  • Loading branch information
kcudnik authored Jan 13, 2018
1 parent 9364b7e commit f081ec8
Show file tree
Hide file tree
Showing 23 changed files with 268 additions and 9 deletions.
2 changes: 2 additions & 0 deletions lib/src/sai_redis_switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ sai_status_t redis_set_switch_attribute(
_In_ sai_object_id_t switch_id,
_In_ const sai_attribute_t *attr)
{
// SWSS_LOG_ENTER() omitted here, defined below after mutex

if (attr != NULL && attr->id == SAI_REDIS_SWITCH_ATTR_PERFORM_LOG_ROTATE)
{
/*
Expand Down
2 changes: 2 additions & 0 deletions meta/sai_extra_mirror.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ sai_status_t is_header_version_ok(
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list)
{
SWSS_LOG_ENTER();

const sai_attribute_t* attr_iphdr_version = get_attribute_by_id(SAI_MIRROR_SESSION_ATTR_IPHDR_VERSION, attr_count, attr_list);

if (attr_iphdr_version != NULL)
Expand Down
9 changes: 9 additions & 0 deletions meta/sai_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ static bool meta_unittests_get_and_erase_set_readonly_flag(
bool is_ipv6_mask_valid(
_In_ const uint8_t* mask)
{
SWSS_LOG_ENTER();

if (mask == NULL)
{
SWSS_LOG_ERROR("mask is null");
Expand Down Expand Up @@ -189,6 +191,7 @@ class SaiAttrWrapper

const sai_attribute_t* getattr() const
{
SWSS_LOG_ENTER();
return &m_attr;
}

Expand All @@ -203,6 +206,8 @@ class SaiAttrWrapper

std::string get_attr_info(const sai_attr_metadata_t& md)
{
SWSS_LOG_ENTER();

/*
* Attribute name will contain object type as well so we don't need to
* serialize object type separatly.
Expand Down Expand Up @@ -463,6 +468,8 @@ void set_object(
const std::vector<std::shared_ptr<SaiAttrWrapper>> get_object_attributes(
_In_ const sai_object_meta_key_t& meta_key)
{
SWSS_LOG_ENTER();

std::string key = sai_serialize_object_meta_key(meta_key);

if (!object_exists(key))
Expand Down Expand Up @@ -641,6 +648,8 @@ sai_status_t meta_genetic_validation_list(
_In_ uint32_t count,
_In_ const void* list)
{
SWSS_LOG_ENTER();

if (count > MAX_LIST_COUNT)
{
META_LOG_ERROR(md, "list count %u is > then max list count %u", count, MAX_LIST_COUNT);
Expand Down
6 changes: 6 additions & 0 deletions meta/saiattributelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ std::vector<swss::FieldValueTuple> SaiAttributeList::serialize_attr_list(
_In_ const sai_attribute_t *attr_list,
_In_ bool countOnly)
{
SWSS_LOG_ENTER();

std::vector<swss::FieldValueTuple> entry;

for (uint32_t index = 0; index < attr_count; ++index)
Expand Down Expand Up @@ -85,10 +87,14 @@ std::vector<swss::FieldValueTuple> SaiAttributeList::serialize_attr_list(

sai_attribute_t* SaiAttributeList::get_attr_list()
{
SWSS_LOG_ENTER();

return m_attr_list.data();
}

uint32_t SaiAttributeList::get_attr_count()
{
SWSS_LOG_ENTER();

return (uint32_t)m_attr_list.size();
}
46 changes: 46 additions & 0 deletions meta/saiserialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ using json = nlohmann::json;
int char_to_int(
_In_ const char c)
{
SWSS_LOG_ENTER();

if (c >= '0' && c <= '9')
return c - '0';

Expand All @@ -29,6 +31,8 @@ int char_to_int(
template<class T, typename U>
T* sai_alloc_n_of_ptr_type(U count, T*)
{
SWSS_LOG_ENTER();

return new T[count];
}

Expand All @@ -37,6 +41,8 @@ void sai_alloc_list(
_In_ T count,
_In_ U &element)
{
SWSS_LOG_ENTER();

element.count = count;
element.list = sai_alloc_n_of_ptr_type(count, element.list);
}
Expand All @@ -45,6 +51,8 @@ template<typename T>
void sai_free_list(
_In_ T &element)
{
SWSS_LOG_ENTER();

delete[] element.list;
element.list = NULL;
}
Expand All @@ -54,6 +62,8 @@ void transfer_primitive(
_In_ const T &src_element,
_In_ T &dst_element)
{
SWSS_LOG_ENTER();

const unsigned char* src_mem = reinterpret_cast<const unsigned char*>(&src_element);
unsigned char* dst_mem = reinterpret_cast<unsigned char*>(&dst_element);

Expand All @@ -66,6 +76,8 @@ sai_status_t transfer_list(
_In_ T &dst_element,
_In_ bool countOnly)
{
SWSS_LOG_ENTER();

if (countOnly || dst_element.count == 0)
{
transfer_primitive(src_element.count, dst_element.count);
Expand Down Expand Up @@ -115,6 +127,8 @@ sai_status_t transfer_attribute(
_In_ sai_attribute_t &dst_attr,
_In_ bool countOnly)
{
SWSS_LOG_ENTER();

switch (serialization_type)
{
case SAI_ATTR_VALUE_TYPE_BOOL:
Expand Down Expand Up @@ -378,6 +392,8 @@ sai_status_t transfer_attributes(
_In_ sai_attribute_t *dst_attr_list,
_In_ bool countOnly)
{
SWSS_LOG_ENTER();

for (uint32_t i = 0; i < attr_count; i++)
{
const sai_attribute_t &src_attr = src_attr_list[i];
Expand Down Expand Up @@ -571,6 +587,8 @@ std::string sai_serialize_enum(
_In_ const int32_t value,
_In_ const sai_enum_metadata_t* meta)
{
SWSS_LOG_ENTER();

if (meta == NULL)
{
return sai_serialize_number(value);
Expand All @@ -593,6 +611,8 @@ std::string sai_serialize_number(
_In_ const uint32_t number,
_In_ bool hex)
{
SWSS_LOG_ENTER();

return sai_serialize_number<uint32_t>(number, hex);
}

Expand Down Expand Up @@ -623,12 +643,16 @@ std::string sai_serialize_common_api(
std::string sai_serialize_object_type(
_In_ const sai_object_type_t object_type)
{
SWSS_LOG_ENTER();

return sai_serialize_enum(object_type, &sai_metadata_enum_sai_object_type_t);
}

std::string sai_serialize_attr_value_type(
_In_ const sai_attr_value_type_t attr_value_type)
{
SWSS_LOG_ENTER();

return sai_serialize_enum(attr_value_type, &sai_metadata_enum_sai_attr_value_type_t);
}

Expand Down Expand Up @@ -824,6 +848,8 @@ std::string sai_serialize_ip_address(
std::string sai_serialize_object_id(
_In_ sai_object_id_t oid)
{
SWSS_LOG_ENTER();

char buf[32];

snprintf(buf, sizeof(buf), "oid:0x%lx", oid);
Expand Down Expand Up @@ -900,6 +926,8 @@ std::string sai_serialize_number_list(
json sai_serialize_qos_map_params(
_In_ const sai_qos_map_params_t& params)
{
SWSS_LOG_ENTER();

json j;

j["tc"] = params.tc;
Expand All @@ -916,6 +944,8 @@ json sai_serialize_qos_map_params(
json sai_serialize_qos_map(
_In_ const sai_qos_map_t& qosmap)
{
SWSS_LOG_ENTER();

json j;

j["key"] = sai_serialize_qos_map_params(qosmap.key);
Expand Down Expand Up @@ -958,6 +988,8 @@ std::string sai_serialize_qos_map_list(
json sai_serialize_tunnel_map_params(
_In_ const sai_tunnel_map_params_t& params)
{
SWSS_LOG_ENTER();

json j;

j["oecn"] = params.oecn;
Expand All @@ -971,6 +1003,8 @@ json sai_serialize_tunnel_map_params(
json sai_serialize_tunnel_map(
_In_ const sai_tunnel_map_t& tunnelmap)
{
SWSS_LOG_ENTER();

json j;

j["key"] = sai_serialize_tunnel_map_params(tunnelmap.key);
Expand Down Expand Up @@ -1574,6 +1608,8 @@ void sai_deserialize_number(
_Out_ T& number,
_In_ bool hex = false)
{
SWSS_LOG_ENTER();

errno = 0;

char *endptr = NULL;
Expand All @@ -1591,6 +1627,8 @@ void sai_deserialize_number(
_Out_ uint32_t& number,
_In_ bool hex)
{
SWSS_LOG_ENTER();

sai_deserialize_number<uint32_t>(s, number, hex);
}

Expand All @@ -1599,6 +1637,8 @@ void sai_deserialize_enum(
_In_ const sai_enum_metadata_t *meta,
_Out_ int32_t& value)
{
SWSS_LOG_ENTER();

if (meta == NULL)
{
return sai_deserialize_number(s, value);
Expand Down Expand Up @@ -1646,6 +1686,8 @@ void sai_deserialize_object_id(
_In_ const std::string& s,
_Out_ sai_object_id_t& oid)
{
SWSS_LOG_ENTER();

if (s.find("oid:0x") != 0)
{
SWSS_LOG_THROW("invalid oid %s", s.c_str());
Expand Down Expand Up @@ -2340,6 +2382,8 @@ void sai_deserialize_object_type(
_In_ const std::string& s,
_Out_ sai_object_type_t& object_type)
{
SWSS_LOG_ENTER();

sai_deserialize_enum(s, &sai_metadata_enum_sai_object_type_t, (int32_t&)object_type);
}

Expand All @@ -2357,6 +2401,8 @@ void sai_deserialize_fdb_entry_bridge_type(
_In_ const std::string& s,
_Out_ sai_fdb_entry_bridge_type_t& fdb_entry_bridge_type)
{
SWSS_LOG_ENTER();

sai_deserialize_enum(s, &sai_metadata_enum_sai_fdb_entry_bridge_type_t, (int32_t&)fdb_entry_bridge_type);
}
#endif
Expand Down
2 changes: 2 additions & 0 deletions saidiscovery/saidiscovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ void handleProfileMap(

void printUsage()
{
SWSS_LOG_ENTER();

std::cout << std::endl;
std::cout << "Usage: saidiscovery [-I] [-D] [-f] [-d] [-p profile] [-w] [-h]" << std::endl << std::endl;
std::cout << " -I --noInitSwitch:" << std::endl;
Expand Down
6 changes: 6 additions & 0 deletions saiplayer/saiplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ void translate_local_to_redis(

sai_object_type_t deserialize_object_type(const std::string& s)
{
SWSS_LOG_ENTER();

sai_object_type_t object_type;

sai_deserialize_object_type(s, object_type);
Expand All @@ -221,6 +223,8 @@ sai_object_type_t deserialize_object_type(const std::string& s)

const std::vector<swss::FieldValueTuple> get_values(const std::vector<std::string>& items)
{
SWSS_LOG_ENTER();

std::vector<swss::FieldValueTuple> values;

// timestamp|action|objecttype:objectid|attrid=value,...
Expand Down Expand Up @@ -1235,6 +1239,8 @@ int replay(int argc, char **argv)

void printUsage()
{
SWSS_LOG_ENTER();

std::cout << "Usage: saiplayer [-h] recordfile" << std::endl << std::endl;
std::cout << " -C --skipNotifySyncd:" << std::endl;
std::cout << " Will not send notify init/apply view to syncd" << std::endl << std::endl;
Expand Down
10 changes: 9 additions & 1 deletion saisdkdump/saisdkdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ std::string sai_profile = "/tmp/sai.profile";

void print_usage()
{
SWSS_LOG_ENTER();

std::cerr << "Following SAI dump options can be specified:" << std::endl;
std::cerr << "-------------------------------------------" << std::endl;
std::cerr << "--dump_file -f Full path for dump file" << std::endl;
Expand All @@ -25,10 +27,13 @@ void print_usage()

__attribute__((__noreturn__)) void exit_with_sai_failure(const char *msg, sai_status_t status)
{
SWSS_LOG_ENTER();

if (msg)
{
std::cerr << msg << " rc=" << status << std::endl;
}

SWSS_LOG_ERROR("saisdkdump exited with SAI rc: 0x%x, msg: %s .", status, (msg != NULL ? msg : ""));
exit(EXIT_FAILURE);
}
Expand All @@ -37,6 +42,8 @@ const char* profile_get_value(
_In_ sai_switch_profile_id_t profile_id,
_In_ const char* variable)
{
SWSS_LOG_ENTER();

return sai_profile.c_str();
}

Expand All @@ -45,6 +52,7 @@ int profile_get_next_value(
_Out_ const char** variable,
_Out_ const char** value)
{
SWSS_LOG_ENTER();
return -1;
}

Expand Down Expand Up @@ -146,7 +154,7 @@ int main(int argc, char **argv)
status = switch_api->remove_switch(switch_id);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("remove switch 0x%x failed: 0x%x", switch_id, status);
SWSS_LOG_ERROR("remove switch 0x%lx failed: 0x%x", switch_id, status);
}

status = sai_api_uninitialize();
Expand Down
3 changes: 3 additions & 0 deletions syncd/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#include "swss/logger.h"

int syncd_main(int argc, char **argv);

int main(int argc, char **argv)
{
SWSS_LOG_ENTER();

return syncd_main(argc, argv);
}
Loading

0 comments on commit f081ec8

Please sign in to comment.