Move logging to core
This commit is contained in:
+2
-1
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -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"
|
||||
|
||||
|
||||
+1
-1
@@ -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"
|
||||
|
||||
|
||||
+1
-1
@@ -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"
|
||||
|
||||
+1
-1
@@ -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"
|
||||
|
||||
+1
-1
@@ -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"
|
||||
|
||||
+1
-1
@@ -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"
|
||||
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "alfstream.h"
|
||||
#include "logging.h"
|
||||
#include "core/logging.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "alnumeric.h"
|
||||
#include "aloptional.h"
|
||||
#include "atomic.h"
|
||||
#include "logging.h"
|
||||
#include "core/logging.h"
|
||||
|
||||
|
||||
bool BackendBase::reset()
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include "alexcpt.h"
|
||||
#include "almalloc.h"
|
||||
#include "alu.h"
|
||||
#include "logging.h"
|
||||
#include "threads.h"
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#include "alu.h"
|
||||
#include "logging.h"
|
||||
#include "core/logging.h"
|
||||
|
||||
#include "oboe/Oboe.h"
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "alexcpt.h"
|
||||
#include "almalloc.h"
|
||||
#include "alu.h"
|
||||
#include "logging.h"
|
||||
#include "core/logging.h"
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
|
||||
+1
-78
@@ -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)
|
||||
|
||||
+1
-1
@@ -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"
|
||||
|
||||
+1
-1
@@ -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"
|
||||
|
||||
|
||||
+1
-1
@@ -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"
|
||||
|
||||
@@ -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
|
||||
@@ -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 */
|
||||
Reference in New Issue
Block a user