Monado OpenXR Runtime
Loading...
Searching...
No Matches
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   (4096)
 
#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.
 
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.
 
void oxr_slog_cancel (struct oxr_sink_logger *slog)
 Cancel logging, frees all internal data.
 
void oxr_log_slog (struct oxr_logger *log, struct oxr_sink_logger *slog)
 Flush sink as a log message, frees all internal data.
 
void oxr_warn_slog (struct oxr_logger *log, struct oxr_sink_logger *slog)
 Flush sink as a warning message, frees all internal data.
 
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.
 

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()

XrResult oxr_error ( struct oxr_logger logger,
XrResult  result,
const char *  fmt,
  ... 
)

Trigger a debugger breakpoint.

References XRT_DEBUGBREAK.

Referenced by handle_null(), oxr_action_get_input_source_localized_name(), oxr_action_sync_data(), oxr_create_messenger(), oxr_d3d_check_luid(), oxr_d3d_get_requirements(), oxr_error_slog(), oxr_handle_do_destroy(), oxr_instance_action_context::oxr_instance_action_context_init(), oxr_instance::oxr_instance_create(), oxr_instance::oxr_instance_init_system_locked(), oxr_roles_init_on_stack(), oxr_session_frame_end(), oxr_space_xdev_pose_create(), oxr_swapchain_common_acquire(), oxr_swapchain_common_create(), oxr_swapchain_common_release(), oxr_swapchain_common_wait(), oxr_verify_fixed_size_single_level_path(), oxr_verify_full_path(), oxr_verify_localized_name(), oxr_verify_subaction_path_get(), oxr_verify_subaction_path_sync(), oxr_xrApplyHapticFeedback(), oxr_xrAttachSessionActionSets(), oxr_xrBeginSession(), oxr_xrCreateAction(), oxr_xrCreateActionSet(), oxr_xrCreateInstance(), oxr_xrCreateSwapchain(), oxr_xrCreateVulkanDeviceKHR(), oxr_xrCreateVulkanInstanceKHR(), oxr_xrEndFrame(), oxr_xrEnumerateBoundSourcesForAction(), oxr_xrEnumerateSwapchainImages(), oxr_xrGetActionStateBoolean(), oxr_xrGetActionStateFloat(), oxr_xrGetActionStatePose(), oxr_xrGetActionStateVector2f(), oxr_xrGetCurrentInteractionProfile(), oxr_xrGetInputSourceLocalizedName(), oxr_xrLocateSpace(), oxr_xrLocateViews(), oxr_xrPathToString(), oxr_xrSessionBeginDebugUtilsLabelRegionEXT(), oxr_xrSessionEndDebugUtilsLabelRegionEXT(), oxr_xrSessionInsertDebugUtilsLabelEXT(), oxr_xrSetDebugUtilsObjectNameEXT(), oxr_xrStopHapticFeedback(), oxr_xrSuggestInteractionProfileBindings(), and verify_projection_layer().

◆ 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.

++
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

References u_truncate_snprintf().