aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/logging.cpp12
-rw-r--r--core/logging.h18
2 files changed, 20 insertions, 10 deletions
diff --git a/core/logging.cpp b/core/logging.cpp
index 34385cf4..b6248514 100644
--- a/core/logging.cpp
+++ b/core/logging.cpp
@@ -19,7 +19,16 @@
#include <android/log.h>
#endif
-void al_print(LogLevel level, FILE *logfile, const char *fmt, ...)
+
+FILE *gLogFile{stderr};
+#ifdef _DEBUG
+LogLevel gLogLevel{LogLevel::Warning};
+#else
+LogLevel gLogLevel{LogLevel::Error};
+#endif
+
+
+void al_print(LogLevel level, const char *fmt, ...)
{
/* Kind of ugly since string literals are const char arrays with a size
* that includes the null terminator, which we want to exclude from the
@@ -60,6 +69,7 @@ void al_print(LogLevel level, FILE *logfile, const char *fmt, ...)
if(gLogLevel >= level)
{
+ auto logfile = gLogFile;
fputs(str, logfile);
fflush(logfile);
}
diff --git a/core/logging.h b/core/logging.h
index f4b6ab56..c99c4e45 100644
--- a/core/logging.h
+++ b/core/logging.h
@@ -17,35 +17,35 @@ extern LogLevel gLogLevel;
extern FILE *gLogFile;
#ifdef __USE_MINGW_ANSI_STDIO
-[[gnu::format(gnu_printf,3,4)]]
+[[gnu::format(gnu_printf,2,3)]]
#else
-[[gnu::format(printf,3,4)]]
+[[gnu::format(printf,2,3)]]
#endif
-void al_print(LogLevel level, FILE *logfile, const char *fmt, ...);
+void al_print(LogLevel level, const char *fmt, ...);
#if (!defined(_WIN32) || defined(NDEBUG)) && !defined(__ANDROID__)
#define TRACE(...) do { \
if(gLogLevel >= LogLevel::Trace) UNLIKELY \
- al_print(LogLevel::Trace, gLogFile, __VA_ARGS__); \
+ al_print(LogLevel::Trace, __VA_ARGS__); \
} while(0)
#define WARN(...) do { \
if(gLogLevel >= LogLevel::Warning) UNLIKELY \
- al_print(LogLevel::Warning, gLogFile, __VA_ARGS__); \
+ al_print(LogLevel::Warning, __VA_ARGS__); \
} while(0)
#define ERR(...) do { \
if(gLogLevel >= LogLevel::Error) UNLIKELY \
- al_print(LogLevel::Error, gLogFile, __VA_ARGS__); \
+ al_print(LogLevel::Error, __VA_ARGS__); \
} while(0)
#else
-#define TRACE(...) al_print(LogLevel::Trace, gLogFile, __VA_ARGS__)
+#define TRACE(...) al_print(LogLevel::Trace, __VA_ARGS__)
-#define WARN(...) al_print(LogLevel::Warning, gLogFile, __VA_ARGS__)
+#define WARN(...) al_print(LogLevel::Warning, __VA_ARGS__)
-#define ERR(...) al_print(LogLevel::Error, gLogFile, __VA_ARGS__)
+#define ERR(...) al_print(LogLevel::Error, __VA_ARGS__)
#endif
#endif /* CORE_LOGGING_H */