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;
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
bool *verbose = retro_main_verbosity();
if (path)
{
@ -1268,7 +1267,7 @@ static bool config_load_file(const char *path, bool set_defaults)
extra_path = strtok_r(NULL, "|", &save);
}
#if 0
if (*verbose)
if (verbosity_is_enabled())
{
RARCH_LOG_OUTPUT("=== Config ===\n");
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 (verbose)
*verbose = tmp_bool;
if (tmp_bool)
verbosity_enable();
else
verbosity_disable();
}
}
@ -2529,6 +2530,7 @@ bool config_save_file(const char *path)
{
float msg_color;
unsigned i = 0;
bool tmp_bool = false;
bool ret = false;
config_file_t *conf = config_file_new(path);
settings_t *settings = config_get_ptr();
@ -2944,12 +2946,9 @@ bool config_save_file(const char *path)
config_set_bool(conf, "sort_savestates_enable",
settings->sort_savestates_enable);
config_set_int(conf, "libretro_log_level", settings->libretro_log_level);
config_set_bool(conf, "log_verbosity", *retro_main_verbosity());
{
bool perfcnt_enable = runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL);
config_set_bool(conf, "perfcnt_enable", perfcnt_enable);
}
config_set_bool(conf, "log_verbosity", verbosity_is_enabled());
config_set_bool(conf, "perfcnt_enable", runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL));
#if TARGET_OS_IPHONE
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;
(void)data;
#ifndef IS_SALAMANDER
bool *verbose = retro_main_verbosity();
*verbose = true;
verbosity_enable();
#ifdef HAVE_FILE_LOGGER
command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL);
@ -187,9 +186,7 @@ static void frontend_ctr_init(void *data)
{
#ifndef IS_SALAMANDER
(void)data;
bool *verbose = retro_main_verbosity();
*verbose = true;
verbosity_enable();
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)
{
#ifndef IS_SALAMANDER
bool *verbose = retro_main_verbosity();
bool original_verbose = *verbose;
*verbose = true;
bool original_verbose = verbosity_is_enabled();
verbosity_enable();
#endif
(void)args;
@ -236,7 +235,10 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[],
}
#ifndef IS_SALAMANDER
*verbose = original_verbose;
if (original_verbose)
verbosity_enable();
else
verbosity_disable();
#endif
}
@ -383,10 +385,9 @@ static void frontend_ps3_exec(const char *path, bool should_load_game)
{
#ifndef IS_SALAMANDER
char *fullpath = NULL;
bool *verbose = retro_main_verbosity();
bool original_verbose = *verbose;
bool original_verbose = verbosity_is_enabled();
*verbose = true;
verbosity_enable();
#endif
(void)should_load_game;
@ -422,7 +423,10 @@ static void frontend_ps3_exec(const char *path, bool should_load_game)
cellSysmoduleUnloadModule(CELL_SYSMODULE_NET);
#ifndef IS_SALAMANDER
*verbose = original_verbose;
if (original_verbose)
verbosity_enable();
else
verbosity_disable();
#endif
}
@ -432,9 +436,9 @@ static void frontend_ps3_exitspawn(char *core_path, size_t core_path_size)
bool should_load_game = false;
#ifndef IS_SALAMANDER
bool *verbose = retro_main_verbosity();
bool original_verbose = *verbose;
*verbose = true;
bool original_verbose = verbosity_is_enabled();
verbosity_enable();
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
#ifndef IS_SALAMANDER
*verbose = original_verbose;
if (original_verbose)
verbosity_enable();
else
verbosity_disable();
#endif
#endif
}

View File

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

View File

@ -121,9 +121,7 @@ void system_exec_wii(const char *_path, bool should_load_game)
char path[PATH_MAX_LENGTH];
char game_path[PATH_MAX_LENGTH];
#ifndef IS_SALAMANDER
bool *verbose = retro_main_verbosity();
bool original_verbose = *verbose;
*verbose = true;
bool original_verbose = verbosity_is_enabled();
#endif
/* copy heap info into stack so it survives
@ -190,6 +188,9 @@ void system_exec_wii(const char *_path, bool should_load_game)
exit:
(void)0;
#ifndef IS_SALAMANDER
*verbose = original_verbose;
if (original_verbose)
verbosity_enable();
else
verbosity_disable();
#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)
{
#ifndef IS_SALAMANDER
bool *verbose = retro_main_verbosity();
bool original_verbose = *verbose;
*verbose = true;
bool original_verbose = verbosity_is_enabled();
#endif
char szSourceDevice[48] = {0};
char szDestinationDrive[16] = {0};
@ -1059,7 +1057,10 @@ static HRESULT xbox_io_mount(char *szDrive, char *szDevice)
IoCreateSymbolicLink(&LinkName, &DeviceName);
#ifndef IS_SALAMANDER
*verbose = original_verbose;
if (original_verbose)
verbosity_enable();
else
verbosity_disable();
#endif
return S_OK;
}
@ -1091,10 +1092,7 @@ static void frontend_xdk_get_environment_settings(int *argc, char *argv[],
(void)ret;
#ifndef IS_SALAMANDER
bool *verbose = retro_main_verbosity();
bool original_verbose = *verbose;
*verbose = true;
bool original_verbose = verbosity_is_enabled();
#endif
#ifndef IS_SALAMANDER
@ -1226,7 +1224,10 @@ static void frontend_xdk_get_environment_settings(int *argc, char *argv[],
#ifndef IS_SALAMANDER
exit:
*verbose = original_verbose;
if (original_verbose)
verbosity_enable();
else
verbosity_disable();
#endif
}
@ -1247,9 +1248,7 @@ static void frontend_xdk_init(void *data)
static void frontend_xdk_exec(const char *path, bool should_load_game)
{
#ifndef IS_SALAMANDER
bool *verbose = retro_main_verbosity();
bool original_verbose = *verbose;
*verbose = true;
bool original_verbose = verbosity_is_enabled();
#endif
(void)should_load_game;
@ -1287,7 +1286,10 @@ static void frontend_xdk_exec(const char *path, bool should_load_game)
#endif
#endif
#ifndef IS_SALAMANDER
*verbose = original_verbose;
if (original_verbose)
verbosity_enable();
else
verbosity_disable();
#endif
}

View File

@ -3056,9 +3056,11 @@ void general_write_handler(void *data)
break;
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;
}
break;
@ -4077,7 +4079,7 @@ static bool setting_append_list(
CONFIG_BOOL(
list, list_info,
retro_main_verbosity(),
verbosity_get_ptr(),
menu_hash_to_str(MENU_LABEL_LOG_VERBOSITY),
menu_hash_to_str(MENU_LABEL_VALUE_LOG_VERBOSITY),
false,

View File

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

View File

@ -53,10 +53,25 @@
/* If this is non-NULL. RARCH_LOG and friends
* will write to this 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;
}
@ -82,15 +97,6 @@ void retro_main_log_file_deinit(void)
}
#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)
{
#if TARGET_OS_IPHONE
@ -100,7 +106,7 @@ static aslclient asl_client;
#endif
#endif
if (!RARCH_LOG_VERBOSE())
if (!verbosity_is_enabled())
return;
#if TARGET_OS_IPHONE
#if TARGET_IPHONE_SIMULATOR
@ -148,7 +154,7 @@ void RARCH_LOG(const char *fmt, ...)
{
va_list ap;
if (!RARCH_LOG_VERBOSE())
if (!verbosity_is_enabled())
return;
va_start(ap, fmt);

View File

@ -27,7 +27,13 @@
extern "C" {
#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);