Reimplement verbosity

This commit is contained in:
twinaphex 2016-05-31 04:42:04 +02:00
parent 0b47d98169
commit 5b52098c54
11 changed files with 84 additions and 72 deletions

View File

@ -1236,7 +1236,6 @@ static bool config_load_file(const char *path, bool set_defaults)
config_file_t *conf = NULL; config_file_t *conf = NULL;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();
bool *verbose = retro_main_verbosity();
if (path) if (path)
{ {
@ -1268,7 +1267,7 @@ static bool config_load_file(const char *path, bool set_defaults)
extra_path = strtok_r(NULL, "|", &save); extra_path = strtok_r(NULL, "|", &save);
} }
#if 0 #if 0
if (*verbose) if (verbosity_is_enabled())
{ {
RARCH_LOG_OUTPUT("=== Config ===\n"); RARCH_LOG_OUTPUT("=== Config ===\n");
config_file_dump_all(conf); config_file_dump_all(conf);
@ -1643,8 +1642,10 @@ static bool config_load_file(const char *path, bool set_defaults)
{ {
if (config_get_bool(conf, "log_verbosity", &tmp_bool)) if (config_get_bool(conf, "log_verbosity", &tmp_bool))
{ {
if (verbose) if (tmp_bool)
*verbose = tmp_bool; verbosity_enable();
else
verbosity_disable();
} }
} }
@ -2529,6 +2530,7 @@ bool config_save_file(const char *path)
{ {
float msg_color; float msg_color;
unsigned i = 0; unsigned i = 0;
bool tmp_bool = false;
bool ret = false; bool ret = false;
config_file_t *conf = config_file_new(path); config_file_t *conf = config_file_new(path);
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
@ -2944,12 +2946,9 @@ bool config_save_file(const char *path)
config_set_bool(conf, "sort_savestates_enable", config_set_bool(conf, "sort_savestates_enable",
settings->sort_savestates_enable); settings->sort_savestates_enable);
config_set_int(conf, "libretro_log_level", settings->libretro_log_level); config_set_int(conf, "libretro_log_level", settings->libretro_log_level);
config_set_bool(conf, "log_verbosity", *retro_main_verbosity());
{ config_set_bool(conf, "log_verbosity", verbosity_is_enabled());
bool perfcnt_enable = runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL); config_set_bool(conf, "perfcnt_enable", runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL));
config_set_bool(conf, "perfcnt_enable", perfcnt_enable);
}
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE
config_set_bool(conf, "small_keyboard_enable", settings->input.small_keyboard_enable); config_set_bool(conf, "small_keyboard_enable", settings->input.small_keyboard_enable);

View File

@ -91,8 +91,7 @@ static void frontend_ctr_deinit(void *data)
u8 not_2DS; u8 not_2DS;
(void)data; (void)data;
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
bool *verbose = retro_main_verbosity(); verbosity_enable();
*verbose = true;
#ifdef HAVE_FILE_LOGGER #ifdef HAVE_FILE_LOGGER
command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL); command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL);
@ -187,9 +186,7 @@ static void frontend_ctr_init(void *data)
{ {
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
(void)data; (void)data;
bool *verbose = retro_main_verbosity(); verbosity_enable();
*verbose = true;
gfxInit(GSP_BGR8_OES,GSP_RGB565_OES,false); gfxInit(GSP_BGR8_OES,GSP_RGB565_OES,false);

View File

@ -96,9 +96,8 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[],
void *args, void *params_data) void *args, void *params_data)
{ {
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
bool *verbose = retro_main_verbosity(); bool original_verbose = verbosity_is_enabled();
bool original_verbose = *verbose; verbosity_enable();
*verbose = true;
#endif #endif
(void)args; (void)args;
@ -236,7 +235,10 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[],
} }
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
*verbose = original_verbose; if (original_verbose)
verbosity_enable();
else
verbosity_disable();
#endif #endif
} }
@ -383,10 +385,9 @@ static void frontend_ps3_exec(const char *path, bool should_load_game)
{ {
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
char *fullpath = NULL; char *fullpath = NULL;
bool *verbose = retro_main_verbosity(); bool original_verbose = verbosity_is_enabled();
bool original_verbose = *verbose;
*verbose = true; verbosity_enable();
#endif #endif
(void)should_load_game; (void)should_load_game;
@ -422,7 +423,10 @@ static void frontend_ps3_exec(const char *path, bool should_load_game)
cellSysmoduleUnloadModule(CELL_SYSMODULE_NET); cellSysmoduleUnloadModule(CELL_SYSMODULE_NET);
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
*verbose = original_verbose; if (original_verbose)
verbosity_enable();
else
verbosity_disable();
#endif #endif
} }
@ -432,9 +436,9 @@ static void frontend_ps3_exitspawn(char *core_path, size_t core_path_size)
bool should_load_game = false; bool should_load_game = false;
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
bool *verbose = retro_main_verbosity(); bool original_verbose = verbosity_is_enabled();
bool original_verbose = *verbose;
*verbose = true; verbosity_enable();
if (ps3_fork_mode == FRONTEND_FORK_NONE) if (ps3_fork_mode == FRONTEND_FORK_NONE)
{ {
@ -465,7 +469,10 @@ static void frontend_ps3_exitspawn(char *core_path, size_t core_path_size)
#endif #endif
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
*verbose = original_verbose; if (original_verbose)
verbosity_enable();
else
verbosity_disable();
#endif #endif
#endif #endif
} }

