From 1debcc8032f01dd2bb64f2725143121b57320876 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Fri, 4 Jul 2025 12:13:01 +0200 Subject: Added logging priorities and use SDLs logging facilities By using SDL logging, we can rely on SDL to filter the log messages by their priority before they get sent to our custom output function. For example, we now no longer get entries for created and destroyed Window instances by default, since these have only "debug" priority whereas the default priority for the "app" category is "info". We can also get log messages raised by SDL itself in our log now. Log levels can be controlled per category through the "SDL_LOGGING" environment variable. Many existing log messages have been assigned a category based on their existing prefix. --- src/utils/xml.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/utils/xml.cpp') diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp index c408c9c2..34bcc52b 100644 --- a/src/utils/xml.cpp +++ b/src/utils/xml.cpp @@ -43,13 +43,13 @@ namespace XML auto *context = static_cast(ctx); if (context) - logger->log("Error in XML file '%s' on line %d", - context->file.c_str(), error->line); + Log::info("Error in XML file '%s' on line %d", + context->file.c_str(), error->line); else - logger->log("Error in unknown XML file on line %d", - error->line); + Log::info("Error in unknown XML file on line %d", + error->line); - logger->log("%s", error->message); + Log::info("%s", error->message); // No need to keep errors around xmlCtxtResetLastError(error->ctxt); @@ -76,11 +76,11 @@ namespace XML SDL_free(data); if (!mDoc) - logger->log("Error parsing XML file %s", filename.c_str()); + Log::info("Error parsing XML file %s", filename.c_str()); } else { - logger->log("Error loading %s: %s", filename.c_str(), SDL_GetError()); + Log::info("Error loading %s: %s", filename.c_str(), SDL_GetError()); } xmlSetStructuredErrorFunc(nullptr, xmlLogger); @@ -109,7 +109,7 @@ namespace XML mWriter = xmlNewTextWriterFilename(fileName.c_str(), 0); if (!mWriter) { - logger->log("Error creating XML writer for file %s", fileName.c_str()); + Log::info("Error creating XML writer for file %s", fileName.c_str()); return; } -- cgit v1.2.3-70-g09d2