Skip to content

Commit f081ec8

Browse files
authored
Add missing SWSS_LOG_ENTER macros (sonic-net#282)
* Add missing SWSS_LOG_ENTER macros * Fix missing include
1 parent 9364b7e commit f081ec8

23 files changed

+268
-9
lines changed

lib/src/sai_redis_switch.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ sai_status_t redis_set_switch_attribute(
221221
_In_ sai_object_id_t switch_id,
222222
_In_ const sai_attribute_t *attr)
223223
{
224+
// SWSS_LOG_ENTER() omitted here, defined below after mutex
225+
224226
if (attr != NULL && attr->id == SAI_REDIS_SWITCH_ATTR_PERFORM_LOG_ROTATE)
225227
{
226228
/*

meta/sai_extra_mirror.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ sai_status_t is_header_version_ok(
55
_In_ uint32_t attr_count,
66
_In_ const sai_attribute_t *attr_list)
77
{
8+
SWSS_LOG_ENTER();
9+
810
const sai_attribute_t* attr_iphdr_version = get_attribute_by_id(SAI_MIRROR_SESSION_ATTR_IPHDR_VERSION, attr_count, attr_list);
911

1012
if (attr_iphdr_version != NULL)

meta/sai_meta.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ static bool meta_unittests_get_and_erase_set_readonly_flag(
9898
bool is_ipv6_mask_valid(
9999
_In_ const uint8_t* mask)
100100
{
101+
SWSS_LOG_ENTER();
102+
101103
if (mask == NULL)
102104
{
103105
SWSS_LOG_ERROR("mask is null");
@@ -189,6 +191,7 @@ class SaiAttrWrapper
189191

190192
const sai_attribute_t* getattr() const
191193
{
194+
SWSS_LOG_ENTER();
192195
return &m_attr;
193196
}
194197

@@ -203,6 +206,8 @@ class SaiAttrWrapper
203206

204207
std::string get_attr_info(const sai_attr_metadata_t& md)
205208
{
209+
SWSS_LOG_ENTER();
210+
206211
/*
207212
* Attribute name will contain object type as well so we don't need to
208213
* serialize object type separatly.
@@ -463,6 +468,8 @@ void set_object(
463468
const std::vector<std::shared_ptr<SaiAttrWrapper>> get_object_attributes(
464469
_In_ const sai_object_meta_key_t& meta_key)
465470
{
471+
SWSS_LOG_ENTER();
472+
466473
std::string key = sai_serialize_object_meta_key(meta_key);
467474

468475
if (!object_exists(key))
@@ -641,6 +648,8 @@ sai_status_t meta_genetic_validation_list(
641648
_In_ uint32_t count,
642649
_In_ const void* list)
643650
{
651+
SWSS_LOG_ENTER();
652+
644653
if (count > MAX_LIST_COUNT)
645654
{
646655
META_LOG_ERROR(md, "list count %u is > then max list count %u", count, MAX_LIST_COUNT);

meta/saiattributelist.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ std::vector<swss::FieldValueTuple> SaiAttributeList::serialize_attr_list(
5858
_In_ const sai_attribute_t *attr_list,
5959
_In_ bool countOnly)
6060
{
61+
SWSS_LOG_ENTER();
62+
6163
std::vector<swss::FieldValueTuple> entry;
6264

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

8688
sai_attribute_t* SaiAttributeList::get_attr_list()
8789
{
90+
SWSS_LOG_ENTER();
91+
8892
return m_attr_list.data();
8993
}
9094

9195
uint32_t SaiAttributeList::get_attr_count()
9296
{
97+
SWSS_LOG_ENTER();
98+
9399
return (uint32_t)m_attr_list.size();
94100
}

meta/saiserialize.cpp

+46
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ using json = nlohmann::json;
1414
int char_to_int(
1515
_In_ const char c)
1616
{
17+
SWSS_LOG_ENTER();
18+
1719
if (c >= '0' && c <= '9')
1820
return c - '0';
1921

@@ -29,6 +31,8 @@ int char_to_int(
2931
template<class T, typename U>
3032
T* sai_alloc_n_of_ptr_type(U count, T*)
3133
{
34+
SWSS_LOG_ENTER();
35+
3236
return new T[count];
3337
}
3438

@@ -37,6 +41,8 @@ void sai_alloc_list(
3741
_In_ T count,
3842
_In_ U &element)
3943
{
44+
SWSS_LOG_ENTER();
45+
4046
element.count = count;
4147
element.list = sai_alloc_n_of_ptr_type(count, element.list);
4248
}
@@ -45,6 +51,8 @@ template<typename T>
4551
void sai_free_list(
4652
_In_ T &element)
4753
{
54+
SWSS_LOG_ENTER();
55+
4856
delete[] element.list;
4957
element.list = NULL;
5058
}
@@ -54,6 +62,8 @@ void transfer_primitive(
5462
_In_ const T &src_element,
5563
_In_ T &dst_element)
5664
{
65+
SWSS_LOG_ENTER();
66+
5767
const unsigned char* src_mem = reinterpret_cast<const unsigned char*>(&src_element);
5868
unsigned char* dst_mem = reinterpret_cast<unsigned char*>(&dst_element);
5969

@@ -66,6 +76,8 @@ sai_status_t transfer_list(
6676
_In_ T &dst_element,
6777
_In_ bool countOnly)
6878
{
79+
SWSS_LOG_ENTER();
80+
6981
if (countOnly || dst_element.count == 0)
7082
{
7183
transfer_primitive(src_element.count, dst_element.count);
@@ -115,6 +127,8 @@ sai_status_t transfer_attribute(
115127
_In_ sai_attribute_t &dst_attr,
116128
_In_ bool countOnly)
117129
{
130+
SWSS_LOG_ENTER();
131+
118132
switch (serialization_type)
119133
{
120134
case SAI_ATTR_VALUE_TYPE_BOOL:
@@ -378,6 +392,8 @@ sai_status_t transfer_attributes(
378392
_In_ sai_attribute_t *dst_attr_list,
379393
_In_ bool countOnly)
380394
{
395+
SWSS_LOG_ENTER();
396+
381397
for (uint32_t i = 0; i < attr_count; i++)
382398
{
383399
const sai_attribute_t &src_attr = src_attr_list[i];
@@ -571,6 +587,8 @@ std::string sai_serialize_enum(
571587
_In_ const int32_t value,
572588
_In_ const sai_enum_metadata_t* meta)
573589
{
590+
SWSS_LOG_ENTER();
591+
574592
if (meta == NULL)
575593
{
576594
return sai_serialize_number(value);
@@ -593,6 +611,8 @@ std::string sai_serialize_number(
593611
_In_ const uint32_t number,
594612
_In_ bool hex)
595613
{
614+
SWSS_LOG_ENTER();
615+
596616
return sai_serialize_number<uint32_t>(number, hex);
597617
}
598618

@@ -623,12 +643,16 @@ std::string sai_serialize_common_api(
623643
std::string sai_serialize_object_type(
624644
_In_ const sai_object_type_t object_type)
625645
{
646+
SWSS_LOG_ENTER();
647+
626648
return sai_serialize_enum(object_type, &sai_metadata_enum_sai_object_type_t);
627649
}
628650

629651
std::string sai_serialize_attr_value_type(
630652
_In_ const sai_attr_value_type_t attr_value_type)
631653
{
654+
SWSS_LOG_ENTER();
655+
632656
return sai_serialize_enum(attr_value_type, &sai_metadata_enum_sai_attr_value_type_t);
633657
}
634658

@@ -824,6 +848,8 @@ std::string sai_serialize_ip_address(
824848
std::string sai_serialize_object_id(
825849
_In_ sai_object_id_t oid)
826850
{
851+
SWSS_LOG_ENTER();
852+
827853
char buf[32];
828854

829855
snprintf(buf, sizeof(buf), "oid:0x%lx", oid);
@@ -900,6 +926,8 @@ std::string sai_serialize_number_list(
900926
json sai_serialize_qos_map_params(
901927
_In_ const sai_qos_map_params_t& params)
902928
{
929+
SWSS_LOG_ENTER();
930+
903931
json j;
904932

905933
j["tc"] = params.tc;
@@ -916,6 +944,8 @@ json sai_serialize_qos_map_params(
916944
json sai_serialize_qos_map(
917945
_In_ const sai_qos_map_t& qosmap)
918946
{
947+
SWSS_LOG_ENTER();
948+
919949
json j;
920950

921951
j["key"] = sai_serialize_qos_map_params(qosmap.key);
@@ -958,6 +988,8 @@ std::string sai_serialize_qos_map_list(
958988
json sai_serialize_tunnel_map_params(
959989
_In_ const sai_tunnel_map_params_t& params)
960990
{
991+
SWSS_LOG_ENTER();
992+
961993
json j;
962994

963995
j["oecn"] = params.oecn;
@@ -971,6 +1003,8 @@ json sai_serialize_tunnel_map_params(
9711003
json sai_serialize_tunnel_map(
9721004
_In_ const sai_tunnel_map_t& tunnelmap)
9731005
{
1006+
SWSS_LOG_ENTER();
1007+
9741008
json j;
9751009

9761010
j["key"] = sai_serialize_tunnel_map_params(tunnelmap.key);
@@ -1574,6 +1608,8 @@ void sai_deserialize_number(
15741608
_Out_ T& number,
15751609
_In_ bool hex = false)
15761610
{
1611+
SWSS_LOG_ENTER();
1612+
15771613
errno = 0;
15781614

15791615
char *endptr = NULL;
@@ -1591,6 +1627,8 @@ void sai_deserialize_number(
15911627
_Out_ uint32_t& number,
15921628
_In_ bool hex)
15931629
{
1630+
SWSS_LOG_ENTER();
1631+
15941632
sai_deserialize_number<uint32_t>(s, number, hex);
15951633
}
15961634

@@ -1599,6 +1637,8 @@ void sai_deserialize_enum(
15991637
_In_ const sai_enum_metadata_t *meta,
16001638
_Out_ int32_t& value)
16011639
{
1640+
SWSS_LOG_ENTER();
1641+
16021642
if (meta == NULL)
16031643
{
16041644
return sai_deserialize_number(s, value);
@@ -1646,6 +1686,8 @@ void sai_deserialize_object_id(
16461686
_In_ const std::string& s,
16471687
_Out_ sai_object_id_t& oid)
16481688
{
1689+
SWSS_LOG_ENTER();
1690+
16491691
if (s.find("oid:0x") != 0)
16501692
{
16511693
SWSS_LOG_THROW("invalid oid %s", s.c_str());
@@ -2340,6 +2382,8 @@ void sai_deserialize_object_type(
23402382
_In_ const std::string& s,
23412383
_Out_ sai_object_type_t& object_type)
23422384
{
2385+
SWSS_LOG_ENTER();
2386+
23432387
sai_deserialize_enum(s, &sai_metadata_enum_sai_object_type_t, (int32_t&)object_type);
23442388
}
23452389

@@ -2357,6 +2401,8 @@ void sai_deserialize_fdb_entry_bridge_type(
23572401
_In_ const std::string& s,
23582402
_Out_ sai_fdb_entry_bridge_type_t& fdb_entry_bridge_type)
23592403
{
2404+
SWSS_LOG_ENTER();
2405+
23602406
sai_deserialize_enum(s, &sai_metadata_enum_sai_fdb_entry_bridge_type_t, (int32_t&)fdb_entry_bridge_type);
23612407
}
23622408
#endif

saidiscovery/saidiscovery.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,8 @@ void handleProfileMap(
473473

474474
void printUsage()
475475
{
476+
SWSS_LOG_ENTER();
477+
476478
std::cout << std::endl;
477479
std::cout << "Usage: saidiscovery [-I] [-D] [-f] [-d] [-p profile] [-w] [-h]" << std::endl << std::endl;
478480
std::cout << " -I --noInitSwitch:" << std::endl;

saiplayer/saiplayer.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ void translate_local_to_redis(
212212

213213
sai_object_type_t deserialize_object_type(const std::string& s)
214214
{
215+
SWSS_LOG_ENTER();
216+
215217
sai_object_type_t object_type;
216218

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

222224
const std::vector<swss::FieldValueTuple> get_values(const std::vector<std::string>& items)
223225
{
226+
SWSS_LOG_ENTER();
227+
224228
std::vector<swss::FieldValueTuple> values;
225229

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

12361240
void printUsage()
12371241
{
1242+
SWSS_LOG_ENTER();
1243+
12381244
std::cout << "Usage: saiplayer [-h] recordfile" << std::endl << std::endl;
12391245
std::cout << " -C --skipNotifySyncd:" << std::endl;
12401246
std::cout << " Will not send notify init/apply view to syncd" << std::endl << std::endl;

saisdkdump/saisdkdump.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ std::string sai_profile = "/tmp/sai.profile";
1616

1717
void print_usage()
1818
{
19+
SWSS_LOG_ENTER();
20+
1921
std::cerr << "Following SAI dump options can be specified:" << std::endl;
2022
std::cerr << "-------------------------------------------" << std::endl;
2123
std::cerr << "--dump_file -f Full path for dump file" << std::endl;
@@ -25,10 +27,13 @@ void print_usage()
2527

2628
__attribute__((__noreturn__)) void exit_with_sai_failure(const char *msg, sai_status_t status)
2729
{
30+
SWSS_LOG_ENTER();
31+
2832
if (msg)
2933
{
3034
std::cerr << msg << " rc=" << status << std::endl;
3135
}
36+
3237
SWSS_LOG_ERROR("saisdkdump exited with SAI rc: 0x%x, msg: %s .", status, (msg != NULL ? msg : ""));
3338
exit(EXIT_FAILURE);
3439
}
@@ -37,6 +42,8 @@ const char* profile_get_value(
3742
_In_ sai_switch_profile_id_t profile_id,
3843
_In_ const char* variable)
3944
{
45+
SWSS_LOG_ENTER();
46+
4047
return sai_profile.c_str();
4148
}
4249

@@ -45,6 +52,7 @@ int profile_get_next_value(
4552
_Out_ const char** variable,
4653
_Out_ const char** value)
4754
{
55+
SWSS_LOG_ENTER();
4856
return -1;
4957
}
5058

@@ -146,7 +154,7 @@ int main(int argc, char **argv)
146154
status = switch_api->remove_switch(switch_id);
147155
if (status != SAI_STATUS_SUCCESS)
148156
{
149-
SWSS_LOG_ERROR("remove switch 0x%x failed: 0x%x", switch_id, status);
157+
SWSS_LOG_ERROR("remove switch 0x%lx failed: 0x%x", switch_id, status);
150158
}
151159

152160
status = sai_api_uninitialize();

syncd/main.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
#include "swss/logger.h"
12

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

45
int main(int argc, char **argv)
56
{
7+
SWSS_LOG_ENTER();
8+
69
return syncd_main(argc, argv);
710
}

0 commit comments

Comments
 (0)