log to ~/flycast.log if ./flycast.log isn't valid

This commit is contained in:
Flyinghead 2020-12-29 13:12:00 +01:00
parent cc7a292591
commit 467e7954a5
3 changed files with 14 additions and 4 deletions

View File

@ -135,7 +135,17 @@ LogManager::LogManager()
#else
std::string logPath = "flycast.log";
#endif
RegisterListener(LogListener::FILE_LISTENER, new FileLogListener(logPath));
FileLogListener *listener = new FileLogListener(logPath);
if (!listener->IsValid())
{
const char *home = getenv("HOME");
if (home != nullptr)
{
delete listener;
listener = new FileLogListener(home + ("/" + logPath));
}
}
RegisterListener(LogListener::FILE_LISTENER, listener);
EnableListener(LogListener::FILE_LISTENER, true);
}
EnableListener(LogListener::CONSOLE_LISTENER, cfgLoadBool("log", "LogToConsole", true));

View File

@ -435,6 +435,8 @@ int reicast_init(int argc, char* argv[])
LogManager::Init();
LoadSettings(false);
}
for (int i = 1; i < argc; i++)
NOTICE_LOG(BOOT, "Arg %d: %s", i, argv[i]);
settings.pvr.rend = (RenderType)cfgLoadInt("config", "pvr.rend", (int)settings.pvr.rend);
os_CreateWindow();

View File

@ -99,6 +99,7 @@ extern "C" void emu_dc_term()
if (dc_is_running())
dc_exit();
dc_term();
LogManager::Shutdown();
}
extern "C" void emu_dc_resume()
@ -201,10 +202,7 @@ extern "C" int emu_reicast_init()
unsigned long argc = [arguments count];
char **argv = (char **)malloc(argc * sizeof(char*));
for (unsigned long i = 0; i < argc; i++)
{
argv[i] = strdup([[arguments objectAtIndex:i] UTF8String]);
NOTICE_LOG(BOOT, "Arg %d: %s", i+1, argv[i]);
}
int rc = reicast_init((int)argc, argv);