aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-12-17 01:25:33 -0800
committerChris Robinson <[email protected]>2020-12-17 02:47:03 -0800
commitd578bc6cb1b9bce4954ded9b138d51980163c233 (patch)
treee38c0c3869f80e39693f19ff7c184708ac4e7770
parentf0fe57dc5a1b518397688b868592287f49d1afef (diff)
Move logging to core
-rw-r--r--CMakeLists.txt3
-rw-r--r--al/auxeffectslot.cpp2
-rw-r--r--al/effect.cpp2
-rw-r--r--al/error.cpp2
-rw-r--r--al/event.cpp2
-rw-r--r--al/source.cpp2
-rw-r--r--alc/alc.cpp2
-rw-r--r--alc/alconfig.cpp2
-rw-r--r--alc/ambdec.cpp2
-rw-r--r--alc/backends/alsa.cpp2
-rw-r--r--alc/backends/base.cpp2
-rw-r--r--alc/backends/coreaudio.cpp2
-rw-r--r--alc/backends/dsound.cpp2
-rw-r--r--alc/backends/jack.cpp2
-rw-r--r--alc/backends/null.cpp1
-rw-r--r--alc/backends/oboe.cpp2
-rw-r--r--alc/backends/opensl.cpp2
-rw-r--r--alc/backends/oss.cpp2
-rw-r--r--alc/backends/portaudio.cpp2
-rw-r--r--alc/backends/pulseaudio.cpp2
-rw-r--r--alc/backends/sdl2.cpp2
-rw-r--r--alc/backends/sndio.cpp4
-rw-r--r--alc/backends/solaris.cpp2
-rw-r--r--alc/backends/wasapi.cpp2
-rw-r--r--alc/backends/wave.cpp2
-rw-r--r--alc/backends/winmm.cpp2
-rw-r--r--alc/effects/convolution.cpp2
-rw-r--r--alc/helpers.cpp79
-rw-r--r--alc/hrtf.cpp2
-rw-r--r--alc/panning.cpp2
-rw-r--r--alc/voice.cpp2
-rw-r--r--core/logging.cpp95
-rw-r--r--core/logging.h (renamed from alc/logging.h)6
33 files changed, 130 insertions, 112 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dace780b..fa9e7d37 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -604,6 +604,8 @@ set(CORE_OBJS
core/filters/splitter.h
core/fmt_traits.cpp
core/fmt_traits.h
+ core/logging.cpp
+ core/logging.h
core/mastering.cpp
core/mastering.h
core/uhjfilter.cpp
@@ -693,7 +695,6 @@ set(ALC_OBJS
alc/hrtf.cpp
alc/hrtf.h
alc/inprogext.h
- alc/logging.h
alc/panning.cpp
alc/uiddefs.cpp
alc/voice.cpp
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp
index 46f68374..a69df77a 100644
--- a/al/auxeffectslot.cpp
+++ b/al/auxeffectslot.cpp
@@ -42,10 +42,10 @@
#include "alspan.h"
#include "alu.h"
#include "buffer.h"
+#include "core/logging.h"
#include "effect.h"
#include "fpu_ctrl.h"
#include "inprogext.h"
-#include "logging.h"
#include "opthelpers.h"
diff --git a/al/effect.cpp b/al/effect.cpp
index b45ba00a..3cfccaa3 100644
--- a/al/effect.cpp
+++ b/al/effect.cpp
@@ -44,8 +44,8 @@
#include "almalloc.h"
#include "alnumeric.h"
#include "alstring.h"
+#include "core/logging.h"
#include "effects/base.h"
-#include "logging.h"
#include "opthelpers.h"
#include "vector.h"
diff --git a/al/error.cpp b/al/error.cpp
index 79bbc56c..f9c408d2 100644
--- a/al/error.cpp
+++ b/al/error.cpp
@@ -38,7 +38,7 @@
#include "alcontext.h"
#include "alexcpt.h"
#include "almalloc.h"
-#include "logging.h"
+#include "core/logging.h"
#include "opthelpers.h"
#include "vector.h"
diff --git a/al/event.cpp b/al/event.cpp
index ada92e24..6834253a 100644
--- a/al/event.cpp
+++ b/al/event.cpp
@@ -22,9 +22,9 @@
#include "alexcpt.h"
#include "almalloc.h"
#include "async_event.h"
+#include "core/logging.h"
#include "effects/base.h"
#include "inprogext.h"
-#include "logging.h"
#include "opthelpers.h"
#include "ringbuffer.h"
#include "threads.h"
diff --git a/al/source.cpp b/al/source.cpp
index 2cb74589..5fae7b54 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -61,10 +61,10 @@
#include "core/ambidefs.h"
#include "core/filters/nfc.h"
#include "core/filters/splitter.h"
+#include "core/logging.h"
#include "event.h"
#include "filter.h"
#include "inprogext.h"
-#include "logging.h"
#include "math_defs.h"
#include "opthelpers.h"
#include "ringbuffer.h"
diff --git a/alc/alc.cpp b/alc/alc.cpp
index 2720033e..6fd61b44 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -85,6 +85,7 @@
#include "core/mastering.h"
#include "core/filters/nfc.h"
#include "core/filters/splitter.h"
+#include "core/logging.h"
#include "core/uhjfilter.h"
#include "cpu_caps.h"
#include "effects/base.h"
@@ -93,7 +94,6 @@
#include "hrtf.h"
#include "inprogext.h"
#include "intrusive_ptr.h"
-#include "logging.h"
#include "opthelpers.h"
#include "pragmadefs.h"
#include "ringbuffer.h"
diff --git a/alc/alconfig.cpp b/alc/alconfig.cpp
index ac075b54..634679aa 100644
--- a/alc/alconfig.cpp
+++ b/alc/alconfig.cpp
@@ -41,7 +41,7 @@
#include "alfstream.h"
#include "alstring.h"
#include "compat.h"
-#include "logging.h"
+#include "core/logging.h"
#include "strutils.h"
#include "vector.h"
diff --git a/alc/ambdec.cpp b/alc/ambdec.cpp
index eaeb9086..a50d6d95 100644
--- a/alc/ambdec.cpp
+++ b/alc/ambdec.cpp
@@ -11,7 +11,7 @@
#include <string>
#include "alfstream.h"
-#include "logging.h"
+#include "core/logging.h"
namespace {
diff --git a/alc/backends/alsa.cpp b/alc/backends/alsa.cpp
index a07d006b..0166e28c 100644
--- a/alc/backends/alsa.cpp
+++ b/alc/backends/alsa.cpp
@@ -45,8 +45,8 @@
#include "alnumeric.h"
#include "aloptional.h"
#include "alu.h"
+#include "core/logging.h"
#include "dynload.h"
-#include "logging.h"
#include "ringbuffer.h"
#include "threads.h"
#include "vector.h"
diff --git a/alc/backends/base.cpp b/alc/backends/base.cpp
index 04fc4d64..9d8d0c64 100644
--- a/alc/backends/base.cpp
+++ b/alc/backends/base.cpp
@@ -19,7 +19,7 @@
#include "alnumeric.h"
#include "aloptional.h"
#include "atomic.h"
-#include "logging.h"
+#include "core/logging.h"
bool BackendBase::reset()
diff --git a/alc/backends/coreaudio.cpp b/alc/backends/coreaudio.cpp
index 32f8d123..80259667 100644
--- a/alc/backends/coreaudio.cpp
+++ b/alc/backends/coreaudio.cpp
@@ -34,7 +34,7 @@
#include "alu.h"
#include "ringbuffer.h"
#include "converter.h"
-#include "logging.h"
+#include "core/logging.h"
#include "backends/base.h"
#include <unistd.h>
diff --git a/alc/backends/dsound.cpp b/alc/backends/dsound.cpp
index 9ff5505b..061e9a18 100644
--- a/alc/backends/dsound.cpp
+++ b/alc/backends/dsound.cpp
@@ -48,8 +48,8 @@
#include "alexcpt.h"
#include "alu.h"
#include "compat.h"
+#include "core/logging.h"
#include "dynload.h"
-#include "logging.h"
#include "ringbuffer.h"
#include "strutils.h"
#include "threads.h"
diff --git a/alc/backends/jack.cpp b/alc/backends/jack.cpp
index bc3a2d09..871562ff 100644
--- a/alc/backends/jack.cpp
+++ b/alc/backends/jack.cpp
@@ -35,8 +35,8 @@
#include "alu.h"
#include "alconfig.h"
#include "alexcpt.h"
+#include "core/logging.h"
#include "dynload.h"
-#include "logging.h"
#include "ringbuffer.h"
#include "threads.h"
diff --git a/alc/backends/null.cpp b/alc/backends/null.cpp
index f78a23a0..8a134a93 100644
--- a/alc/backends/null.cpp
+++ b/alc/backends/null.cpp
@@ -34,7 +34,6 @@
#include "alexcpt.h"
#include "almalloc.h"
#include "alu.h"
-#include "logging.h"
#include "threads.h"
diff --git a/alc/backends/oboe.cpp b/alc/backends/oboe.cpp
index f4a9877a..1c1b22cd 100644
--- a/alc/backends/oboe.cpp
+++ b/alc/backends/oboe.cpp
@@ -7,7 +7,7 @@
#include <cstring>
#include "alu.h"
-#include "logging.h"
+#include "core/logging.h"
#include "oboe/Oboe.h"
diff --git a/alc/backends/opensl.cpp b/alc/backends/opensl.cpp
index 74309a94..185c9999 100644
--- a/alc/backends/opensl.cpp
+++ b/alc/backends/opensl.cpp
@@ -36,8 +36,8 @@
#include "alexcpt.h"
#include "alu.h"
#include "compat.h"
+#include "core/logging.h"
#include "endiantest.h"
-#include "logging.h"
#include "ringbuffer.h"
#include "threads.h"
diff --git a/alc/backends/oss.cpp b/alc/backends/oss.cpp
index 0f00115e..513f481a 100644
--- a/alc/backends/oss.cpp
+++ b/alc/backends/oss.cpp
@@ -50,7 +50,7 @@
#include "alnumeric.h"
#include "aloptional.h"
#include "alu.h"
-#include "logging.h"
+#include "core/logging.h"
#include "ringbuffer.h"
#include "threads.h"
#include "vector.h"
diff --git a/alc/backends/portaudio.cpp b/alc/backends/portaudio.cpp
index 42dbb4c9..54fac803 100644
--- a/alc/backends/portaudio.cpp
+++ b/alc/backends/portaudio.cpp
@@ -30,9 +30,9 @@
#include "alexcpt.h"
#include "alu.h"
#include "alconfig.h"
+#include "core/logging.h"
#include "dynload.h"
#include "ringbuffer.h"
-#include "logging.h"
#include <portaudio.h>
diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp
index 5bcd8b5f..73312722 100644
--- a/alc/backends/pulseaudio.cpp
+++ b/alc/backends/pulseaudio.cpp
@@ -40,8 +40,8 @@
#include "alconfig.h"
#include "alexcpt.h"
#include "compat.h"
+#include "core/logging.h"
#include "dynload.h"
-#include "logging.h"
#include "strutils.h"
#include <pulse/pulseaudio.h>
diff --git a/alc/backends/sdl2.cpp b/alc/backends/sdl2.cpp
index 30335140..05e8e4e0 100644
--- a/alc/backends/sdl2.cpp
+++ b/alc/backends/sdl2.cpp
@@ -33,7 +33,7 @@
#include "alexcpt.h"
#include "almalloc.h"
#include "alu.h"
-#include "logging.h"
+#include "core/logging.h"
#include <SDL2/SDL.h>
diff --git a/alc/backends/sndio.cpp b/alc/backends/sndio.cpp
index c20ce496..4e9af3bc 100644
--- a/alc/backends/sndio.cpp
+++ b/alc/backends/sndio.cpp
@@ -32,10 +32,10 @@
#include "alcmain.h"
#include "alexcpt.h"
#include "alu.h"
+#include "core/logging.h"
+#include "ringbuffer.h"
#include "threads.h"
#include "vector.h"
-#include "ringbuffer.h"
-#include "logging.h"
#include <sndio.h>
diff --git a/alc/backends/solaris.cpp b/alc/backends/solaris.cpp
index 6849a820..5134c101 100644
--- a/alc/backends/solaris.cpp
+++ b/alc/backends/solaris.cpp
@@ -43,7 +43,7 @@
#include "alu.h"
#include "alconfig.h"
#include "compat.h"
-#include "logging.h"
+#include "core/logging.h"
#include "threads.h"
#include "vector.h"
diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp
index ba0d52d5..154355f2 100644
--- a/alc/backends/wasapi.cpp
+++ b/alc/backends/wasapi.cpp
@@ -60,7 +60,7 @@
#include "alu.h"
#include "compat.h"
#include "converter.h"
-#include "logging.h"
+#include "core/logging.h"
#include "ringbuffer.h"
#include "strutils.h"
#include "threads.h"
diff --git a/alc/backends/wave.cpp b/alc/backends/wave.cpp
index 473d0314..a9713718 100644
--- a/alc/backends/wave.cpp
+++ b/alc/backends/wave.cpp
@@ -43,8 +43,8 @@
#include "alnumeric.h"
#include "alu.h"
#include "compat.h"
+#include "core/logging.h"
#include "endiantest.h"
-#include "logging.h"
#include "strutils.h"
#include "threads.h"
#include "vector.h"
diff --git a/alc/backends/winmm.cpp b/alc/backends/winmm.cpp
index 274536b3..d4e7c786 100644
--- a/alc/backends/winmm.cpp
+++ b/alc/backends/winmm.cpp
@@ -42,7 +42,7 @@
#include "alexcpt.h"
#include "alu.h"
#include "compat.h"
-#include "logging.h"
+#include "core/logging.h"
#include "ringbuffer.h"
#include "strutils.h"
#include "threads.h"
diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp
index 677c59ba..667d5fb3 100644
--- a/alc/effects/convolution.cpp
+++ b/alc/effects/convolution.cpp
@@ -18,9 +18,9 @@
#include "core/ambidefs.h"
#include "core/filters/splitter.h"
#include "core/fmt_traits.h"
+#include "core/logging.h"
#include "effects/base.h"
#include "effectslot.h"
-#include "logging.h"
#include "polyphase_resampler.h"
diff --git a/alc/helpers.cpp b/alc/helpers.cpp
index 1003ccfa..8c1c8562 100644
--- a/alc/helpers.cpp
+++ b/alc/helpers.cpp
@@ -35,7 +35,7 @@
#include "alspan.h"
#include "alstring.h"
#include "compat.h"
-#include "logging.h"
+#include "core/logging.h"
#include "strutils.h"
#include "vector.h"
@@ -79,36 +79,6 @@ const PathNamePair &GetProcBinary()
return ret;
}
-
-void al_print(LogLevel level, FILE *logfile, const char *fmt, ...)
-{
- al::vector<char> dynmsg;
- char stcmsg[256];
- char *str{stcmsg};
-
- va_list args, args2;
- va_start(args, fmt);
- va_copy(args2, args);
- int msglen{std::vsnprintf(str, sizeof(stcmsg), fmt, args)};
- if UNLIKELY(msglen >= 0 && static_cast<size_t>(msglen) >= sizeof(stcmsg))
- {
- dynmsg.resize(static_cast<size_t>(msglen) + 1u);
- str = dynmsg.data();
- msglen = std::vsnprintf(str, dynmsg.size(), fmt, args2);
- }
- va_end(args2);
- va_end(args);
-
- std::wstring wstr{utf8_to_wstr(str)};
- if(gLogLevel >= level)
- {
- fputws(wstr.c_str(), logfile);
- fflush(logfile);
- }
- OutputDebugStringW(wstr.c_str());
-}
-
-
namespace {
void DirectorySearch(const char *path, const char *ext, al::vector<std::string> *const results)
@@ -225,9 +195,6 @@ void SetRTPriority(void)
#ifdef __HAIKU__
#include <FindDirectory.h>
#endif
-#ifdef __ANDROID__
-#include <android/log.h>
-#endif
#ifdef HAVE_PROC_PIDPATH
#include <libproc.h>
#endif
@@ -323,50 +290,6 @@ const PathNamePair &GetProcBinary()
return ret;
}
-
-void al_print(LogLevel level, FILE *logfile, const char *fmt, ...)
-{
- al::vector<char> dynmsg;
- char stcmsg[256];
- char *str{stcmsg};
-
- va_list args, args2;
- va_start(args, fmt);
- va_copy(args2, args);
- int msglen{std::vsnprintf(str, sizeof(stcmsg), fmt, args)};
- if UNLIKELY(msglen >= 0 && static_cast<size_t>(msglen) >= sizeof(stcmsg))
- {
- dynmsg.resize(static_cast<size_t>(msglen) + 1u);
- str = dynmsg.data();
- msglen = std::vsnprintf(str, dynmsg.size(), fmt, args2);
- }
- va_end(args2);
- va_end(args);
-
- if(gLogLevel >= level)
- {
- fputs(str, logfile);
- fflush(logfile);
- }
-#ifdef __ANDROID__
- auto android_severity = [](LogLevel l) noexcept
- {
- switch(l)
- {
- case LogLevel::Trace: return ANDROID_LOG_DEBUG;
- case LogLevel::Warning: return ANDROID_LOG_WARN;
- case LogLevel::Error: return ANDROID_LOG_ERROR;
- /* Should not happen. */
- case LogLevel::Disable:
- break;
- }
- return ANDROID_LOG_ERROR;
- };
- __android_log_print(android_severity(level), "openal", "%s", str);
-#endif
-}
-
-
namespace {
void DirectorySearch(const char *path, const char *ext, al::vector<std::string> *const results)
diff --git a/alc/hrtf.cpp b/alc/hrtf.cpp
index e01cdf97..b13b50cb 100644
--- a/alc/hrtf.cpp
+++ b/alc/hrtf.cpp
@@ -48,7 +48,7 @@
#include "aloptional.h"
#include "alspan.h"
#include "core/filters/splitter.h"
-#include "logging.h"
+#include "core/logging.h"
#include "math_defs.h"
#include "opthelpers.h"
#include "polyphase_resampler.h"
diff --git a/alc/panning.cpp b/alc/panning.cpp
index ad297ef7..cb77199f 100644
--- a/alc/panning.cpp
+++ b/alc/panning.cpp
@@ -52,10 +52,10 @@
#include "core/ambidefs.h"
#include "core/bs2b.h"
#include "core/devformat.h"
+#include "core/logging.h"
#include "core/uhjfilter.h"
#include "front_stablizer.h"
#include "hrtf.h"
-#include "logging.h"
#include "math_defs.h"
#include "opthelpers.h"
diff --git a/alc/voice.cpp b/alc/voice.cpp
index 15240544..2639bcf8 100644
--- a/alc/voice.cpp
+++ b/alc/voice.cpp
@@ -50,12 +50,12 @@
#include "core/filters/nfc.h"
#include "core/filters/splitter.h"
#include "core/fmt_traits.h"
+#include "core/logging.h"
#include "core/mixer/defs.h"
#include "core/mixer/hrtfdefs.h"
#include "cpu_caps.h"
#include "hrtf.h"
#include "inprogext.h"
-#include "logging.h"
#include "opthelpers.h"
#include "ringbuffer.h"
#include "threads.h"
diff --git a/core/logging.cpp b/core/logging.cpp
new file mode 100644
index 00000000..dd7f53c7
--- /dev/null
+++ b/core/logging.cpp
@@ -0,0 +1,95 @@
+
+#include "config.h"
+
+#include "logging.h"
+
+#include <cstdarg>
+#include <cstdio>
+#include <string>
+
+#include "strutils.h"
+#include "vector.h"
+
+
+#ifdef _WIN32
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+void al_print(LogLevel level, FILE *logfile, const char *fmt, ...)
+{
+ al::vector<char> dynmsg;
+ char stcmsg[256];
+ char *str{stcmsg};
+
+ std::va_list args, args2;
+ va_start(args, fmt);
+ va_copy(args2, args);
+ int msglen{std::vsnprintf(str, sizeof(stcmsg), fmt, args)};
+ if UNLIKELY(msglen >= 0 && static_cast<size_t>(msglen) >= sizeof(stcmsg))
+ {
+ dynmsg.resize(static_cast<size_t>(msglen) + 1u);
+ str = dynmsg.data();
+ msglen = std::vsnprintf(str, dynmsg.size(), fmt, args2);
+ }
+ va_end(args2);
+ va_end(args);
+
+ std::wstring wstr{utf8_to_wstr(str)};
+ if(gLogLevel >= level)
+ {
+ fputws(wstr.c_str(), logfile);
+ fflush(logfile);
+ }
+ OutputDebugStringW(wstr.c_str());
+}
+
+#else
+
+#ifdef __ANDROID__
+#include <android/log.h>
+#endif
+
+void al_print(LogLevel level, FILE *logfile, const char *fmt, ...)
+{
+ al::vector<char> dynmsg;
+ char stcmsg[256];
+ char *str{stcmsg};
+
+ std::va_list args, args2;
+ va_start(args, fmt);
+ va_copy(args2, args);
+ int msglen{std::vsnprintf(str, sizeof(stcmsg), fmt, args)};
+ if UNLIKELY(msglen >= 0 && static_cast<size_t>(msglen) >= sizeof(stcmsg))
+ {
+ dynmsg.resize(static_cast<size_t>(msglen) + 1u);
+ str = dynmsg.data();
+ msglen = std::vsnprintf(str, dynmsg.size(), fmt, args2);
+ }
+ va_end(args2);
+ va_end(args);
+
+ if(gLogLevel >= level)
+ {
+ std::fputs(str, logfile);
+ std::fflush(logfile);
+ }
+#ifdef __ANDROID__
+ auto android_severity = [](LogLevel l) noexcept
+ {
+ switch(l)
+ {
+ case LogLevel::Trace: return ANDROID_LOG_DEBUG;
+ case LogLevel::Warning: return ANDROID_LOG_WARN;
+ case LogLevel::Error: return ANDROID_LOG_ERROR;
+ /* Should not happen. */
+ case LogLevel::Disable:
+ break;
+ }
+ return ANDROID_LOG_ERROR;
+ };
+ __android_log_print(android_severity(level), "openal", "%s", str);
+#endif
+}
+
+#endif
diff --git a/alc/logging.h b/core/logging.h
index 32a877e1..b931c27e 100644
--- a/alc/logging.h
+++ b/core/logging.h
@@ -1,5 +1,5 @@
-#ifndef LOGGING_H
-#define LOGGING_H
+#ifndef CORE_LOGGING_H
+#define CORE_LOGGING_H
#include <stdio.h>
@@ -44,4 +44,4 @@ extern FILE *gLogFile;
#define ERR(...) al_print(LogLevel::Error, gLogFile, "[ALSOFT] (EE) " __VA_ARGS__)
#endif
-#endif /* LOGGING_H */
+#endif /* CORE_LOGGING_H */