Skip to content

Commit a9d686e

Browse files
committed
rename log suppression functions
1 parent e656775 commit a9d686e

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

includes/ziti/ziti_log.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ ZITI_FUNC extern void ziti_log_set_level(int level, const char *marker);
103103

104104
// set limit for repeated log messages. set to negative value to log all messages.
105105
// default is -1.
106-
ZITI_FUNC extern void ziti_log_set_repeat_limit(int32_t n);
106+
ZITI_FUNC extern void ziti_log_set_suppress_threshold(int32_t n);
107107

108-
// log a notification message after a message is suppressed n times
109-
ZITI_FUNC extern void ziti_log_set_repeat_notify_count(uint32_t n);
108+
// log a notification message after a message is suppressed n times. default is 500.
109+
ZITI_FUNC extern void ziti_log_set_suppress_notify_count(uint32_t n);
110110

111111
// don't use directly
112112
ZITI_FUNC extern int ziti_log_level(const char *module, const char *file);

library/utils.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ static const char *TLSUV_MODULE = "tlsuv";
115115

116116
static model_map log_levels;
117117
static int ziti_log_lvl = ZITI_LOG_DEFAULT_LEVEL;
118-
static int ziti_log_repeat_limit = -1;
119-
static uint32_t ziti_log_repeat_notify_count = 500;
118+
static int ziti_log_suppress_threshold = -1;
119+
static uint32_t ziti_log_suppress_notify_count = 500;
120120
static FILE *ziti_debug_out;
121121
static bool log_initialized = false;
122122
static uv_pid_t log_pid = 0;
@@ -244,12 +244,12 @@ void ziti_log_set_logger(log_writer log) {
244244
logger = log;
245245
}
246246

247-
void ziti_log_set_repeat_limit(int32_t n) {
248-
ziti_log_repeat_limit = n;
247+
void ziti_log_set_suppress_threshold(int32_t n) {
248+
ziti_log_suppress_threshold = n;
249249
}
250250

251-
void ziti_log_set_repeat_notify_count(uint32_t n) {
252-
ziti_log_repeat_notify_count = n;
251+
void ziti_log_set_suppress_notify_count(uint32_t n) {
252+
ziti_log_suppress_notify_count = n;
253253
}
254254

255255
static void init_uv_mbed_log() {
@@ -395,21 +395,21 @@ void ziti_logger(int level, const char *module, const char *file, unsigned int l
395395
len = (int) loglinelen;
396396
}
397397

398-
if (ziti_log_repeat_limit > 0) {
398+
if (ziti_log_suppress_threshold > 0) {
399399
if (strcmp(logbuf->mesg, logbuf->prev_mesg) == 0) {
400400
logbuf->repeat++;
401-
if (logbuf->repeat >= ziti_log_repeat_limit) {
401+
if (logbuf->repeat >= ziti_log_suppress_threshold) {
402402
if (logbuf->repeat % 500 == 0) {
403403
int l = strlen("previous message repeated 500 times");
404404
logfunc(level, "\b", "previous message repeated 500 times", l);
405405
}
406406
return; // suppress
407407
}
408408
} else {
409-
if (logbuf->repeat > ziti_log_repeat_limit) {
409+
if (logbuf->repeat > ziti_log_suppress_threshold) {
410410
// previous message had been silenced
411411
int l = snprintf(logbuf->prev_mesg, loglinelen, "previous message repeated %u times",
412-
(logbuf->repeat - ziti_log_repeat_limit + 1) % 500);
412+
(logbuf->repeat - ziti_log_suppress_threshold + 1) % 500);
413413
logfunc(level, "\b", logbuf->prev_mesg, l);
414414
}
415415
logbuf->repeat = 0;

tests/util_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static void test_log_writer(int level, const char *loc, const char *msg, size_t
102102

103103
TEST_CASE("check repeated logs are silenced") {
104104
ziti_log_init(uv_default_loop(), INFO, test_log_writer);
105-
ziti_log_set_repeat_limit(5);
105+
ziti_log_set_suppress_threshold(5);
106106
int i;
107107

108108
mesgs_logged = 0;

0 commit comments

Comments
 (0)