[client,sdl] add log functions

This commit is contained in:
Armin Novak 2023-01-18 08:50:55 +01:00 committed by akallabeth
parent defa74b94b
commit a1b764019d
2 changed files with 29 additions and 0 deletions

View File

@ -99,3 +99,25 @@ const char* sdl_event_type_str(Uint32 type)
#undef EV_CASE_STR
#undef STR
}
const char* sdl_error_string(Uint32 res)
{
if (res >= 0)
return NULL;
return SDL_GetError();
}
BOOL sdl_log_error_ex(Uint32 res, wLog* log, const char* what, const char* file, size_t line,
const char* fkt)
{
const char* msg = sdl_error_string(res);
WINPR_UNUSED(file);
if (!msg)
return FALSE;
WLog_Print(log, WLOG_ERROR, "[%s:%" PRIuz "][%s]: %s", fkt, line, what, msg);
return TRUE;
}

View File

@ -20,9 +20,16 @@
#ifndef FREERDP_CLIENT_SDL_UTILS_H
#define FREERDP_CLIENT_SDL_UTILS_H
#include <winpr/wlog.h>
#include <stdbool.h>
#include <SDL.h>
const char* sdl_event_type_str(Uint32 type);
const char* sdl_error_string(Uint32 res);
#define sdl_log_error(res, log, what) sdl_log_error(res, log, what, __FILE__ __LINE__, __FUNCTION__)
BOOL sdl_log_error_ex(Uint32 res, wLog* log, const char* what, const char* file, size_t line,
const char* fkt);
#endif /* FREERDP_CLIENT_SDL_UTILS_H */