From e2beaae4ec08ed76f80d74811ca782f3f5cf17e7 Mon Sep 17 00:00:00 2001 From: Julius Pfrommer Date: Wed, 13 Nov 2024 08:26:04 +0100 Subject: [PATCH] fix ua-cli logging --- tools/ua-cli/ua.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/ua-cli/ua.c b/tools/ua-cli/ua.c index 1a4c8ea9147..ad6569f9bce 100644 --- a/tools/ua-cli/ua.c +++ b/tools/ua-cli/ua.c @@ -49,14 +49,15 @@ logCategoryNames[UA_LOGCATEGORIES] = static void cliLog(void *context, UA_LogLevel level, UA_LogCategory category, - const char *msg, va_list args) { - if(logLevel > level) - return; + const char *msg, va_list args) { /* Set to fatal if the level is outside the range */ - int logLevelSlot = ((int)level / 100) - 1; - if(logLevelSlot < 0 || logLevelSlot > 5) - logLevelSlot = 5; + int l = ((int)level / 100) - 1; + if(l < 0 || l > 5) + l = 5; + + if((int)logLevel - 1 > l) + return; /* Log */ #define LOGBUFSIZE 512 @@ -64,7 +65,7 @@ cliLog(void *context, UA_LogLevel level, UA_LogCategory category, UA_String out = {LOGBUFSIZE, logbuf}; UA_String_vprintf(&out, msg, args); fprintf(stderr, "%s/%s" ANSI_COLOR_RESET "\t", - logLevelNames[logLevelSlot], logCategoryNames[category]); + logLevelNames[l], logCategoryNames[category]); fprintf(stderr, "%s\n", logbuf); fflush(stderr); }