Logging cleanup (#69)

* Mac OS X 10.6 & More C++03 Support

* Fix SDL2 options.txt loading for C++03

* Output/Logging Overhaul
* Added StandardOut class
* Renamed LOGX macros to LOG_X
* Removed LogMsg macros in favor of LOG_X
* Added console window for debug Windows builds

* Updated Xcode Project
+ StandardOut.hpp
+ StandardOut.cpp

* StandardOut_windows
* Replaced the Windows #ifdefs in StandardOut with StandardOut_windows

---------

Co-authored-by: Brent Da Mage <BrentDaMage@users.noreply.github.com>
This commit is contained in:
Brent
2023-08-28 02:55:41 -05:00
committed by GitHub
parent f7915a1dab
commit 5c1ea03747
43 changed files with 326 additions and 207 deletions

View File

@@ -107,7 +107,7 @@ void AppPlatform_sdl::ensureDirectoryExists(const char* path)
if (ret != 0)
{
// Unable To Create Folder
LogMsg("Error Creating Directory: %s: %s", path, strerror(errno));
LOG_E("Error Creating Directory: %s: %s", path, strerror(errno));
exit(EXIT_FAILURE);
}
}
@@ -177,11 +177,11 @@ void AppPlatform_sdl::saveScreenshot(const std::string& filename, int glWidth, i
// Save Image
if (fail || save_png(file.c_str(), pixels, line_size, width, height))
{
LogMsg("Screenshot Failed: %s", file.c_str());
LOG_E("Screenshot Failed: %s", file.c_str());
}
else
{
LogMsg("Screenshot Saved: %s", file.c_str());
LOG_I("Screenshot Saved: %s", file.c_str());
}
// Free
@@ -284,8 +284,8 @@ Texture AppPlatform_sdl::loadTexture(const std::string& path, bool b)
SDL_RWclose(io);
}
// TODO: I don't think this logic makes any sense
LogMsg("Couldn't find file: %s", path.c_str());
// TODO: I don't think this logic makes any sense
LOG_E("Couldn't find file: %s", path.c_str());
return out;
}
@@ -299,12 +299,12 @@ std::vector<std::string> AppPlatform_sdl::getOptionStrings()
// TODO: This isn't specific to SDL2. Why isn't it in an AppPlatform base class?
std::vector<std::string> o;
LogMsg("Storage dir is %s", _storageDir.c_str());
LOG_I("Storage dir is %s", _storageDir.c_str());
std::ifstream ifs(getOptionsFilePath().c_str());
if (!ifs.is_open())
{
LogMsg("Warning, options.txt doesn't exist, resetting to defaults");
LOG_W("options.txt doesn't exist, resetting to defaults");
return o;
}
@@ -340,7 +340,7 @@ void AppPlatform_sdl::setOptionStrings(const std::vector<std::string>& str)
os.open(getOptionsFilePath().c_str());
if (!os.is_open())
{
LogMsg("Error, options.txt can't be opened");
LOG_E("Failed to read options.txt");
return;
}

View File

@@ -56,7 +56,7 @@ SDL_Surface* AppPlatform_sdlbase::getSurfaceForTexture(const Texture* const text
0xFF000000
);
if (!surface)
LogMsg("Error loading SDL_Surface from Texture: %s", SDL_GetError());
LOG_E("Failed loading SDL_Surface from Texture: %s", SDL_GetError());
return surface;
}

View File

@@ -26,27 +26,6 @@ typedef AppPlatform_sdl UsedAppPlatform;
static float g_fPointToPixelScale = 1.0f;
void LogMsg(const char* fmt, ...)
{
va_list lst;
va_start(lst, fmt);
vprintf(fmt, lst);
printf("\n");
va_end(lst);
}
// I hate duplicating code, but yeah
void LogMsgNoCR(const char* fmt, ...)
{
va_list lst;
va_start(lst, fmt);
vprintf(fmt, lst);
va_end(lst);
}
UsedAppPlatform *g_pAppPlatform;
NinecraftApp *g_pApp;
@@ -262,7 +241,7 @@ int main(int argc, char *argv[])
{
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
LOGE("Unable To Initialize SDL: %s\n", SDL_GetError());
LOG_E("Unable To Initialize SDL: %s\n", SDL_GetError());
exit(EXIT_FAILURE);
}
@@ -290,7 +269,7 @@ int main(int argc, char *argv[])
window = SDL_CreateWindow("ReMinecraftPE", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, Minecraft::width, Minecraft::height, flags);
if (!window)
{
LOGE("Unable to create SDL window\n");
LOG_E("Unable to create SDL window\n");
exit(EXIT_FAILURE);
}
@@ -301,7 +280,7 @@ int main(int argc, char *argv[])
context = SDL_GL_CreateContext(window);
if (!context)
{
LOGE("Unable to create OpenGL context\n");
LOG_E("Unable to create OpenGL context\n");
exit(EXIT_FAILURE);
}