Monado OpenXR Runtime
oxr_logger.c File Reference

Logging functions. More...

#include "xrt/xrt_compiler.h"
#include "util/u_misc.h"
#include "util/u_debug.h"
#include "util/u_truncate_printf.h"
#include "oxr_objects.h"
#include "oxr_logger.h"
#include "openxr/openxr_reflection.h"
#include <stdio.h>
#include <stdarg.h>
#include <limits.h>
Include dependency graph for oxr_logger.c:

Macros

#define LOG_BUFFER_SIZE   (1024)
 
#define DEFAULT_NO_STDERR   (false)
 
#define CHECK_SHOULD_NOT_PRINT   (debug_get_bool_option_no_printing() || debug_get_bool_option_no_printing_stderr())
 
#define ENTRY(NAME, VALUE)    case VALUE: return #NAME;
 

Functions

static const char * oxr_result_to_string (XrResult result)
 
static bool is_fmt_func_arg_start (const char *fmt)
 
static int print_prefix (struct oxr_logger *logger, const char *fmt, const char *prefix, char *buf, int remaining)
 Prints the first part of a logging message, has three forms. More...
 
static void do_output (const char *buf)
 
static void do_print (struct oxr_logger *logger, const char *fmt, const char *prefix, va_list args)
 
static void do_print_func (const char *api_func_name)
 
void oxr_log_init (struct oxr_logger *logger, const char *api_func_name)
 
void oxr_log_set_instance (struct oxr_logger *logger, struct oxr_instance *inst)
 
void oxr_log (struct oxr_logger *logger, const char *fmt,...)
 
void oxr_warn (struct oxr_logger *logger, const char *fmt,...)
 
XrResult oxr_error (struct oxr_logger *logger, XrResult result, const char *fmt,...)
 
static void oxr_slog_ensure (struct oxr_sink_logger *slog, size_t extra)
 
static void slog_free_store (struct oxr_sink_logger *slog)
 
void oxr_slog (struct oxr_sink_logger *slog, const char *fmt,...)
 
void oxr_slog_add_array (struct oxr_sink_logger *slog, const char *str, size_t size)
 Add the string to the slog struct. More...
 
void oxr_slog_cancel (struct oxr_sink_logger *slog)
 Cancel logging, frees all internal data. More...
 
void oxr_log_slog (struct oxr_logger *log, struct oxr_sink_logger *slog)
 Flush sink as a log message, frees all internal data. More...
 
void oxr_warn_slog (struct oxr_logger *log, struct oxr_sink_logger *slog)
 Flush sink as a warning message, frees all internal data. More...
 
XrResult oxr_error_slog (struct oxr_logger *log, XrResult res, struct oxr_sink_logger *slog)
 Flush sink as a error message, frees all internal data. More...
 

Detailed Description

Logging functions.

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

Function Documentation

◆ oxr_error()

◆ print_prefix()

static int print_prefix ( struct oxr_logger logger,
const char *  fmt,
const char *  prefix,
char *  buf,
int  remaining 
)
static

Prints the first part of a logging message, has three forms.

{c++}
print_prefix(l, "(myInfo->memberName) is bad", "XR_ERROR_VALIDATION_FAILURE");
// XR_ERROR_VALIDATION_FAILURE: xrMyFunc(myInfo->memberName) is bad
print_prefix(l, "This is bad", "XR_ERROR_VALIDATION_FAILURE");
// XR_ERROR_VALIDATION_FAILURE in xrMyFunc: This is bad
print_prefix(l, "No functions set now", "LOG");
// LOG: No function set now
static int print_prefix(struct oxr_logger *logger, const char *fmt, const char *prefix, char *buf, int remaining)
Prints the first part of a logging message, has three forms.
Definition: oxr_logger.c:82