mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
Add separate setting for Frontend Logging Level
This commit is contained in:
parent
ad71451432
commit
73663104b3
@ -2640,6 +2640,7 @@ static bool config_load_file(const char *path, settings_t *settings)
|
|||||||
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
||||||
char *tmp_str = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
char *tmp_str = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
unsigned tmp_uint = 0;
|
||||||
bool tmp_bool = false;
|
bool tmp_bool = false;
|
||||||
unsigned msg_color = 0;
|
unsigned msg_color = 0;
|
||||||
char *save = NULL;
|
char *save = NULL;
|
||||||
@ -2741,19 +2742,9 @@ static bool config_load_file(const char *path, settings_t *settings)
|
|||||||
else
|
else
|
||||||
verbosity_disable();
|
verbosity_disable();
|
||||||
}
|
}
|
||||||
|
if (config_get_uint(conf, "frontend_log_level", &tmp_uint))
|
||||||
{
|
{
|
||||||
char tmp[64];
|
verbosity_set_log_level(tmp_uint);
|
||||||
|
|
||||||
tmp[0] = '\0';
|
|
||||||
|
|
||||||
strlcpy(tmp, "perfcnt_enable", sizeof(tmp));
|
|
||||||
if (config_get_bool(conf, tmp, &tmp_bool))
|
|
||||||
{
|
|
||||||
if (tmp_bool)
|
|
||||||
rarch_ctl(RARCH_CTL_SET_PERFCNT_ENABLE, NULL);
|
|
||||||
else
|
|
||||||
rarch_ctl(RARCH_CTL_UNSET_PERFCNT_ENABLE, NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Integer settings */
|
/* Integer settings */
|
||||||
|
@ -6063,6 +6063,14 @@ void general_write_handler(rarch_setting_t *setting)
|
|||||||
command_event(rarch_cmd, NULL);
|
command_event(rarch_cmd, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void frontend_log_level_change_handler(rarch_setting_t *setting)
|
||||||
|
{
|
||||||
|
if (!setting)
|
||||||
|
return;
|
||||||
|
|
||||||
|
verbosity_set_log_level(*setting->value.target.unsigned_integer);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_OVERLAY
|
#ifdef HAVE_OVERLAY
|
||||||
static void overlay_enable_toggle_change_handler(rarch_setting_t *setting)
|
static void overlay_enable_toggle_change_handler(rarch_setting_t *setting)
|
||||||
{
|
{
|
||||||
@ -7593,6 +7601,7 @@ static bool setting_append_list(
|
|||||||
parent_group,
|
parent_group,
|
||||||
general_write_handler,
|
general_write_handler,
|
||||||
general_read_handler);
|
general_read_handler);
|
||||||
|
(*list)[list_info->index - 1].change_handler = frontend_log_level_change_handler;
|
||||||
(*list)[list_info->index - 1].ui_type = ST_UI_TYPE_UINT_RADIO_BUTTONS;
|
(*list)[list_info->index - 1].ui_type = ST_UI_TYPE_UINT_RADIO_BUTTONS;
|
||||||
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
|
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
|
||||||
menu_settings_list_current_add_range(list, list_info, 0, 3, 1.0, true, true);
|
menu_settings_list_current_add_range(list, list_info, 0, 3, 1.0, true, true);
|
||||||
|
10
retroarch.c
10
retroarch.c
@ -6276,7 +6276,7 @@ static bool environ_cb_get_system_info(unsigned cmd, void *data)
|
|||||||
const struct retro_subsystem_info *info =
|
const struct retro_subsystem_info *info =
|
||||||
(const struct retro_subsystem_info*)data;
|
(const struct retro_subsystem_info*)data;
|
||||||
settings_t *settings = configuration_settings;
|
settings_t *settings = configuration_settings;
|
||||||
unsigned log_level = settings->uints.libretro_log_level;
|
unsigned log_level = settings->uints.frontend_log_level;
|
||||||
|
|
||||||
subsystem_current_count = 0;
|
subsystem_current_count = 0;
|
||||||
|
|
||||||
@ -6690,7 +6690,7 @@ static bool rarch_environment_cb(unsigned cmd, void *data)
|
|||||||
|
|
||||||
case RETRO_ENVIRONMENT_GET_VARIABLE:
|
case RETRO_ENVIRONMENT_GET_VARIABLE:
|
||||||
{
|
{
|
||||||
unsigned log_level = settings->uints.libretro_log_level;
|
unsigned log_level = settings->uints.frontend_log_level;
|
||||||
struct retro_variable *var = (struct retro_variable*)data;
|
struct retro_variable *var = (struct retro_variable*)data;
|
||||||
|
|
||||||
if (!var)
|
if (!var)
|
||||||
@ -6992,7 +6992,7 @@ static bool rarch_environment_cb(unsigned cmd, void *data)
|
|||||||
RARCH_LOG("Environ SET_INPUT_DESCRIPTORS:\n");
|
RARCH_LOG("Environ SET_INPUT_DESCRIPTORS:\n");
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned log_level = settings->uints.libretro_log_level;
|
unsigned log_level = settings->uints.frontend_log_level;
|
||||||
|
|
||||||
if (log_level == RETRO_LOG_DEBUG)
|
if (log_level == RETRO_LOG_DEBUG)
|
||||||
{
|
{
|
||||||
@ -7293,7 +7293,7 @@ static bool rarch_environment_cb(unsigned cmd, void *data)
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
const struct retro_subsystem_info *info =
|
const struct retro_subsystem_info *info =
|
||||||
(const struct retro_subsystem_info*)data;
|
(const struct retro_subsystem_info*)data;
|
||||||
unsigned log_level = settings->uints.libretro_log_level;
|
unsigned log_level = settings->uints.frontend_log_level;
|
||||||
|
|
||||||
if (log_level == RETRO_LOG_DEBUG)
|
if (log_level == RETRO_LOG_DEBUG)
|
||||||
RARCH_LOG("Environ SET_SUBSYSTEM_INFO.\n");
|
RARCH_LOG("Environ SET_SUBSYSTEM_INFO.\n");
|
||||||
@ -7343,7 +7343,7 @@ static bool rarch_environment_cb(unsigned cmd, void *data)
|
|||||||
unsigned i, j;
|
unsigned i, j;
|
||||||
const struct retro_controller_info *info =
|
const struct retro_controller_info *info =
|
||||||
(const struct retro_controller_info*)data;
|
(const struct retro_controller_info*)data;
|
||||||
unsigned log_level = settings->uints.libretro_log_level;
|
unsigned log_level = settings->uints.frontend_log_level;
|
||||||
|
|
||||||
RARCH_LOG("Environ SET_CONTROLLER_INFO.\n");
|
RARCH_LOG("Environ SET_CONTROLLER_INFO.\n");
|
||||||
|
|
||||||
|
191
verbosity.c
191
verbosity.c
@ -62,12 +62,19 @@
|
|||||||
#include "ui/ui_companion_driver.h"
|
#include "ui/ui_companion_driver.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef RARCH_INTERNAL
|
||||||
|
#include "config.def.h"
|
||||||
|
#else
|
||||||
|
#define DEFAULT_FRONTEND_LOG_LEVEL 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/* If this is non-NULL. RARCH_LOG and friends
|
/* If this is non-NULL. RARCH_LOG and friends
|
||||||
* will write to this file. */
|
* will write to this file. */
|
||||||
static FILE *log_file_fp = NULL;
|
static FILE *log_file_fp = NULL;
|
||||||
static void* log_file_buf = NULL;
|
static void* log_file_buf = NULL;
|
||||||
static bool main_verbosity = false;
|
static unsigned verbosity_log_level = DEFAULT_FRONTEND_LOG_LEVEL;
|
||||||
static bool log_file_initialized = false;
|
static bool main_verbosity = false;
|
||||||
|
static bool log_file_initialized = false;
|
||||||
|
|
||||||
#ifdef HAVE_LIBNX
|
#ifdef HAVE_LIBNX
|
||||||
static Mutex logging_mtx;
|
static Mutex logging_mtx;
|
||||||
@ -76,6 +83,11 @@ bool nxlink_connected = false;
|
|||||||
#endif /* NXLINK */
|
#endif /* NXLINK */
|
||||||
#endif /* HAVE_LIBNX */
|
#endif /* HAVE_LIBNX */
|
||||||
|
|
||||||
|
void verbosity_set_log_level(unsigned level)
|
||||||
|
{
|
||||||
|
verbosity_log_level = level;
|
||||||
|
}
|
||||||
|
|
||||||
void verbosity_enable(void)
|
void verbosity_enable(void)
|
||||||
{
|
{
|
||||||
main_verbosity = true;
|
main_verbosity = true;
|
||||||
@ -162,112 +174,115 @@ void retro_main_log_file_deinit(void)
|
|||||||
#if !defined(HAVE_LOGGER)
|
#if !defined(HAVE_LOGGER)
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
if (verbosity_log_level <= 1)
|
||||||
|
{
|
||||||
#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_str(FILE_PATH_PROGRAM_NAME),
|
file_path_str(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_str(FILE_PATH_PROGRAM_NAME),
|
|
||||||
tag ? tag : "",
|
|
||||||
fmt);
|
|
||||||
wvsprintf(buffer, msg_new, ap);
|
|
||||||
OutputDebugStringA(buffer);
|
|
||||||
#elif defined(ANDROID)
|
|
||||||
int prio = ANDROID_LOG_INFO;
|
|
||||||
if (tag)
|
|
||||||
{
|
|
||||||
if (string_is_equal(file_path_str(FILE_PATH_LOG_WARN), tag))
|
|
||||||
prio = ANDROID_LOG_WARN;
|
|
||||||
else if (string_is_equal(file_path_str(FILE_PATH_LOG_ERROR), tag))
|
|
||||||
prio = ANDROID_LOG_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (log_file_initialized)
|
|
||||||
{
|
|
||||||
vfprintf(log_file_fp, fmt, ap);
|
|
||||||
fflush(log_file_fp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
__android_log_vprint(prio,
|
|
||||||
file_path_str(FILE_PATH_PROGRAM_NAME),
|
file_path_str(FILE_PATH_PROGRAM_NAME),
|
||||||
fmt,
|
tag ? tag : "",
|
||||||
ap);
|
fmt);
|
||||||
#else
|
wvsprintf(buffer, msg_new, ap);
|
||||||
FILE *fp = (FILE*)log_file_fp;
|
OutputDebugStringA(buffer);
|
||||||
#if defined(HAVE_QT) || defined(__WINRT__)
|
#elif defined(ANDROID)
|
||||||
int ret;
|
int prio = ANDROID_LOG_INFO;
|
||||||
char buffer[256];
|
if (tag)
|
||||||
buffer[0] = '\0';
|
|
||||||
ret = vsnprintf(buffer, sizeof(buffer), fmt, ap);
|
|
||||||
|
|
||||||
/* ensure null termination and line break in error case */
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
int end;
|
|
||||||
buffer[sizeof(buffer) - 1] = '\0';
|
|
||||||
end = strlen(buffer) - 1;
|
|
||||||
if (end >= 0)
|
|
||||||
buffer[end] = '\n';
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
buffer[0] = '\n';
|
if (string_is_equal(file_path_str(FILE_PATH_LOG_WARN), tag))
|
||||||
buffer[1] = '\0';
|
prio = ANDROID_LOG_WARN;
|
||||||
|
else if (string_is_equal(file_path_str(FILE_PATH_LOG_ERROR), tag))
|
||||||
|
prio = ANDROID_LOG_ERROR;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (fp)
|
if (log_file_initialized)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%s %s", tag ? tag : file_path_str(FILE_PATH_LOG_INFO), buffer);
|
vfprintf(log_file_fp, fmt, ap);
|
||||||
fflush(fp);
|
fflush(log_file_fp);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
__android_log_vprint(prio,
|
||||||
|
file_path_str(FILE_PATH_PROGRAM_NAME),
|
||||||
|
fmt,
|
||||||
|
ap);
|
||||||
|
#else
|
||||||
|
FILE *fp = (FILE*)log_file_fp;
|
||||||
|
#if defined(HAVE_QT) || defined(__WINRT__)
|
||||||
|
int ret;
|
||||||
|
char buffer[256];
|
||||||
|
buffer[0] = '\0';
|
||||||
|
ret = vsnprintf(buffer, sizeof(buffer), fmt, ap);
|
||||||
|
|
||||||
|
/* ensure null termination and line break in error case */
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
int end;
|
||||||
|
buffer[sizeof(buffer) - 1] = '\0';
|
||||||
|
end = strlen(buffer) - 1;
|
||||||
|
if (end >= 0)
|
||||||
|
buffer[end] = '\n';
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buffer[0] = '\n';
|
||||||
|
buffer[1] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
|
fprintf(fp, "%s %s", tag ? tag : file_path_str(FILE_PATH_LOG_INFO), buffer);
|
||||||
|
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(&logging_mtx);
|
mutexLock(&logging_mtx);
|
||||||
#endif
|
#endif
|
||||||
if (fp)
|
if (fp)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%s ",
|
fprintf(fp, "%s ",
|
||||||
tag ? tag : file_path_str(FILE_PATH_LOG_INFO));
|
tag ? tag : file_path_str(FILE_PATH_LOG_INFO));
|
||||||
vfprintf(fp, fmt, ap);
|
vfprintf(fp, fmt, ap);
|
||||||
fflush(fp);
|
fflush(fp);
|
||||||
}
|
}
|
||||||
#if defined(HAVE_LIBNX)
|
#if defined(HAVE_LIBNX)
|
||||||
mutexUnlock(&logging_mtx);
|
mutexUnlock(&logging_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)
|
||||||
@ -309,6 +324,8 @@ void RARCH_LOG(const char *fmt, ...)
|
|||||||
|
|
||||||
if (!main_verbosity)
|
if (!main_verbosity)
|
||||||
return;
|
return;
|
||||||
|
if (verbosity_log_level > 1)
|
||||||
|
return;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
RARCH_LOG_V(file_path_str(FILE_PATH_LOG_INFO), fmt, ap);
|
RARCH_LOG_V(file_path_str(FILE_PATH_LOG_INFO), fmt, ap);
|
||||||
@ -329,6 +346,8 @@ void RARCH_WARN(const char *fmt, ...)
|
|||||||
|
|
||||||
if (!main_verbosity)
|
if (!main_verbosity)
|
||||||
return;
|
return;
|
||||||
|
if (verbosity_log_level > 2)
|
||||||
|
return;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
RARCH_WARN_V(file_path_str(FILE_PATH_LOG_WARN), fmt, ap);
|
RARCH_WARN_V(file_path_str(FILE_PATH_LOG_WARN), fmt, ap);
|
||||||
|
@ -33,6 +33,8 @@ void verbosity_enable(void);
|
|||||||
|
|
||||||
void verbosity_disable(void);
|
void verbosity_disable(void);
|
||||||
|
|
||||||
|
void verbosity_set_log_level(unsigned level);
|
||||||
|
|
||||||
bool *verbosity_get_ptr(void);
|
bool *verbosity_get_ptr(void);
|
||||||
|
|
||||||
void *retro_main_log_file(void);
|
void *retro_main_log_file(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user