Skip to content

Commit ca8d5b5

Browse files
removed hacks; Added set log level API
1 parent bcfb876 commit ca8d5b5

File tree

2 files changed

+12
-35
lines changed

2 files changed

+12
-35
lines changed

common/events.cpp

+11-26
Original file line numberDiff line numberDiff line change
@@ -560,49 +560,34 @@ event_receive_wrap(void *handle, char *event_str,
560560
}
561561
string json_str(res.dump());
562562
rc = snprintf(event_str, event_str_sz, "%s", json_str.c_str());
563+
if (rc >= event_str_sz) {
564+
SWSS_LOG_ERROR("truncated event buffer.need=%d given=%d",
565+
rc, event_str_sz);
566+
event_str[event_str_sz-1] = 0;
567+
}
563568

564569
int rc_missed = snprintf(missed_cnt_str, missed_cnt_str_sz, "%d", missed_cnt);
565570
if (rc_missed >= missed_cnt_str_sz) {
566571
SWSS_LOG_ERROR("missed cnt (%d) buffer.need=%d given=%d",
567572
missed_cnt, rc_missed, missed_cnt_str_sz);
573+
missed_cnt_str[missed_cnt_str_sz-1] = 0;
568574
}
569575
}
570576
else if (rc > 0) {
571577
// timoeut
572578
rc = 0;
573579
}
574580

575-
return rc;
576-
}
577-
578-
int event_receive_wrap_1(void *handle)
579-
{
580-
SWSS_LOG_DEBUG("event_receive_wrap_1 called handle=%p", handle);
581-
return 0;
582-
}
581+
SWSS_LOG_DEBUG("events_receive_wrap rc=%d event_str=%s missed=%s\n",
582+
rc, event_str, missed_cnt_str);
583583

584-
int event_receive_wrap_2(char *event_str, int sz)
585-
{
586-
SWSS_LOG_DEBUG("event_receive_wrap_2 called sz=%d", sz);
587-
return 0;
584+
return rc;
588585
}
589586

590-
int event_receive_wrap_3(char *event_str,
591-
int event_str_sz, char *missed_cnt, int missed_cnt_sz)
592-
{
593-
SWSS_LOG_DEBUG("event_receive_wrap_3 called sz=%d, %d", event_str_sz, missed_cnt_sz);
594-
return 0;
595-
}
596587

597-
int event_receive_wrap_4(void *handle, char *event_str)
588+
void swssSetLogPriority(int pri)
598589
{
599-
SWSS_LOG_DEBUG("event_receive_wrap_4 called handle=%p", handle);
600-
return 0;
590+
swss::Logger::setMinPrio((swss::Logger::Priority) pri);
601591
}
602592

603-
int event_receive_wrap_5(const char *event_str)
604-
{
605-
SWSS_LOG_DEBUG("event_receive_wrap_5 called ");
606-
return 0;
607-
}
608593

common/events_wrap.h

+1-9
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,7 @@ void events_deinit_subscriber_wrap(void *handle);
135135
int event_receive_wrap(void *handle, char *event_str,
136136
int event_str_sz, char *missed_cnt, int missed_cnt_sz);
137137

138-
int event_receive_wrap_1(void *handle);
139-
140-
int event_receive_wrap_2(char *event_str, int sz);
141-
int event_receive_wrap_3(char *event_str,
142-
int event_str_sz, char *missed_cnt, int missed_cnt_sz);
143-
144-
int event_receive_wrap_4(void *handle, char *event_str);
145-
146-
int event_receive_wrap_5(const char *event_str);
138+
void swssSetLogPriority(int pri);
147139

148140
#ifdef __cplusplus
149141
}

0 commit comments

Comments
 (0)