|  | 
| 32 | 32 | #include "utils_common.h" | 
| 33 | 33 | #include "utils_log.h" | 
| 34 | 34 | 
 | 
|  | 35 | +#ifndef DISABLE_SINGLE_LOGGER | 
|  | 36 | +#include "utils_concurrency.h" | 
|  | 37 | +#endif | 
|  | 38 | + | 
| 35 | 39 | #define UMF_MAGIC_STR "\x00@(#) " | 
| 36 | 40 | #define UMF_PREF_STR "Intel(R) " | 
| 37 | 41 | #define UMF_PREFIX UMF_MAGIC_STR UMF_PREF_STR | 
| @@ -60,6 +64,10 @@ char const __umf_str_1__all_cmake_vars[] = | 
| 60 | 64 | #define MAX_FILE_PATH 256 | 
| 61 | 65 | #define MAX_ENV_LEN 2048 | 
| 62 | 66 | 
 | 
|  | 67 | +#ifndef DISABLE_CTL_LOGGER | 
|  | 68 | +static UTIL_ONCE_FLAG initOnce = UTIL_ONCE_FLAG_INIT; | 
|  | 69 | +#endif | 
|  | 70 | + | 
| 63 | 71 | typedef struct { | 
| 64 | 72 |     bool enableTimestamp; | 
| 65 | 73 |     bool enablePid; | 
| @@ -247,7 +255,7 @@ void utils_plog(utils_log_level_t level, const char *func, const char *format, | 
| 247 | 255 | 
 | 
| 248 | 256 | static const char *bool_to_str(int b) { return b ? "yes" : "no"; } | 
| 249 | 257 | 
 | 
| 250 |  | -void utils_log_init(void) { | 
|  | 258 | +static void utils_log_init_once(void) { | 
| 251 | 259 |     const char *envVar = getenv("UMF_LOG"); | 
| 252 | 260 | 
 | 
| 253 | 261 |     if (!envVar) { | 
| @@ -343,6 +351,12 @@ void utils_log_init(void) { | 
| 343 | 351 | } | 
| 344 | 352 | 
 | 
| 345 | 353 | // this is needed for logger unit test | 
|  | 354 | +#ifndef DISABLE_SINGLE_LOGGER | 
|  | 355 | +void utils_log_init(void) { utils_init_once(&initOnce, utils_log_init_once); } | 
|  | 356 | +#else // DISABLE_SINGLE_LOGGER | 
|  | 357 | +void utils_log_init(void) { utils_log_init_once(); } | 
|  | 358 | +#endif | 
|  | 359 | + | 
| 346 | 360 | #ifndef DISABLE_CTL_LOGGER | 
| 347 | 361 | static umf_result_t | 
| 348 | 362 | CTL_READ_HANDLER(timestamp)(void *ctx, umf_ctl_query_source_t source, void *arg, | 
|  | 
0 commit comments