Monado OpenXR Runtime
u_logging.c File Reference

Logging functions. More...

#include "util/u_logging.h"
#include "xrt/xrt_config_os.h"
#include "xrt/xrt_config_build.h"
#include "util/u_debug.h"
#include "u_json.h"
#include "util/u_truncate_printf.h"
#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
Include dependency graph for u_logging.c:

Macros

#define LOG_BUFFER_SIZE   (3 * 1024)
 
#define LOG_MAX_HEX_DUMP   (0x00ffffff)
 
#define LOG_MAX_HEX_DUMP_HUMAN_READABLE   "16MB"
 
#define LOG_HEX_BYTES_PER_LINE   (16)
 
#define LOG_HEX_LINE_BUF_SIZE   (128)
 
#define DISPATCH_SINK(FILE, LINE, FUNC, LEVEL, FORMAT, ARGS)
 
#define CHECK_RET_AND_UPDATE_STATE()
 

Functions

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_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...
 
static void u_log_hexdump_line (char *buf, size_t offset, const uint8_t *data, size_t data_size)
 
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...
 
static int print_prefix_mono (const char *func, enum u_logging_level level, char *buf, int remaining)
 
static int print_prefix (const char *func, enum u_logging_level level, char *buf, int remaining)
 
static int log_as_json (const char *file, const char *func, enum u_logging_level level, const char *format, va_list args)
 
static int do_print (const char *file, int line, const char *func, enum u_logging_level level, const char *format, va_list args)
 
void u_log (const char *file, int line, const char *func, enum u_logging_level level, const char *format,...)
 
void u_log_xdev (const char *file, int line, const char *func, enum u_logging_level level, struct xrt_device *xdev, const char *format,...)
 

Variables

static u_log_sink_func_t g_log_sink_func
 
static void * g_log_sink_data
 

Detailed Description

Logging functions.

Author
Jakob Bornecrantz jakob.nosp@m.@col.nosp@m.labor.nosp@m.a.co.nosp@m.m

Macro Definition Documentation

◆ CHECK_RET_AND_UPDATE_STATE

#define CHECK_RET_AND_UPDATE_STATE ( )
Value:
do { \
if (ret < 0) { \
return ret; \
} \
\
printed += ret; /* Is not negative, checked above. */ \
remaining -= ret; \
buf += ret; /* Continue in the buffer from where we left off. */ \
} while (false);

◆ DISPATCH_SINK

#define DISPATCH_SINK (   FILE,
  LINE,
  FUNC,
  LEVEL,
  FORMAT,
  ARGS 
)
Value:
if (g_log_sink_func != NULL) { \
va_list copy; \
va_copy(copy, ARGS); \
g_log_sink_func(FILE, LINE, FUNC, LEVEL, FORMAT, copy, g_log_sink_data); \
va_end(copy); \
}