mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-31 19:08:30 +00:00
u/logging: Fix first global log message not getting correct level, add comments
This commit is contained in:
parent
5c6158cc8b
commit
083e4f5108
|
@ -19,17 +19,10 @@
|
||||||
|
|
||||||
DEBUG_GET_ONCE_LOG_OPTION(global_log, "XRT_LOG", U_LOGGING_WARN)
|
DEBUG_GET_ONCE_LOG_OPTION(global_log, "XRT_LOG", U_LOGGING_WARN)
|
||||||
|
|
||||||
enum u_logging_level global_log_level;
|
enum u_logging_level
|
||||||
|
u_log_get_global_level(void)
|
||||||
static bool _is_log_level_initialized;
|
|
||||||
|
|
||||||
void
|
|
||||||
_log_level_init()
|
|
||||||
{
|
{
|
||||||
if (!_is_log_level_initialized) {
|
return debug_get_log_option_global_log();
|
||||||
global_log_level = debug_get_log_option_global_log();
|
|
||||||
_is_log_level_initialized = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(XRT_OS_ANDROID)
|
#if defined(XRT_OS_ANDROID)
|
||||||
|
@ -50,10 +43,10 @@ u_log_convert_priority(enum u_logging_level level)
|
||||||
}
|
}
|
||||||
return ANDROID_LOG_INFO;
|
return ANDROID_LOG_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
u_log(const char *file, int line, const char *func, enum u_logging_level level, const char *format, ...)
|
u_log(const char *file, int line, const char *func, enum u_logging_level level, const char *format, ...)
|
||||||
{
|
{
|
||||||
_log_level_init();
|
|
||||||
// print_prefix(func, level);
|
// print_prefix(func, level);
|
||||||
android_LogPriority prio = u_log_convert_priority(level);
|
android_LogPriority prio = u_log_convert_priority(level);
|
||||||
va_list args;
|
va_list args;
|
||||||
|
@ -71,7 +64,6 @@ u_log_xdev(const char *file,
|
||||||
const char *format,
|
const char *format,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
_log_level_init();
|
|
||||||
android_LogPriority prio = u_log_convert_priority(level);
|
android_LogPriority prio = u_log_convert_priority(level);
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
|
@ -107,7 +99,6 @@ print_prefix(int remainingBuf, char *buf, const char *func, enum u_logging_level
|
||||||
void
|
void
|
||||||
u_log(const char *file, int line, const char *func, enum u_logging_level level, const char *format, ...)
|
u_log(const char *file, int line, const char *func, enum u_logging_level level, const char *format, ...)
|
||||||
{
|
{
|
||||||
_log_level_init();
|
|
||||||
|
|
||||||
char buf[16384] = {0};
|
char buf[16384] = {0};
|
||||||
|
|
||||||
|
@ -131,7 +122,6 @@ u_log_xdev(const char *file,
|
||||||
const char *format,
|
const char *format,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
_log_level_init();
|
|
||||||
|
|
||||||
char buf[16384] = {0};
|
char buf[16384] = {0};
|
||||||
|
|
||||||
|
@ -222,8 +212,6 @@ print_prefix(const char *func, enum u_logging_level level)
|
||||||
void
|
void
|
||||||
u_log(const char *file, int line, const char *func, enum u_logging_level level, const char *format, ...)
|
u_log(const char *file, int line, const char *func, enum u_logging_level level, const char *format, ...)
|
||||||
{
|
{
|
||||||
_log_level_init();
|
|
||||||
|
|
||||||
print_prefix(func, level);
|
print_prefix(func, level);
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
|
@ -243,8 +231,6 @@ u_log_xdev(const char *file,
|
||||||
const char *format,
|
const char *format,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
_log_level_init();
|
|
||||||
|
|
||||||
print_prefix(func, level);
|
print_prefix(func, level);
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
|
@ -64,11 +64,11 @@ struct xrt_device;
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#define U_LOG_T(...) U_LOG_IFL_T(global_log_level, __VA_ARGS__)
|
#define U_LOG_T(...) U_LOG_IFL_T(u_log_get_global_level(), __VA_ARGS__)
|
||||||
#define U_LOG_D(...) U_LOG_IFL_D(global_log_level, __VA_ARGS__)
|
#define U_LOG_D(...) U_LOG_IFL_D(u_log_get_global_level(), __VA_ARGS__)
|
||||||
#define U_LOG_I(...) U_LOG_IFL_I(global_log_level, __VA_ARGS__)
|
#define U_LOG_I(...) U_LOG_IFL_I(u_log_get_global_level(), __VA_ARGS__)
|
||||||
#define U_LOG_W(...) U_LOG_IFL_W(global_log_level, __VA_ARGS__)
|
#define U_LOG_W(...) U_LOG_IFL_W(u_log_get_global_level(), __VA_ARGS__)
|
||||||
#define U_LOG_E(...) U_LOG_IFL_E(global_log_level, __VA_ARGS__)
|
#define U_LOG_E(...) U_LOG_IFL_E(u_log_get_global_level(), __VA_ARGS__)
|
||||||
|
|
||||||
#define U_LOG_IFL_T(cond_level, ...) U_LOG_IFL(U_LOGGING_TRACE, cond_level, __VA_ARGS__)
|
#define U_LOG_IFL_T(cond_level, ...) U_LOG_IFL(U_LOGGING_TRACE, cond_level, __VA_ARGS__)
|
||||||
#define U_LOG_IFL_D(cond_level, ...) U_LOG_IFL(U_LOGGING_DEBUG, cond_level, __VA_ARGS__)
|
#define U_LOG_IFL_D(cond_level, ...) U_LOG_IFL(U_LOGGING_DEBUG, cond_level, __VA_ARGS__)
|
||||||
|
@ -99,12 +99,24 @@ enum u_logging_level
|
||||||
U_LOGGING_RAW, //!< Special level for raw printing, prints a new-line.
|
U_LOGGING_RAW, //!< Special level for raw printing, prints a new-line.
|
||||||
};
|
};
|
||||||
|
|
||||||
extern enum u_logging_level global_log_level;
|
/*!
|
||||||
|
* Returns the global logging level, subsystems own logging level take precedence.
|
||||||
|
*/
|
||||||
|
enum u_logging_level
|
||||||
|
u_log_get_global_level(void);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This function always logs, level is used for printing or passed to native
|
||||||
|
* logging functions.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
u_log(const char *file, int line, const char *func, enum u_logging_level level, const char *format, ...)
|
u_log(const char *file, int line, const char *func, enum u_logging_level level, const char *format, ...)
|
||||||
XRT_PRINTF_FORMAT(5, 6);
|
XRT_PRINTF_FORMAT(5, 6);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This function always logs, level is used for printing or passed to native
|
||||||
|
* logging functions.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
u_log_xdev(const char *file,
|
u_log_xdev(const char *file,
|
||||||
int line,
|
int line,
|
||||||
|
|
Loading…
Reference in a new issue