diff --git a/MG/Constants.h b/MG/Constants.h index 5f58509e..6bea5d45 100644 --- a/MG/Constants.h +++ b/MG/Constants.h @@ -31,11 +31,18 @@ namespace ankerl { namespace MG_Constants { namespace Common { - inline const int LOG_LEVEL_DEBUG = 0x0010; - inline const int LOG_LEVEL_WARN = 0x0011; - inline const int LOG_LEVEL_ERROR = 0x0012; - inline const int LOG_LEVEL_INFO = 0x0013; - inline const int LOG_LEVEL_FATAL = 0x0014; + inline constexpr int LOG_LEVEL_DEBUG = 0x0010; + inline constexpr int LOG_LEVEL_WARN = 0x0011; + inline constexpr int LOG_LEVEL_ERROR = 0x0012; + inline constexpr int LOG_LEVEL_INFO = 0x0013; + inline constexpr int LOG_LEVEL_FATAL = 0x0014; + + + inline constexpr int LOG_TARGET_NONE = 0x00; + inline constexpr int LOG_TARGET_CONSOLE = 0x01; + inline constexpr int LOG_TARGET_FILE = 0x02; + inline constexpr int LOG_TARGET_ANDROID = 0x04; // Android logcat + inline constexpr int LOG_TARGET_ALL = LOG_TARGET_CONSOLE | LOG_TARGET_FILE | LOG_TARGET_ANDROID; } namespace Blend { @@ -175,8 +182,8 @@ namespace MG_Constants { namespace Backend { #define BACKEND_VULKAN 0x0015 -#define BACKEND_METAL 0x0016 -#define BACKEND_GLES 0x0017 +#define BACKEND_METAL 0x0016 +#define BACKEND_GLES 0x0017 } inline const char* RenderName = "MobileGL"; diff --git a/MG/Global.h b/MG/Global.h index 630410bd..ceaeeae4 100644 --- a/MG/Global.h +++ b/MG/Global.h @@ -9,10 +9,10 @@ namespace MG_Global { namespace MG { - inline const int VersionMajor = 1; - inline const int VersionMinor = 0; - inline const int VersionRevision = 0; - inline const int VersionPatch = 0; + inline const int VersionMajor = 1; + inline const int VersionMinor = 0; + inline const int VersionRevision = 0; + inline const int VersionPatch = 0; inline const std::string VersionSuffix = "-Dev"; } @@ -21,13 +21,14 @@ namespace MG_Global { } namespace GL { - inline const int GLVersionMajor = 3; - inline const int GLVersionMinor = 2; + inline const int GLVersionMajor = 3; + inline const int GLVersionMinor = 2; inline const int GLVersionRevision = 0; } namespace Common { - inline constexpr int LogLevel = MG_Constants::Common::LOG_LEVEL_INFO; + inline constexpr int LogLevel = MG_Constants::Common::LOG_LEVEL_INFO; + inline constexpr int LogTarget = MG_Constants::Common::LOG_TARGET_ALL; #ifdef __ANDROID__ inline const char* LOG_FILE_PATH = "/sdcard/MG/latest.log"; diff --git a/MG/MG_UTIL/Debug/Debug.cpp b/MG/MG_UTIL/Debug/Debug.cpp index 5add9b7e..dc08d0a6 100644 --- a/MG/MG_UTIL/Debug/Debug.cpp +++ b/MG/MG_UTIL/Debug/Debug.cpp @@ -71,14 +71,22 @@ namespace MG_Util::Debug { std::string full_format = header + format + "\n"; #ifdef __ANDROID__ - __android_log_vprint(androidLevel, MG_Constants::RenderName, full_format.c_str(), args); + if (MG_Global::Common::LogTarget & MG_Constants::Common::LOG_TARGET_ANDROID) { + __android_log_vprint(androidLevel, MG_Constants::RenderName, full_format.c_str(), args); + } #endif - vprintf(full_format.c_str(), args); - va_list args_copy; - va_copy(args_copy, args); - LogWrite(full_format.c_str(), args_copy); - va_end(args_copy); + if (MG_Global::Common::LogTarget & MG_Constants::Common::LOG_TARGET_CONSOLE) { + vprintf(full_format.c_str(), args); + } + + if ((MG_Global::Common::LogTarget & MG_Constants::Common::LOG_TARGET_FILE) && + MG_Global::Common::LOG_FILE_PATH != nullptr) { + va_list args_copy; + va_copy(args_copy, args); + LogWrite(full_format.c_str(), args_copy); + va_end(args_copy); + } } #define DECLARE_LOG_FUNCTION(name, level) \