mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 13:20:43 +00:00
Enable verbosity and logging before initial config file load
This commit is contained in:
parent
c3fee95273
commit
c844705665
@ -3067,6 +3067,7 @@ static bool config_load_file(global_t *global,
|
|||||||
bool ret = false;
|
bool ret = false;
|
||||||
unsigned tmp_uint = 0;
|
unsigned tmp_uint = 0;
|
||||||
bool tmp_bool = false;
|
bool tmp_bool = false;
|
||||||
|
static bool first_load = true;
|
||||||
unsigned msg_color = 0;
|
unsigned msg_color = 0;
|
||||||
char *save = NULL;
|
char *save = NULL;
|
||||||
char *override_username = NULL;
|
char *override_username = NULL;
|
||||||
@ -3158,13 +3159,24 @@ static bool config_load_file(global_t *global,
|
|||||||
settings->bools.network_remote_enable_user[i], tmp_bool);
|
settings->bools.network_remote_enable_user[i], tmp_bool);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (config_get_bool(conf, "log_verbosity", &tmp_bool))
|
/* Set verbosity according to config only if the 'v' command line argument was not used
|
||||||
|
* or if it is not the first config load. */
|
||||||
|
if (config_get_bool(conf, "log_verbosity", &tmp_bool) &&
|
||||||
|
(!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_VERBOSITY, NULL) ||
|
||||||
|
!first_load))
|
||||||
{
|
{
|
||||||
if (tmp_bool)
|
if (tmp_bool)
|
||||||
verbosity_enable();
|
verbosity_enable();
|
||||||
else
|
else
|
||||||
verbosity_disable();
|
verbosity_disable();
|
||||||
}
|
}
|
||||||
|
/* On first config load, make sure log_to_file is true if 'log-file' command line
|
||||||
|
* argument was used. */
|
||||||
|
if (retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_LOG_TO_FILE, NULL) &&
|
||||||
|
first_load)
|
||||||
|
{
|
||||||
|
configuration_set_bool(settings,settings->bools.log_to_file,true);
|
||||||
|
}
|
||||||
if (config_get_uint(conf, "frontend_log_level", &tmp_uint))
|
if (config_get_uint(conf, "frontend_log_level", &tmp_uint))
|
||||||
{
|
{
|
||||||
verbosity_set_log_level(tmp_uint);
|
verbosity_set_log_level(tmp_uint);
|
||||||
@ -3595,6 +3607,7 @@ end:
|
|||||||
free(path_settings);
|
free(path_settings);
|
||||||
if (size_settings)
|
if (size_settings)
|
||||||
free(size_settings);
|
free(size_settings);
|
||||||
|
first_load = false;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3941,15 +3954,15 @@ success:
|
|||||||
*/
|
*/
|
||||||
static void config_parse_file(global_t *global)
|
static void config_parse_file(global_t *global)
|
||||||
{
|
{
|
||||||
|
const char *config_path = path_get(RARCH_PATH_CONFIG);
|
||||||
if (path_is_empty(RARCH_PATH_CONFIG))
|
if (path_is_empty(RARCH_PATH_CONFIG))
|
||||||
{
|
{
|
||||||
RARCH_LOG("[Config]: Loading default config.\n");
|
RARCH_LOG("[Config]: Loading default config.\n");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
RARCH_LOG("[Config]: Loading config from: \"%s\".\n", config_path);
|
||||||
|
|
||||||
{
|
{
|
||||||
const char *config_path = path_get(RARCH_PATH_CONFIG);
|
|
||||||
RARCH_LOG("[Config]: Loading config from: \"%s\".\n", config_path);
|
|
||||||
|
|
||||||
if (!config_load_file(global, config_path, config_get_ptr()))
|
if (!config_load_file(global, config_path, config_get_ptr()))
|
||||||
{
|
{
|
||||||
RARCH_ERR("[Config]: Couldn't find config at path: \"%s\".\n",
|
RARCH_ERR("[Config]: Couldn't find config at path: \"%s\".\n",
|
||||||
|
60
retroarch.c
60
retroarch.c
@ -35184,6 +35184,22 @@ static bool retroarch_parse_input_and_config(
|
|||||||
retroarch_override_setting_set(
|
retroarch_override_setting_set(
|
||||||
RARCH_OVERRIDE_SETTING_STATE_PATH, NULL);
|
RARCH_OVERRIDE_SETTING_STATE_PATH, NULL);
|
||||||
break;
|
break;
|
||||||
|
case 'v':
|
||||||
|
verbosity_enable();
|
||||||
|
retroarch_override_setting_set(
|
||||||
|
RARCH_OVERRIDE_SETTING_VERBOSITY, NULL);
|
||||||
|
break;
|
||||||
|
case RA_OPT_LOG_FILE:
|
||||||
|
/* Enable 'log to file' */
|
||||||
|
configuration_set_bool(p_rarch->configuration_settings,
|
||||||
|
p_rarch->configuration_settings->bools.log_to_file, true);
|
||||||
|
|
||||||
|
retroarch_override_setting_set(
|
||||||
|
RARCH_OVERRIDE_SETTING_LOG_TO_FILE, NULL);
|
||||||
|
|
||||||
|
/* Cache log file path override */
|
||||||
|
rarch_log_file_set_override(optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
/* Must handle '?' otherwise you get an infinite loop */
|
/* Must handle '?' otherwise you get an infinite loop */
|
||||||
case '?':
|
case '?':
|
||||||
@ -35194,6 +35210,13 @@ static bool retroarch_parse_input_and_config(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
verbosity_enabled = verbosity_is_enabled();
|
||||||
|
/* Enable logging to file if verbosity and log-file arguments were passed.
|
||||||
|
* RARCH_OVERRIDE_SETTING_LOG_TO_FILE is set by the RA_OPT_LOG_FILE case above
|
||||||
|
* The parameters passed to rarch_log_file_init are hardcoded as the config
|
||||||
|
* has not yet been initialized at this point. */
|
||||||
|
if (verbosity_enabled && retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_LOG_TO_FILE, NULL))
|
||||||
|
rarch_log_file_init(true,false,'\0');
|
||||||
|
|
||||||
/* Flush out some states that could have been set
|
/* Flush out some states that could have been set
|
||||||
* by core environment variables. */
|
* by core environment variables. */
|
||||||
@ -35213,6 +35236,15 @@ static bool retroarch_parse_input_and_config(
|
|||||||
config_load(&p_rarch->g_extern);
|
config_load(&p_rarch->g_extern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
verbosity_enabled = verbosity_is_enabled();
|
||||||
|
/* Init logging after config load only if not overridden by command line argument.
|
||||||
|
* This handles when logging is set in the config but not via the --log-file option. */
|
||||||
|
if (verbosity_enabled && !retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_LOG_TO_FILE, NULL))
|
||||||
|
rarch_log_file_init(
|
||||||
|
p_rarch->configuration_settings->bools.log_to_file,
|
||||||
|
p_rarch->configuration_settings->bools.log_to_file_timestamp,
|
||||||
|
p_rarch->configuration_settings->paths.log_dir);
|
||||||
|
|
||||||
/* Second pass: All other arguments override the config file */
|
/* Second pass: All other arguments override the config file */
|
||||||
optind = 1;
|
optind = 1;
|
||||||
|
|
||||||
@ -35279,12 +35311,6 @@ static bool retroarch_parse_input_and_config(
|
|||||||
p_rarch->rarch_force_fullscreen = true;
|
p_rarch->rarch_force_fullscreen = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'v':
|
|
||||||
verbosity_enable();
|
|
||||||
retroarch_override_setting_set(
|
|
||||||
RARCH_OVERRIDE_SETTING_VERBOSITY, NULL);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'N':
|
case 'N':
|
||||||
{
|
{
|
||||||
unsigned new_port;
|
unsigned new_port;
|
||||||
@ -35589,18 +35615,6 @@ static bool retroarch_parse_input_and_config(
|
|||||||
retroarch_print_version();
|
retroarch_print_version();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case RA_OPT_LOG_FILE:
|
|
||||||
/* Enable 'log to file' */
|
|
||||||
configuration_set_bool(p_rarch->configuration_settings,
|
|
||||||
p_rarch->configuration_settings->bools.log_to_file, true);
|
|
||||||
|
|
||||||
retroarch_override_setting_set(
|
|
||||||
RARCH_OVERRIDE_SETTING_LOG_TO_FILE, NULL);
|
|
||||||
|
|
||||||
/* Cache log file path override */
|
|
||||||
rarch_log_file_set_override(optarg);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
#ifdef HAVE_CONFIGFILE
|
#ifdef HAVE_CONFIGFILE
|
||||||
case 'c':
|
case 'c':
|
||||||
@ -35608,6 +35622,8 @@ static bool retroarch_parse_input_and_config(
|
|||||||
#endif
|
#endif
|
||||||
case 's':
|
case 's':
|
||||||
case 'S':
|
case 'S':
|
||||||
|
case 'v':
|
||||||
|
case RA_OPT_LOG_FILE:
|
||||||
break; /* Handled in the first pass */
|
break; /* Handled in the first pass */
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
@ -35628,14 +35644,6 @@ static bool retroarch_parse_input_and_config(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
verbosity_enabled = verbosity_is_enabled();
|
|
||||||
|
|
||||||
if (verbosity_enabled)
|
|
||||||
rarch_log_file_init(
|
|
||||||
p_rarch->configuration_settings->bools.log_to_file,
|
|
||||||
p_rarch->configuration_settings->bools.log_to_file_timestamp,
|
|
||||||
p_rarch->configuration_settings->paths.log_dir);
|
|
||||||
|
|
||||||
#ifdef HAVE_GIT_VERSION
|
#ifdef HAVE_GIT_VERSION
|
||||||
RARCH_LOG("RetroArch %s (Git %s)\n",
|
RARCH_LOG("RetroArch %s (Git %s)\n",
|
||||||
PACKAGE_VERSION, retroarch_git_version);
|
PACKAGE_VERSION, retroarch_git_version);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user