mirror of
https://github.com/libretro/RetroArch
synced 2025-03-21 22:20:59 +00:00
RARCH_LOG_BUFFER - doesn't need early return
This commit is contained in:
parent
77f48c8c8e
commit
2fbcc99b24
@ -101,11 +101,12 @@ static void *ds4_pad_init(void *data, uint32_t slot, hid_driver_t *driver)
|
|||||||
|
|
||||||
static void ds4_packet_handler(void *data, uint8_t *packet, uint16_t size)
|
static void ds4_packet_handler(void *data, uint8_t *packet, uint16_t size)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
ds4_instance_t *instance = (ds4_instance_t *)data;
|
ds4_instance_t *instance = (ds4_instance_t *)data;
|
||||||
if (!instance)
|
if (!instance)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RARCH_LOG_BUFFER(packet, size);
|
RARCH_LOG_BUFFER(packet, size);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ds4_set_rumble(void *data, enum retro_rumble_effect effect, uint16_t strength) { }
|
static void ds4_set_rumble(void *data, enum retro_rumble_effect effect, uint16_t strength) { }
|
||||||
|
@ -146,11 +146,12 @@ static void hid_null_get_buttons(void *data, input_bits_t *state) { }
|
|||||||
*/
|
*/
|
||||||
static void hid_null_packet_handler(void *data, uint8_t *packet, uint16_t size)
|
static void hid_null_packet_handler(void *data, uint8_t *packet, uint16_t size)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
hid_null_instance_t *instance = (hid_null_instance_t *)data;
|
hid_null_instance_t *instance = (hid_null_instance_t *)data;
|
||||||
if (!instance)
|
if (!instance)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RARCH_LOG_BUFFER(packet, size);
|
RARCH_LOG_BUFFER(packet, size);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
147
verbosity.c
147
verbosity.c
@ -214,108 +214,106 @@ void retro_main_log_file_deinit(void)
|
|||||||
void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap)
|
void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
verbosity_state_t *g_verbosity = &main_verbosity_st;
|
verbosity_state_t *g_verbosity = &main_verbosity_st;
|
||||||
|
const char *tag_v = tag ? tag : FILE_PATH_LOG_INFO;
|
||||||
|
|
||||||
{
|
|
||||||
const char *tag_v = tag ? tag : FILE_PATH_LOG_INFO;
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
#if TARGET_IPHONE_SIMULATOR
|
#if TARGET_IPHONE_SIMULATOR
|
||||||
vprintf(fmt, ap);
|
vprintf(fmt, ap);
|
||||||
#else
|
#else
|
||||||
static aslclient asl_client;
|
static aslclient asl_client;
|
||||||
static int asl_initialized = 0;
|
static int asl_initialized = 0;
|
||||||
if (!asl_initialized)
|
if (!asl_initialized)
|
||||||
{
|
{
|
||||||
asl_client = asl_open(
|
asl_client = asl_open(
|
||||||
FILE_PATH_PROGRAM_NAME,
|
FILE_PATH_PROGRAM_NAME,
|
||||||
"com.apple.console",
|
"com.apple.console",
|
||||||
ASL_OPT_STDERR | ASL_OPT_NO_DELAY);
|
ASL_OPT_STDERR | ASL_OPT_NO_DELAY);
|
||||||
asl_initialized = 1;
|
asl_initialized = 1;
|
||||||
}
|
}
|
||||||
aslmsg msg = asl_new(ASL_TYPE_MSG);
|
aslmsg msg = asl_new(ASL_TYPE_MSG);
|
||||||
asl_set(msg, ASL_KEY_READ_UID, "-1");
|
asl_set(msg, ASL_KEY_READ_UID, "-1");
|
||||||
if (tag)
|
if (tag)
|
||||||
asl_log(asl_client, msg, ASL_LEVEL_NOTICE, "%s", tag);
|
asl_log(asl_client, msg, ASL_LEVEL_NOTICE, "%s", tag);
|
||||||
asl_vlog(asl_client, msg, ASL_LEVEL_NOTICE, fmt, ap);
|
asl_vlog(asl_client, msg, ASL_LEVEL_NOTICE, fmt, ap);
|
||||||
asl_free(msg);
|
asl_free(msg);
|
||||||
#endif
|
#endif
|
||||||
#elif defined(_XBOX1)
|
#elif defined(_XBOX1)
|
||||||
/* FIXME: Using arbitrary string as fmt argument is unsafe. */
|
/* FIXME: Using arbitrary string as fmt argument is unsafe. */
|
||||||
char msg_new[256];
|
char msg_new[256];
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
|
|
||||||
msg_new[0] = buffer[0] = '\0';
|
msg_new[0] = buffer[0] = '\0';
|
||||||
snprintf(msg_new, sizeof(msg_new), "%s: %s %s",
|
snprintf(msg_new, sizeof(msg_new), "%s: %s %s",
|
||||||
FILE_PATH_PROGRAM_NAME, tag_v, fmt);
|
FILE_PATH_PROGRAM_NAME, tag_v, fmt);
|
||||||
wvsprintf(buffer, msg_new, ap);
|
wvsprintf(buffer, msg_new, ap);
|
||||||
OutputDebugStringA(buffer);
|
OutputDebugStringA(buffer);
|
||||||
#elif defined(ANDROID)
|
#elif defined(ANDROID)
|
||||||
int prio = ANDROID_LOG_INFO;
|
int prio = ANDROID_LOG_INFO;
|
||||||
if (tag)
|
if (tag)
|
||||||
{
|
{
|
||||||
if (string_is_equal(FILE_PATH_LOG_WARN, tag))
|
if (string_is_equal(FILE_PATH_LOG_WARN, tag))
|
||||||
prio = ANDROID_LOG_WARN;
|
prio = ANDROID_LOG_WARN;
|
||||||
else if (string_is_equal(FILE_PATH_LOG_ERROR, tag))
|
else if (string_is_equal(FILE_PATH_LOG_ERROR, tag))
|
||||||
prio = ANDROID_LOG_ERROR;
|
prio = ANDROID_LOG_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_verbosity->initialized)
|
if (g_verbosity->initialized)
|
||||||
{
|
{
|
||||||
vfprintf(g_verbosity->fp, fmt, ap);
|
vfprintf(g_verbosity->fp, fmt, ap);
|
||||||
fflush(g_verbosity->fp);
|
fflush(g_verbosity->fp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
__android_log_vprint(prio, FILE_PATH_PROGRAM_NAME, fmt, ap);
|
__android_log_vprint(prio, FILE_PATH_PROGRAM_NAME, fmt, ap);
|
||||||
#else
|
#else
|
||||||
FILE *fp = (FILE*)g_verbosity->fp;
|
FILE *fp = (FILE*)g_verbosity->fp;
|
||||||
#if defined(HAVE_QT) || defined(__WINRT__)
|
#if defined(HAVE_QT) || defined(__WINRT__)
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
buffer[0] = '\0';
|
buffer[0] = '\0';
|
||||||
|
|
||||||
/* Ensure null termination and line break in error case */
|
/* Ensure null termination and line break in error case */
|
||||||
if (vsnprintf(buffer, sizeof(buffer), fmt, ap) < 0)
|
if (vsnprintf(buffer, sizeof(buffer), fmt, ap) < 0)
|
||||||
|
{
|
||||||
|
int end;
|
||||||
|
buffer[sizeof(buffer) - 1] = '\0';
|
||||||
|
end = strlen(buffer) - 1;
|
||||||
|
if (end >= 0)
|
||||||
|
buffer[end] = '\n';
|
||||||
|
else
|
||||||
{
|
{
|
||||||
int end;
|
buffer[0] = '\n';
|
||||||
buffer[sizeof(buffer) - 1] = '\0';
|
buffer[1] = '\0';
|
||||||
end = strlen(buffer) - 1;
|
|
||||||
if (end >= 0)
|
|
||||||
buffer[end] = '\n';
|
|
||||||
else
|
|
||||||
{
|
|
||||||
buffer[0] = '\n';
|
|
||||||
buffer[1] = '\0';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (fp)
|
if (fp)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%s %s", tag_v, buffer);
|
fprintf(fp, "%s %s", tag_v, buffer);
|
||||||
fflush(fp);
|
fflush(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_QT)
|
#if defined(HAVE_QT)
|
||||||
ui_companion_driver_log_msg(buffer);
|
ui_companion_driver_log_msg(buffer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__WINRT__)
|
#if defined(__WINRT__)
|
||||||
OutputDebugStringA(buffer);
|
OutputDebugStringA(buffer);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if defined(HAVE_LIBNX)
|
#if defined(HAVE_LIBNX)
|
||||||
mutexLock(&g_verbosity->mtx);
|
mutexLock(&g_verbosity->mtx);
|
||||||
#endif
|
#endif
|
||||||
if (fp)
|
if (fp)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%s ", tag_v);
|
fprintf(fp, "%s ", tag_v);
|
||||||
vfprintf(fp, fmt, ap);
|
vfprintf(fp, fmt, ap);
|
||||||
fflush(fp);
|
fflush(fp);
|
||||||
}
|
}
|
||||||
#if defined(HAVE_LIBNX)
|
#if defined(HAVE_LIBNX)
|
||||||
mutexUnlock(&g_verbosity->mtx);
|
mutexUnlock(&g_verbosity->mtx);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RARCH_LOG_BUFFER(uint8_t *data, size_t size)
|
void RARCH_LOG_BUFFER(uint8_t *data, size_t size)
|
||||||
@ -324,9 +322,6 @@ void RARCH_LOG_BUFFER(uint8_t *data, size_t size)
|
|||||||
int padding = size % 16;
|
int padding = size % 16;
|
||||||
uint8_t buf[16] = {0};
|
uint8_t buf[16] = {0};
|
||||||
|
|
||||||
if (verbosity_log_level > 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
RARCH_LOG("== %d-byte buffer ==================\n", (int)size);
|
RARCH_LOG("== %d-byte buffer ==================\n", (int)size);
|
||||||
|
|
||||||
for (i = 0, offset = 0; i < size; i++)
|
for (i = 0, offset = 0; i < size; i++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user