The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

u/logging: Implement global log level.

Adds a `XRT_LOG` environemnt option.

Example:
```
XRT_LOG=debug
```

authored by

Lubosz Sarnecki and committed by
Jakob Bornecrantz
adcd0aff 8bdff9a6

+33 -5
+26
src/xrt/auxiliary/util/u_logging.c
··· 11 11 #include "xrt/xrt_config_os.h" 12 12 #include "xrt/xrt_config_build.h" 13 13 14 + #include "util/u_debug.h" 15 + 14 16 #include <assert.h> 15 17 #include <stdio.h> 16 18 #include <stdarg.h> 17 19 20 + DEBUG_GET_ONCE_LOG_OPTION(global_log, "XRT_LOG", U_LOGGING_WARN) 21 + 22 + enum u_logging_level global_log_level; 23 + 24 + static bool _is_log_level_initialized; 25 + 26 + void 27 + _log_level_init() 28 + { 29 + if (!_is_log_level_initialized) { 30 + global_log_level = debug_get_log_option_global_log(); 31 + _is_log_level_initialized = true; 32 + } 33 + } 18 34 19 35 #if defined(XRT_OS_ANDROID) 20 36 ··· 42 58 const char *format, 43 59 ...) 44 60 { 61 + _log_level_init(); 45 62 // print_prefix(func, level); 46 63 android_LogPriority prio = u_log_convert_priority(level); 47 64 va_list args; ··· 59 76 const char *format, 60 77 ...) 61 78 { 79 + _log_level_init(); 62 80 android_LogPriority prio = u_log_convert_priority(level); 63 81 va_list args; 64 82 va_start(args, format); ··· 113 131 const char *format, 114 132 ...) 115 133 { 134 + _log_level_init(); 135 + 116 136 char buf[16384] = {0}; 117 137 118 138 int remainingBuffer = sizeof(buf) - 2; ··· 136 156 const char *format, 137 157 ...) 138 158 { 159 + _log_level_init(); 160 + 139 161 char buf[16384] = {0}; 140 162 141 163 int remainingBuffer = sizeof(buf) - 1; ··· 240 262 const char *format, 241 263 ...) 242 264 { 265 + _log_level_init(); 266 + 243 267 print_prefix(func, level); 244 268 245 269 va_list args; ··· 259 283 const char *format, 260 284 ...) 261 285 { 286 + _log_level_init(); 287 + 262 288 print_prefix(func, level); 263 289 264 290 va_list args;
+7 -5
src/xrt/auxiliary/util/u_logging.h
··· 68 68 } while (false) 69 69 70 70 // clang-format off 71 - #define U_LOG_T(...) U_LOG(U_LOGGING_TRACE, __VA_ARGS__) 72 - #define U_LOG_D(...) U_LOG(U_LOGGING_DEBUG, __VA_ARGS__) 73 - #define U_LOG_I(...) U_LOG(U_LOGGING_INFO, __VA_ARGS__) 74 - #define U_LOG_W(...) U_LOG(U_LOGGING_WARN, __VA_ARGS__) 75 - #define U_LOG_E(...) U_LOG(U_LOGGING_ERROR, __VA_ARGS__) 71 + #define U_LOG_T(...) U_LOG_IFL_T(global_log_level, __VA_ARGS__) 72 + #define U_LOG_D(...) U_LOG_IFL_D(global_log_level, __VA_ARGS__) 73 + #define U_LOG_I(...) U_LOG_IFL_I(global_log_level, __VA_ARGS__) 74 + #define U_LOG_W(...) U_LOG_IFL_W(global_log_level, __VA_ARGS__) 75 + #define U_LOG_E(...) U_LOG_IFL_E(global_log_level, __VA_ARGS__) 76 76 77 77 #define U_LOG_IFL_T(cond_level, ...) U_LOG_IFL(U_LOGGING_TRACE, cond_level, __VA_ARGS__) 78 78 #define U_LOG_IFL_D(cond_level, ...) U_LOG_IFL(U_LOGGING_DEBUG, cond_level, __VA_ARGS__) ··· 102 102 U_LOGGING_ERROR, 103 103 U_LOGGING_RAW, //!< Special level for raw printing, prints a new-line. 104 104 }; 105 + 106 + extern enum u_logging_level global_log_level; 105 107 106 108 void 107 109 u_log(const char *file,