Monado OpenXR Runtime
u_logging.h File Reference

Basic logging functionality. More...

#include "xrt/xrt_compiler.h"
#include "util/u_pretty_print.h"
#include <stdarg.h>
Include dependency graph for u_logging.h:

Go to the source code of this file.

Macros

#define U_LOG_RAW(...)
 For places where you really want printf, prints a new-line. More...
 
Logging macros conditional on global log level

These each imply a log level, and will only log if the global log level is equal or lower.

They are often used for one-off logging in a module with few other logging needs, where having a module-specific log level would be unnecessary.

See also
U_LOG_IFL, u_log_get_global_level()
Parameters
...Format string and optional format arguments.
#define U_LOG_T(...)   U_LOG_IFL_T(u_log_get_global_level(), __VA_ARGS__)
 Log a message at U_LOGGING_TRACE level, conditional on the global log level. More...
 
#define U_LOG_D(...)   U_LOG_IFL_D(u_log_get_global_level(), __VA_ARGS__)
 Log a message at U_LOGGING_DEBUG level, conditional on the global log level. More...
 
#define U_LOG_I(...)   U_LOG_IFL_I(u_log_get_global_level(), __VA_ARGS__)
 Log a message at U_LOGGING_INFO level, conditional on the global log level. More...
 
#define U_LOG_W(...)   U_LOG_IFL_W(u_log_get_global_level(), __VA_ARGS__)
 Log a message at U_LOGGING_WARN level, conditional on the global log level. More...
 
#define U_LOG_E(...)   U_LOG_IFL_E(u_log_get_global_level(), __VA_ARGS__)
 Log a message at U_LOGGING_ERROR level, conditional on the global log level. More...
 
Logging macros conditional on provided log level

These are often wrapped within a module, to automatically supply cond_level as appropriate for that module.

See also
U_LOG_IFL
Parameters
cond_levelThe minimum u_logging_level that will be actually output.
...Format string and optional format arguments.
#define U_LOG_IFL_T(cond_level, ...)   U_LOG_IFL(U_LOGGING_TRACE, cond_level, __VA_ARGS__)
 Conditionally log a message at U_LOGGING_TRACE level. More...
 
#define U_LOG_IFL_D(cond_level, ...)   U_LOG_IFL(U_LOGGING_DEBUG, cond_level, __VA_ARGS__)
 Conditionally log a message at U_LOGGING_DEBUG level. More...
 
#define U_LOG_IFL_I(cond_level, ...)   U_LOG_IFL(U_LOGGING_INFO, cond_level, __VA_ARGS__)
 Conditionally log a message at U_LOGGING_INFO level. More...
 
#define U_LOG_IFL_W(cond_level, ...)   U_LOG_IFL(U_LOGGING_WARN, cond_level, __VA_ARGS__)
 Conditionally log a message at U_LOGGING_WARN level. More...
 
#define U_LOG_IFL_E(cond_level, ...)   U_LOG_IFL(U_LOGGING_ERROR, cond_level, __VA_ARGS__)
 Conditionally log a message at U_LOGGING_ERROR level. More...
 
#define U_LOG_IFL_T_HEX(cond_level, data, data_size)   U_LOG_IFL_HEX(U_LOGGING_TRACE, cond_level, data, data_size)
 Conditionally log a memory hexdump at U_LOGGING_TRACE level. More...
 
#define U_LOG_IFL_D_HEX(cond_level, data, data_size)   U_LOG_IFL_HEX(U_LOGGING_DEBUG, cond_level, data, data_size)
 Conditionally log a memory hexdump at U_LOGGING_DEBUG level. More...
 
Device-related logging macros conditional on provided log level

These are often wrapped within a driver, to automatically supply xdev and cond_level from their conventional names and log level member variable.

Parameters
levelA u_logging_level value for this message.
cond_levelThe minimum u_logging_level that will be actually output.
xdevThe xrt_device pointer associated with this message.
...Format string and optional format arguments.
#define U_LOG_XDEV_IFL_T(xdev, cond_level, ...)   U_LOG_XDEV_IFL(U_LOGGING_TRACE, cond_level, xdev, __VA_ARGS__)
 Conditionally log a device-related message at U_LOGGING_TRACE level. More...
 
#define U_LOG_XDEV_IFL_D(xdev, cond_level, ...)   U_LOG_XDEV_IFL(U_LOGGING_DEBUG, cond_level, xdev, __VA_ARGS__)
 Conditionally log a device-related message at U_LOGGING_DEBUG level. More...
 
#define U_LOG_XDEV_IFL_I(xdev, cond_level, ...)   U_LOG_XDEV_IFL(U_LOGGING_INFO, cond_level, xdev, __VA_ARGS__)
 Conditionally log a device-related message at U_LOGGING_INFO level. More...
 
#define U_LOG_XDEV_IFL_W(xdev, cond_level, ...)   U_LOG_XDEV_IFL(U_LOGGING_WARN, cond_level, xdev, __VA_ARGS__)
 Conditionally log a device-related message at U_LOGGING_WARN level. More...
 
#define U_LOG_XDEV_IFL_E(xdev, cond_level, ...)   U_LOG_XDEV_IFL(U_LOGGING_ERROR, cond_level, xdev, __VA_ARGS__)
 Conditionally log a device-related message at U_LOGGING_ERROR level. More...
 
