mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Close the global log targets on exit, flushing log files to disk
This commit is contained in:
parent
d6e6182e65
commit
febbeaeeed
@ -108,6 +108,8 @@ static void setScreenRes(int w, int h, int bpp, bool fullscreen, int displayInde
|
||||
void playIntro();
|
||||
static void mainLoop();
|
||||
|
||||
static CBasicLogConfigurator *logConfig;
|
||||
|
||||
#ifndef VCMI_WINDOWS
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
@ -230,8 +232,8 @@ int main(int argc, char * argv[])
|
||||
console->start();
|
||||
|
||||
const bfs::path logPath = VCMIDirs::get().userCachePath() / "VCMI_Client_log.txt";
|
||||
CBasicLogConfigurator logConfig(logPath, console);
|
||||
logConfig.configureDefault();
|
||||
logConfig = new CBasicLogConfigurator(logPath, console);
|
||||
logConfig->configureDefault();
|
||||
logGlobal->info(NAME);
|
||||
logGlobal->info("Creating console and configuring logger: %d ms", pomtime.getDiff());
|
||||
logGlobal->info("The log file will be saved to %s", logPath);
|
||||
@ -292,7 +294,7 @@ int main(int argc, char * argv[])
|
||||
setSettingInteger("general/saveFrequency", "savefrequency", 1);
|
||||
|
||||
// Initialize logging based on settings
|
||||
logConfig.configure();
|
||||
logConfig->configure();
|
||||
logGlobal->debug("settings = %s", settings.toJsonNode().toJson());
|
||||
|
||||
// Some basic data validation to produce better error messages in cases of incorrect install
|
||||
@ -1434,6 +1436,12 @@ void handleQuit(bool ask)
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
if(logConfig != nullptr) {
|
||||
logConfig->deconfigure();
|
||||
delete logConfig;
|
||||
logConfig = nullptr;
|
||||
}
|
||||
|
||||
std::cout << "Ending...\n";
|
||||
exit(0);
|
||||
};
|
||||
|
@ -956,6 +956,7 @@ int main(int argc, char * argv[])
|
||||
CAndroidVMHelper envHelper;
|
||||
envHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "killServer");
|
||||
#endif
|
||||
logConfig.deconfigure();
|
||||
vstd::clear_pointer(VLC);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user