mirror of
https://github.com/libretro/RetroArch
synced 2024-12-29 12:31:05 +00:00
Move log_file code to verbosity.c
This commit is contained in:
parent
76d6378228
commit
a9cb970d0d
@ -1707,12 +1707,7 @@ bool event_command(enum event_command cmd)
|
||||
global->subsystem_fullpaths = NULL;
|
||||
break;
|
||||
case EVENT_CMD_LOG_FILE_DEINIT:
|
||||
if (!global)
|
||||
break;
|
||||
|
||||
if (global->log_file && global->log_file != stderr)
|
||||
fclose(global->log_file);
|
||||
global->log_file = NULL;
|
||||
retro_main_log_file_deinit();
|
||||
break;
|
||||
case EVENT_CMD_DISK_EJECT_TOGGLE:
|
||||
if (info && info->disk_control.get_num_images)
|
||||
|
@ -49,8 +49,7 @@ static void frontend_ctr_get_environment_settings(int *argc, char *argv[],
|
||||
#if defined(HAVE_LOGGER)
|
||||
logger_init();
|
||||
#elif defined(HAVE_FILE_LOGGER)
|
||||
global_t *global = global_get_ptr();
|
||||
global->log_file = fopen("sdmc:/retroarch/retroarch-log.txt", "w");
|
||||
retro_main_log_file_init("sdmc:/retroarch/retroarch-log.txt");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -108,7 +107,6 @@ static void frontend_ctr_deinit(void *data)
|
||||
u8 not_2DS;
|
||||
(void)data;
|
||||
#ifndef IS_SALAMANDER
|
||||
global_t *global = global_get_ptr();
|
||||
bool *verbose = retro_main_verbosity();
|
||||
*verbose = true;
|
||||
|
||||
@ -197,7 +195,6 @@ static void frontend_ctr_init(void *data)
|
||||
{
|
||||
#ifndef IS_SALAMANDER
|
||||
(void)data;
|
||||
global_t *global = global_get_ptr();
|
||||
bool *verbose = retro_main_verbosity();
|
||||
|
||||
*verbose = true;
|
||||
|
@ -149,9 +149,7 @@ int gx_logger_net(struct _reent *r, int fd, const char *ptr, size_t len)
|
||||
#elif defined(HAVE_FILE_LOGGER)
|
||||
int gx_logger_file(struct _reent *r, int fd, const char *ptr, size_t len)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
fwrite(ptr, 1, len, global->log_file);
|
||||
fwrite(ptr, 1, len, retro_main_log_file());
|
||||
return len;
|
||||
}
|
||||
#endif
|
||||
@ -169,8 +167,7 @@ static void frontend_gx_get_environment_settings(int *argc, char *argv[],
|
||||
#if defined(HAVE_LOGGER)
|
||||
logger_init();
|
||||
#elif defined(HAVE_FILE_LOGGER)
|
||||
global_t *global = global_get_ptr();
|
||||
global->log_file = fopen("/retroarch-log.txt", "w");
|
||||
retro_main_log_file_init("/retroarch-log.txt");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -97,7 +97,6 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[],
|
||||
void *args, void *params_data)
|
||||
{
|
||||
#ifndef IS_SALAMANDER
|
||||
global_t *global = global_get_ptr();
|
||||
bool *verbose = retro_main_verbosity();
|
||||
bool original_verbose = *verbose;
|
||||
*verbose = true;
|
||||
@ -108,7 +107,7 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[],
|
||||
#if defined(HAVE_LOGGER)
|
||||
logger_init();
|
||||
#elif defined(HAVE_FILE_LOGGER)
|
||||
global->log_file = fopen("/retroarch-log.txt", "w");
|
||||
retro_main_log_file_init("/retroarch-log.txt");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -361,7 +360,6 @@ static void frontend_ps3_exec(const char *path, bool should_load_game)
|
||||
{
|
||||
#ifndef IS_SALAMANDER
|
||||
char *fullpath = NULL;
|
||||
global_t *global = global_get_ptr();
|
||||
bool *verbose = retro_main_verbosity();
|
||||
bool original_verbose = *verbose;
|
||||
|
||||
@ -411,7 +409,6 @@ static void frontend_ps3_exitspawn(char *core_path, size_t core_path_size)
|
||||
bool should_load_game = false;
|
||||
|
||||
#ifndef IS_SALAMANDER
|
||||
global_t *global = global_get_ptr();
|
||||
bool *verbose = retro_main_verbosity();
|
||||
bool original_verbose = *verbose;
|
||||
|
||||
|
@ -80,8 +80,7 @@ static void frontend_psp_get_environment_settings(int *argc, char *argv[],
|
||||
logger_init();
|
||||
#elif defined(HAVE_FILE_LOGGER)
|
||||
#ifndef VITA
|
||||
global_t *global = global_get_ptr();
|
||||
global->log_file = fopen("ms0:/retroarch-log.txt", "w");
|
||||
retro_main_log_file_init("ms0:/retroarch-log.txt");
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
@ -73,7 +73,6 @@ HRESULT xbox_io_mount(const char* szDrive, char* szDevice)
|
||||
static HRESULT xbox_io_mount(char *szDrive, char *szDevice)
|
||||
{
|
||||
#ifndef IS_SALAMANDER
|
||||
global_t *global = global_get_ptr();
|
||||
bool *verbose = retro_main_verbosity();
|
||||
bool original_verbose = *verbose;
|
||||
*verbose = true;
|
||||
@ -135,7 +134,6 @@ static void frontend_xdk_get_environment_settings(int *argc, char *argv[],
|
||||
(void)ret;
|
||||
|
||||
#ifndef IS_SALAMANDER
|
||||
global_t *global = global_get_ptr();
|
||||
bool *verbose = retro_main_verbosity();
|
||||
bool original_verbose = *verbose;
|
||||
|
||||
@ -146,7 +144,7 @@ static void frontend_xdk_get_environment_settings(int *argc, char *argv[],
|
||||
#if defined(HAVE_LOGGER)
|
||||
logger_init();
|
||||
#elif defined(HAVE_FILE_LOGGER)
|
||||
global->log_file = fopen("/retroarch-log.txt", "w");
|
||||
retro_main_log_file_init("/retroarch-log.txt");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -312,7 +310,6 @@ static void frontend_xdk_exitspawn(char *s, size_t len)
|
||||
static void frontend_xdk_exec(const char *path, bool should_load_game)
|
||||
{
|
||||
#ifndef IS_SALAMANDER
|
||||
global_t *global = global_get_ptr();
|
||||
bool *verbose = retro_main_verbosity();
|
||||
bool original_verbose = *verbose;
|
||||
*verbose = true;
|
||||
|
@ -890,7 +890,7 @@ static void parse_input(int argc, char *argv[])
|
||||
|
||||
#ifdef HAVE_FILE_LOGGER
|
||||
case RA_OPT_LOG_FILE:
|
||||
global->log_file = fopen(optarg, "wb");
|
||||
retro_main_log_file_init(optarg);
|
||||
break;
|
||||
#endif
|
||||
|
||||
@ -1141,7 +1141,7 @@ int rarch_main_init(int argc, char *argv[])
|
||||
return sjlj_ret;
|
||||
}
|
||||
global->inited.error = true;
|
||||
global->log_file = stderr;
|
||||
retro_main_log_file_init(NULL);
|
||||
parse_input(argc, argv);
|
||||
|
||||
verbosity = retro_main_verbosity();
|
||||
|
@ -765,14 +765,6 @@ static void rarch_main_iterate_linefeed_overlay(driver_t *driver,
|
||||
}
|
||||
#endif
|
||||
|
||||
FILE *retro_main_log_file(void)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
if (!global)
|
||||
return NULL;
|
||||
return global->log_file;
|
||||
}
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
static bool rarch_main_cmd_get_state_menu_toggle_button_combo(
|
||||
driver_t *driver, settings_t *settings,
|
||||
|
@ -309,10 +309,6 @@ typedef struct global
|
||||
async_job_t *async_jobs;
|
||||
#endif
|
||||
|
||||
/* If this is non-NULL. RARCH_LOG and friends
|
||||
* will write to this file. */
|
||||
FILE *log_file;
|
||||
|
||||
struct
|
||||
{
|
||||
bool main;
|
||||
@ -354,8 +350,6 @@ void rarch_main_msg_queue_free(void);
|
||||
|
||||
void rarch_main_msg_queue_init(void);
|
||||
|
||||
FILE *retro_main_log_file(void);
|
||||
|
||||
bool rarch_main_ctl(enum rarch_main_ctl_state state, void *data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
25
verbosity.c
25
verbosity.c
@ -17,7 +17,32 @@
|
||||
|
||||
static bool main_verbosity;
|
||||
|
||||
/* If this is non-NULL. RARCH_LOG and friends
|
||||
* will write to this file. */
|
||||
static FILE *log_file;
|
||||
|
||||
bool *retro_main_verbosity(void)
|
||||
{
|
||||
return &main_verbosity;
|
||||
}
|
||||
|
||||
FILE *retro_main_log_file(void)
|
||||
{
|
||||
return log_file;
|
||||
}
|
||||
|
||||
void retro_main_log_file_init(const char *path)
|
||||
{
|
||||
log_file = stderr;
|
||||
if (path == NULL)
|
||||
return;
|
||||
|
||||
log_file = fopen(path, "wb");
|
||||
}
|
||||
|
||||
void retro_main_log_file_deinit(void)
|
||||
{
|
||||
if (log_file && log_file != stderr)
|
||||
fclose(log_file);
|
||||
log_file = NULL;
|
||||
}
|
||||
|
@ -46,14 +46,18 @@ extern "C" {
|
||||
|
||||
bool *retro_main_verbosity(void);
|
||||
|
||||
FILE *retro_main_log_file(void);
|
||||
|
||||
void retro_main_log_file_deinit(void);
|
||||
|
||||
void retro_main_log_file_init(const char *path);
|
||||
|
||||
#if defined(HAVE_FILE_LOGGER)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
|
||||
FILE *retro_main_log_file(void);
|
||||
|
||||
#define LOG_FILE (retro_main_log_file())
|
||||
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user