View File

@ -159,9 +159,7 @@ static void frontend_psp_deinit(void *data)
{ {
(void)data; (void)data;
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
bool *verbose = retro_main_verbosity(); verbosity_disable();
*verbose = false;
#ifdef HAVE_FILE_LOGGER #ifdef HAVE_FILE_LOGGER
command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL); command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL);
#endif #endif

View File

@ -121,9 +121,7 @@ void system_exec_wii(const char *_path, bool should_load_game)
char path[PATH_MAX_LENGTH]; char path[PATH_MAX_LENGTH];
char game_path[PATH_MAX_LENGTH]; char game_path[PATH_MAX_LENGTH];
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
bool *verbose = retro_main_verbosity(); bool original_verbose = verbosity_is_enabled();
bool original_verbose = *verbose;
*verbose = true;
#endif #endif
/* copy heap info into stack so it survives /* copy heap info into stack so it survives
@ -190,6 +188,9 @@ void system_exec_wii(const char *_path, bool should_load_game)
exit: exit:
(void)0; (void)0;
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
*verbose = original_verbose; if (original_verbose)
verbosity_enable();
else
verbosity_disable();
#endif #endif
} }

View File

@ -1030,9 +1030,7 @@ static HRESULT xbox_io_mount(const char* szDrive, char* szDevice)
static HRESULT xbox_io_mount(char *szDrive, char *szDevice) static HRESULT xbox_io_mount(char *szDrive, char *szDevice)
{ {
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
bool *verbose = retro_main_verbosity(); bool original_verbose = verbosity_is_enabled();
bool original_verbose = *verbose;
*verbose = true;
#endif #endif
char szSourceDevice[48] = {0}; char szSourceDevice[48] = {0};
char szDestinationDrive[16] = {0}; char szDestinationDrive[16] = {0};
@ -1059,7 +1057,10 @@ static HRESULT xbox_io_mount(char *szDrive, char *szDevice)
IoCreateSymbolicLink(&LinkName, &DeviceName); IoCreateSymbolicLink(&LinkName, &DeviceName);
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
*verbose = original_verbose; if (original_verbose)
verbosity_enable();
else
verbosity_disable();
#endif #endif
return S_OK; return S_OK;
} }
@ -1091,10 +1092,7 @@ static void frontend_xdk_get_environment_settings(int *argc, char *argv[],
(void)ret; (void)ret;
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
bool *verbose = retro_main_verbosity(); bool original_verbose = verbosity_is_enabled();
bool original_verbose = *verbose;
*verbose = true;
#endif #endif
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
@ -1226,7 +1224,10 @@ static void frontend_xdk_get_environment_settings(int *argc, char *argv[],
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
exit: exit:
*verbose = original_verbose; if (original_verbose)
verbosity_enable();
else
verbosity_disable();
#endif #endif
} }
@ -1247,9 +1248,7 @@ static void frontend_xdk_init(void *data)
static void frontend_xdk_exec(const char *path, bool should_load_game) static void frontend_xdk_exec(const char *path, bool should_load_game)
{ {
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
bool *verbose = retro_main_verbosity(); bool original_verbose = verbosity_is_enabled();
bool original_verbose = *verbose;
*verbose = true;
#endif #endif
(void)should_load_game; (void)should_load_game;
@ -1287,7 +1286,10 @@ static void frontend_xdk_exec(const char *path, bool should_load_game)
#endif #endif
#endif #endif
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
*verbose = original_verbose; if (original_verbose)
verbosity_enable();
else
verbosity_disable();
#endif #endif
} }

View File

@ -3056,9 +3056,11 @@ void general_write_handler(void *data)
break; break;
case MENU_LABEL_LOG_VERBOSITY: case MENU_LABEL_LOG_VERBOSITY:
{ {
bool *verbose = retro_main_verbosity(); if (setting->value.target.boolean && *setting->value.target.boolean)
verbosity_enable();
else
verbosity_disable();
*verbose = *setting->value.target.boolean;
global->has_set.verbosity = *setting->value.target.boolean; global->has_set.verbosity = *setting->value.target.boolean;
} }
break; break;
@ -4077,7 +4079,7 @@ static bool setting_append_list(
CONFIG_BOOL( CONFIG_BOOL(
list, list_info, list, list_info,
retro_main_verbosity(), verbosity_get_ptr(),
menu_hash_to_str(MENU_LABEL_LOG_VERBOSITY), menu_hash_to_str(MENU_LABEL_LOG_VERBOSITY),
menu_hash_to_str(MENU_LABEL_VALUE_LOG_VERBOSITY), menu_hash_to_str(MENU_LABEL_VALUE_LOG_VERBOSITY),
false, false,

View File

@ -794,9 +794,7 @@ static void retroarch_parse_input(int argc, char *argv[])
case 'v': case 'v':
{ {
bool *verbosity = retro_main_verbosity(); verbosity_enable();
if (verbosity)
*verbosity = true;
global->has_set.verbosity = true; global->has_set.verbosity = true;
} }
break; break;
@ -1263,8 +1261,6 @@ static void retroarch_validate_cpu_features(void)
**/ **/
bool retroarch_main_init(int argc, char *argv[]) bool retroarch_main_init(int argc, char *argv[])
{ {
bool *verbosity = NULL;
retroarch_init_state(); retroarch_init_state();
if (setjmp(error_sjlj_context) > 0) if (setjmp(error_sjlj_context) > 0)
@ -1277,9 +1273,7 @@ bool retroarch_main_init(int argc, char *argv[])
retro_main_log_file_init(NULL); retro_main_log_file_init(NULL);
retroarch_parse_input(argc, argv); retroarch_parse_input(argc, argv);
verbosity = retro_main_verbosity(); if (verbosity_is_enabled())
if (verbosity && *verbosity)
{ {
char str[PATH_MAX_LENGTH] = {0}; char str[PATH_MAX_LENGTH] = {0};

View File

@ -1545,7 +1545,7 @@ static void menu_content_environment_get(int *argc, char *argv[],
RARCH_MENU_CTL_HAS_LOAD_NO_CONTENT, NULL); RARCH_MENU_CTL_HAS_LOAD_NO_CONTENT, NULL);
if (!global->has_set.verbosity) if (!global->has_set.verbosity)
wrap_args->verbose = *retro_main_verbosity(); wrap_args->verbose = verbosity_is_enabled();
wrap_args->touched = true; wrap_args->touched = true;
wrap_args->config_path = NULL; wrap_args->config_path = NULL;

View File

@ -53,10 +53,25 @@
/* 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; static FILE *log_file;
static bool main_verbosity;
bool *retro_main_verbosity(void) void verbosity_enable(void)
{
main_verbosity = true;
}
void verbosity_disable(void)
{
main_verbosity = false;
}
bool verbosity_is_enabled(void)
{
return main_verbosity;
}
bool *verbosity_get_ptr(void)
{ {
static bool main_verbosity;
return &main_verbosity; return &main_verbosity;
} }
@ -82,15 +97,6 @@ void retro_main_log_file_deinit(void)
} }
#if !defined(HAVE_LOGGER) #if !defined(HAVE_LOGGER)
static bool RARCH_LOG_VERBOSE(void)
{
bool *verbose = NULL;
verbose = retro_main_verbosity();
if (!verbose)
return false;
return *verbose;
}
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 TARGET_OS_IPHONE #if TARGET_OS_IPHONE
@ -100,7 +106,7 @@ static aslclient asl_client;
#endif #endif
#endif #endif
if (!RARCH_LOG_VERBOSE()) if (!verbosity_is_enabled())
return; return;
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE
#if TARGET_IPHONE_SIMULATOR #if TARGET_IPHONE_SIMULATOR
@ -148,7 +154,7 @@ void RARCH_LOG(const char *fmt, ...)
{ {
va_list ap; va_list ap;
if (!RARCH_LOG_VERBOSE()) if (!verbosity_is_enabled())
return; return;
va_start(ap, fmt); va_start(ap, fmt);

View File

@ -27,7 +27,13 @@
extern "C" { extern "C" {
#endif #endif
bool *retro_main_verbosity(void); bool verbosity_is_enabled(void);
void verbosity_enable(void);
void verbosity_disable(void);
bool *verbosity_get_ptr(void);
FILE *retro_main_log_file(void); FILE *retro_main_log_file(void);