Add logging prefixes to api.c client and server

This commit is contained in:
Juliusz Sosinowicz
2023-07-31 13:20:14 +02:00
parent 05b692d01c
commit 158402ab03
3 changed files with 25 additions and 1 deletions
+14 -1
View File
@@ -127,6 +127,7 @@ THREAD_LS_T void *StackSizeCheck_stackOffsetPointer = 0;
/* Set these to default values initially. */
static wolfSSL_Logging_cb log_function = NULL;
static int loggingEnabled = 0;
THREAD_LS_T const char* log_prefix = NULL;
#if defined(WOLFSSL_APACHE_MYNEWT)
#include "log/log.h"
@@ -186,6 +187,15 @@ void wolfSSL_Debugging_OFF(void)
#endif
}
WOLFSSL_API void wolfSSL_SetLoggingPrefix(const char* prefix)
{
#ifdef DEBUG_WOLFSSL
log_prefix = prefix;
#else
(void)prefix;
#endif
}
#ifdef WOLFSSL_FUNC_TIME
/* WARNING: This code is only to be used for debugging performance.
* The code is not thread-safe.
@@ -316,7 +326,10 @@ static void wolfssl_log(const int logLevel, const char *const logMessage)
defined(HAVE_STACK_SIZE_VERBOSE) && defined(HAVE_STACK_SIZE_VERBOSE_LOG)
STACK_SIZE_CHECKPOINT_MSG(logMessage);
#else
fprintf(stderr, "%s\n", logMessage);
if (log_prefix != NULL)
fprintf(stderr, "[%s]: %s\n", log_prefix, logMessage);
else
fprintf(stderr, "%s\n", logMessage);
#endif
}
}