commit 6c78f4203aac1ee68bdc5d952dd9d1c4ef6a80b1
Author: Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Wed Apr 28 17:47:12 2021 -0600
Commit: Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Wed Apr 28 17:47:12 2021 -0600
Disable writing to log file by default
---
source/logger.cpp | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/source/logger.cpp b/source/logger.cpp
index a75a5b2..f63ac54 100644
--- a/source/logger.cpp
+++ b/source/logger.cpp
@@ -4,19 +4,24 @@
#include "logger.h"
+#define LOGGER_ENABLED false
+
FILE * m_file = nullptr;
bool m_enabled = false;
void Logger_Initialize(const char* pathPrefix)
{
+ #if LOGGER_ENABLED
std::string buf(pathPrefix);
buf.append("pico.log");
m_file = freopen(buf.c_str(), "w", stderr);
m_enabled = true;
+ #endif
}
void Logger_LogOutput(const char * func, size_t line, const char * format, ...)
{
+ #if LOGGER_ENABLED
if (!m_enabled || !m_file)
return;
@@ -28,10 +33,12 @@ void Logger_LogOutput(const char * func, size_t line, const char * format, ...)
fprintf(m_file, "\n\n");
fflush(m_file);
+ #endif
}
void Logger_Write(const char * format, ...)
{
+ #if LOGGER_ENABLED
if (!m_enabled || !m_file)
return;
@@ -41,22 +48,27 @@ void Logger_Write(const char * format, ...)
vfprintf(m_file, format, args);
fflush(m_file);
+ #endif
}
void Logger_WriteUnformatted(const char * message)
{
+ #if LOGGER_ENABLED
if (!m_enabled || !m_file)
return;
fprintf(m_file, "%s", message);
fflush(m_file);
+ #endif
}
void Logger_Exit()
{
+ #if LOGGER_ENABLED
if (!m_enabled || !m_file)
return;
fclose(m_file);
+ #endif
}