aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-07-01 06:07:11 -0700
committerChris Robinson <[email protected]>2023-07-01 06:07:11 -0700
commit548f7ad80abc253a38171b7e4eb1c84a6b179a41 (patch)
treec21cf749ac11cb4a9bd90861f426716a3ed100da
parent0cad3f7391959d1ad83f948df37db608e3f0e72c (diff)
Don't pass the file handle to al_print
-rw-r--r--alc/alc.cpp7
-rw-r--r--core/logging.cpp12
-rw-r--r--core/logging.h18
3 files changed, 20 insertions, 17 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp
index e6c2f137..0e1dc637 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -162,13 +162,6 @@
#endif // ALSOFT_EAX
-FILE *gLogFile{stderr};
-#ifdef _DEBUG
-LogLevel gLogLevel{LogLevel::Warning};
-#else
-LogLevel gLogLevel{LogLevel::Error};
-#endif
-
/************************************************
* Library initialization
************************************************/
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 */