Skip to content

Commit

Permalink
log level changes with INFO level
Browse files Browse the repository at this point in the history
  • Loading branch information
ekoby committed Jan 12, 2023
1 parent f9f80fd commit 00c1720
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions library/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,23 +129,29 @@ static void init_uv_mbed_log();
void ziti_log_init(uv_loop_t *loop, int level, log_writer log_func) {
init_uv_mbed_log();

if (level == ZITI_LOG_DEFAULT_LEVEL) {
level = ziti_log_lvl;
} // in case it was set before

init_debug(loop);

ziti_log_set_level(level, NULL);
if (level == ZITI_LOG_DEFAULT_LEVEL) {
level = ziti_log_lvl;
}

if (log_func == NULL) {
// keep the logger if it was already set
ziti_log_set_logger(logger ? logger : default_log_writer);
} else {
ziti_log_set_logger(log_func);
}

ziti_log_set_level(level, NULL);
}

void ziti_log_set_level(int level, const char *marker) {
if (level > TRACE) {
level = TRACE;
} else if (level < 0) {
level = ZITI_LOG_DEFAULT_LEVEL;
}

if (level == ZITI_LOG_DEFAULT_LEVEL) {
if (marker) {
model_map_remove(&log_levels, marker);
Expand All @@ -162,9 +168,9 @@ void ziti_log_set_level(int level, const char *marker) {
}

if (logger) {
char msg[128];
int len = snprintf(msg, sizeof(msg), "set log level: %s=%d", marker ? marker : "root", level);
logger(INFO, "ziti_log_set_level", msg, len);
int l = level == ZITI_LOG_DEFAULT_LEVEL ? ziti_log_lvl : level;
const char *lbl = level_labels[l];
ZITI_LOG(INFO, "set log level: %s=%d/%s", marker ? marker : "root", l, lbl);
}
}

Expand Down

0 comments on commit 00c1720

Please sign in to comment.