From 32ba683bfb257fb016c981ce0aac13296a8367e0 Mon Sep 17 00:00:00 2001 From: Joel16 Date: Fri, 22 Nov 2024 11:30:38 +0000 Subject: [PATCH] logs: Don't create logs on non debug builds --- source/gui.cpp | 5 ++++- source/log.cpp | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/source/gui.cpp b/source/gui.cpp index 3c61cfe..50821f1 100755 --- a/source/gui.cpp +++ b/source/gui.cpp @@ -61,8 +61,9 @@ namespace GUI { guiSizeBuf = C2D_TextBufNew(4096); Textures::Init(); +#if defined BUILD_DEBUG Log::Open(); - +#endif // Real time services #if !defined BUILD_CITRA mcuHwcInit(); @@ -81,7 +82,9 @@ namespace GUI { #if !defined BUILD_CITRA mcuHwcExit(); #endif +#if defined BUILD_DEBUG Log::Close(); +#endif Textures::Exit(); C2D_TextBufDelete(guiSizeBuf); C2D_TextBufDelete(guiDynamicBuf); diff --git a/source/log.cpp b/source/log.cpp index cbfcdc7..450b5e5 100644 --- a/source/log.cpp +++ b/source/log.cpp @@ -6,7 +6,7 @@ namespace Log { static FS_Archive sdmcArchive; - static Handle handle; + static Handle handle = 0; static u64 offset = 0; Result Open(void) { @@ -44,7 +44,12 @@ namespace Log { return 0; } - void Error(const char *data, ...) { + void Error(const char *data, ...) { + // File handle was not open for writing + if (!handle) { + return; + } + char buf[256]; va_list args; va_start(args, data);