#define U_LOG_XDEV_IFL_T_HEX(xdev, cond_level, data, data_size)    U_LOG_XDEV_IFL_HEX(U_LOGGING_TRACE, cond_level, xdev, data, data_size)
 Conditionally log a device-related memory hexdump at U_LOGGING_TRACE level. More...
 
#define U_LOG_XDEV_IFL_D_HEX(xdev, cond_level, data, data_size)    U_LOG_XDEV_IFL_HEX(U_LOGGING_DEBUG, cond_level, xdev, data, data_size)
 Conditionally log a device-related memory hexdump message at U_LOGGING_DEBUG level. More...
 
Device-related error logging macros

These are printed from a driver at error level.

Parameters
xdevThe xrt_device pointer associated with this message
#define U_LOG_XDEV_UNSUPPORTED_INPUT(xdev, cond_level, name)
 
Device-related logging macros that always log.

These wrap U_LOG_XDEV() to supply the level - which is only used for formatting the output, these macros always log regardless of level.

Parameters
xdevThe xrt_device pointer associated with this message.
...Format string and optional format arguments.
#define U_LOG_XDEV_T(xdev, ...)   U_LOG_XDEV(U_LOGGING_TRACE, xdev, __VA_ARGS__)
 Log a device-related message at U_LOGGING_TRACE level (always logs). More...
 
#define U_LOG_XDEV_D(xdev, ...)   U_LOG_XDEV(U_LOGGING_DEBUG, xdev, __VA_ARGS__)
 Log a device-related message at U_LOGGING_DEBUG level (always logs). More...
 
#define U_LOG_XDEV_I(xdev, ...)   U_LOG_XDEV(U_LOGGING_INFO, xdev, __VA_ARGS__)
 Log a device-related message at U_LOGGING_INFO level (always logs). More...
 
#define U_LOG_XDEV_W(xdev, ...)   U_LOG_XDEV(U_LOGGING_WARN, xdev, __VA_ARGS__)
 Log a device-related message at U_LOGGING_WARN level (always logs). More...
 
#define U_LOG_XDEV_E(xdev, ...)   U_LOG_XDEV(U_LOGGING_ERROR, xdev, __VA_ARGS__)
 Log a device-related message at U_LOGGING_ERROR level (always logs). More...
 

Typedefs

typedef void(* u_log_sink_func_t) (const char *file, int line, const char *func, enum u_logging_level level, const char *format, va_list args, void *data)
 Function typedef for setting the logging sink. More...
 

Enumerations

enum  u_logging_level {
  U_LOGGING_TRACE , U_LOGGING_DEBUG , U_LOGGING_INFO , U_LOGGING_WARN ,
  U_LOGGING_ERROR , U_LOGGING_RAW
}
 Logging level enum. More...
 

Base Logging Utilities

In most cases, you will want to use another macro from this file, or a module/driver-local macro, to do your logging.

#define U_LOG(level, ...)
 Log a message at level , with file, line, and function context (always logs) - typically wrapped in a helper macro. More...
 
#define U_LOG_IFL(level, cond_level, ...)
 Log at level only if the level is at least cond_level - typically wrapped in a helper macro. More...
 
#define U_LOG_XDEV(level, xdev, ...)
 Log at level for a given xrt_device - typically wrapped in a helper macro. More...
 
#define U_LOG_XDEV_IFL(level, cond_level, xdev, ...)
 Log at level for a given xrt_device, only if the level is at least cond_level - typically wrapped in a helper macro. More...
 
#define U_LOG_IFL_HEX(level, cond_level, data, data_size)
 Log a memory hexdump at level only if the level is at least cond_level - typically wrapped in a helper macro. More...
 
#define U_LOG_XDEV_IFL_HEX(level, cond_level, xdev, data, data_size)
 Log a memory hexdump at level for a given xrt_device, only if the level is at least cond_level - typically wrapped in a helper macro. More...
 
enum u_logging_level u_log_get_global_level (void)
 Returns the global logging level, subsystems own logging level take precedence. More...
 
void u_log (const char *file, int line, const char *func, enum u_logging_level level, const char *format,...) XRT_PRINTF_FORMAT(5
 Main non-device-related log implementation function: do not call directly, use a macro that wraps it. More...
 
void void u_log_xdev (const char *file, int line, const char *func, enum u_logging_level level, struct xrt_device *xdev, const char *format,...) XRT_PRINTF_FORMAT(6
 Main device-related log implementation function: do not call directly, use a macro that wraps it. More...
 
void void void u_log_hex (const char *file, int line, const char *func, enum u_logging_level level, const uint8_t *data, const size_t data_size)
 Log implementation for dumping memory buffers as hex: do not call directly, use a macro that wraps it. More...
 
void u_log_xdev_hex (const char *file, int line, const char *func, enum u_logging_level level, struct xrt_device *xdev, const uint8_t *data, const size_t data_size)
 Device-related log implementation for dumping memory buffers as hex: do not call directly, use a macro that wraps it. More...
 
void u_log_set_sink (u_log_sink_func_t func, void *data)
 Sets the logging sink, log is still passed on to the platform defined output as well as the sink. More...
 

Detailed Description