main: improve logging.

This commit is contained in:
Guillaume Jacquemin 2022-03-30 14:18:23 +02:00
parent 14d75e0e83
commit ef05c075ba

View file

@ -25,7 +25,20 @@
#include <winerror.h> #include <winerror.h>
int main(int argc, char** argv) { int main(int argc, char** argv) {
void* mutex_handle = CreateMutexW(nullptr, 0, L"MassBuilderSaveTool"); #ifndef SAVETOOL_DEBUG_BUILD
std::ofstream output{"SaveToolLog.txt", std::ios::trunc|std::ios::out};
Utility::Debug d{&output};
Utility::Warning w{&output};
Utility::Error e{&output};
#else
Utility::Warning w{Utility::Debug::defaultOutput()};
Utility::Error e{Utility::Debug::defaultOutput()};
#endif
Utility::Debug{} << "===M.A.S.S. Builder Save Tool version " SAVETOOL_VERSION "===";
auto mutex_handle = CreateMutexW(nullptr, 0, L"MassBuilderSaveTool");
if(!mutex_handle) { if(!mutex_handle) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app", SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app",
@ -39,14 +52,7 @@ int main(int argc, char** argv) {
return EXIT_FAILURE; return EXIT_FAILURE;
} }
#ifndef SAVETOOL_DEBUG_BUILD Utility::Debug{} << "===Initialising OpenGL renderer===";
std::ofstream output{"SaveToolLog.txt", std::ios::trunc|std::ios::out};
Utility::Debug d{&output};
Utility::Warning w{&output};
Utility::Error e{&output};
#endif
SaveTool app({argc, argv}); SaveTool app({argc, argv});
Int result = app.exec(); Int result = app.exec();