mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-10-05 15:49:01 +00:00
# Conflicts: # CMakeLists.txt # CMakeSettings.json # Data/Sys/GameSettings/GLR.ini # Data/Sys/GameSettings/HA9.ini # Data/Sys/GameSettings/MB3.ini # Data/Sys/GameSettings/MBA.ini # Data/Sys/GameSettings/MCV.ini # Data/Sys/GameSettings/MCY.ini # Data/Sys/GameSettings/NAK.ini # Data/Sys/GameSettings/NAL.ini # Data/Sys/GameSettings/NAT.ini # Data/Sys/GameSettings/R8P.ini # Data/Sys/GameSettings/R9I.ini # Data/Sys/GameSettings/REF.ini # Data/Sys/GameSettings/RES.ini # Data/Sys/GameSettings/RMHE08.ini # Data/Sys/GameSettings/RMHP08.ini # Data/Sys/GameSettings/SE2.ini # Data/Sys/GameSettings/WW2.ini # Data/Sys/GameSettings/WW3.ini # Data/Sys/GameSettings/WWI.ini # Externals/Bochs_disasm/Bochs_disasm.vcxproj # Externals/FreeSurround/FreeSurround.vcxproj # Externals/LZO/LZO.vcxproj # Externals/SFML/build/vc2010/SFML_Network.vcxproj # Externals/bzip2/bzip2.vcxproj # Externals/cpp-optparse/cpp-optparse.vcxproj # Externals/cubeb/msvc/cubeb.vcxproj # Externals/curl/curl.vcxproj # Externals/curl/lib/CMakeLists.txt # Externals/discord-rpc/src/discord-rpc.vcxproj # Externals/ed25519/ed25519.vcxproj # Externals/enet/enet.vcxproj # Externals/glslang/glslang.vcxproj # Externals/imgui/imgui.vcxproj # Externals/liblzma/liblzma.vcxproj # Externals/libpng/png/png.vcxproj # Externals/libusb/libusb_static_2013.vcxproj # Externals/mbedtls/mbedTLS.vcxproj # Externals/miniupnpc/miniupnpc.vcxproj # Externals/minizip/minizip.vcxproj # Externals/picojson/picojson.vcxproj # Externals/pugixml/pugixml.vcxproj # Externals/soundtouch/SoundTouch.vcxproj # Externals/xxhash/xxhash.vcxproj # Externals/zlib/zlib.vcxproj # Externals/zstd/zstd.vcxproj # Languages/Languages.vcxproj # Source/Android/jni/MainAndroid.cpp # Source/Core/AudioCommon/AudioCommon.vcxproj # Source/Core/Common/Common.vcxproj # Source/Core/Common/Common.vcxproj.filters # Source/Core/Common/Logging/Log.h # Source/Core/Common/StringUtil.cpp # Source/Core/Core/CMakeLists.txt # Source/Core/Core/ConfigManager.cpp # Source/Core/Core/ConfigManager.h # Source/Core/Core/Core.vcxproj # Source/Core/Core/Core.vcxproj.filters # Source/Core/Core/HotkeyManager.cpp # Source/Core/Core/State.cpp # Source/Core/DiscIO/DiscIO.vcxproj # Source/Core/DolphinNoGUI/DolphinNoGUI.vcxproj # Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp # Source/Core/DolphinQt/DolphinQt.vcxproj # Source/Core/InputCommon/InputCommon.vcxproj # Source/Core/InputCommon/InputCommon.vcxproj.filters # Source/Core/UICommon/UICommon.vcxproj # Source/Core/UpdaterCommon/UpdaterCommon.vcxproj # Source/Core/VideoBackends/D3D/D3D.vcxproj # Source/Core/VideoBackends/D3D12/D3D12.vcxproj # Source/Core/VideoBackends/D3DCommon/D3DCommon.vcxproj # Source/Core/VideoBackends/Null/Null.vcxproj # Source/Core/VideoBackends/OGL/OGL.vcxproj # Source/Core/VideoBackends/Software/Software.vcxproj # Source/Core/VideoBackends/Vulkan/Vulkan.vcxproj # Source/Core/VideoCommon/OnScreenDisplay.cpp # Source/Core/VideoCommon/OnScreenDisplay.h # Source/Core/VideoCommon/VideoCommon.vcxproj # Source/Core/WinUpdater/WinUpdater.vcxproj # Source/DSPTool/DSPTool.vcxproj # Source/PCH/pch.vcxproj # Source/UnitTests/UnitTests.vcxproj
196 lines
8.4 KiB
C++
196 lines
8.4 KiB
C++
// Copyright 2009 Dolphin Emulator Project
|
|
// Licensed under GPLv2+
|
|
// Refer to the license.txt file included.
|
|
|
|
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <fmt/format.h>
|
|
#include <string_view>
|
|
#include "Common/FormatUtil.h"
|
|
|
|
namespace Common::Log
|
|
{
|
|
enum LOG_TYPE
|
|
{
|
|
ACTIONREPLAY,
|
|
AUDIO,
|
|
AUDIO_INTERFACE,
|
|
BOOT,
|
|
COMMANDPROCESSOR,
|
|
COMMON,
|
|
CONSOLE,
|
|
CORE,
|
|
DISCIO,
|
|
DSPHLE,
|
|
DSPLLE,
|
|
DSP_MAIL,
|
|
DSPINTERFACE,
|
|
DVDINTERFACE,
|
|
DYNA_REC,
|
|
EXPANSIONINTERFACE,
|
|
FILEMON,
|
|
FRAMEDUMP,
|
|
GDB_STUB,
|
|
GPFIFO,
|
|
HOST_GPU,
|
|
IOS,
|
|
IOS_DI,
|
|
IOS_ES,
|
|
IOS_FS,
|
|
IOS_NET,
|
|
IOS_SD,
|
|
IOS_SSL,
|
|
IOS_STM,
|
|
IOS_USB,
|
|
IOS_WC24,
|
|
IOS_WFS,
|
|
IOS_WIIMOTE,
|
|
MASTER_LOG,
|
|
MEMMAP,
|
|
MEMCARD_MANAGER,
|
|
NETPLAY,
|
|
OSHLE,
|
|
OSREPORT,
|
|
PAD,
|
|
PIXELENGINE,
|
|
PROCESSORINTERFACE,
|
|
POWERPC,
|
|
SERIALINTERFACE,
|
|
SLIPPI,
|
|
SLIPPI_ONLINE,
|
|
SP1,
|
|
SYMBOLS,
|
|
VIDEO,
|
|
VIDEOINTERFACE,
|
|
WII_IPC,
|
|
WIIMOTE,
|
|
|
|
NUMBER_OF_LOGS // Must be last
|
|
};
|
|
|
|
enum LOG_LEVELS
|
|
{
|
|
LNOTICE = 1, // VERY important information that is NOT errors. Like startup and OSReports.
|
|
LERROR = 2, // Critical errors
|
|
LWARNING = 3, // Something is suspicious.
|
|
LINFO = 4, // General information.
|
|
LDEBUG = 5, // Detailed debugging - might make things slow.
|
|
};
|
|
|
|
static const char LOG_LEVEL_TO_CHAR[7] = "-NEWID";
|
|
|
|
// Short File code taken from https://blog.galowicz.de/2016/02/20/short_file_macro/
|
|
static constexpr const char* past_last_slash(const char* str, const char* last_slash)
|
|
{
|
|
return *str == '\0' ? last_slash
|
|
: *str == '/' || *str == '\\' ? past_last_slash(str + 1, str + 1) : past_last_slash(str + 1, last_slash);
|
|
}
|
|
|
|
static constexpr const char* past_last_slash(const char* str)
|
|
{
|
|
return past_last_slash(str, str);
|
|
}
|
|
|
|
void GenericLogFmtImpl(LOG_LEVELS level, LOG_TYPE type, const char* file, int line,
|
|
fmt::string_view format, const fmt::format_args& args);
|
|
|
|
template <std::size_t NumFields, typename S, typename... Args>
|
|
void GenericLogFmt(LOG_LEVELS level, LOG_TYPE type, const char* file, int line, const S& format,
|
|
const Args&... args)
|
|
{
|
|
static_assert(NumFields == sizeof...(args),
|
|
"Unexpected number of replacement fields in format string; did you pass too few or "
|
|
"too many arguments?");
|
|
GenericLogFmtImpl(level, type, file, line, format,
|
|
fmt::make_args_checked<Args...>(format, args...));
|
|
}
|
|
|
|
void GenericLog(LOG_LEVELS level, LOG_TYPE type, const char* file, int line, const char* fmt, ...)
|
|
#ifdef __GNUC__
|
|
__attribute__((format(printf, 5, 6)))
|
|
#endif
|
|
;
|
|
} // namespace Common::Log
|
|
|
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
|
#define MAX_LOGLEVEL Common::Log::LOG_LEVELS::LDEBUG
|
|
#else
|
|
#ifndef MAX_LOGLEVEL
|
|
#define MAX_LOGLEVEL Common::Log::LOG_LEVELS::LINFO
|
|
#endif // loglevel
|
|
#endif // logging
|
|
|
|
// Let the compiler optimize this out
|
|
#define GENERIC_LOG(t, v, ...) \
|
|
do \
|
|
{ \
|
|
if (v <= MAX_LOGLEVEL) \
|
|
Common::Log::GenericLog(v, t, Common::Log::past_last_slash(__FILE__), __LINE__, __VA_ARGS__); \
|
|
} while (0)
|
|
|
|
#define ERROR_LOG(t, ...) \
|
|
do \
|
|
{ \
|
|
GENERIC_LOG(Common::Log::t, Common::Log::LERROR, __VA_ARGS__); \
|
|
} while (0)
|
|
#define WARN_LOG(t, ...) \
|
|
do \
|
|
{ \
|
|
GENERIC_LOG(Common::Log::t, Common::Log::LWARNING, __VA_ARGS__); \
|
|
} while (0)
|
|
#define NOTICE_LOG(t, ...) \
|
|
do \
|
|
{ \
|
|
GENERIC_LOG(Common::Log::t, Common::Log::LNOTICE, __VA_ARGS__); \
|
|
} while (0)
|
|
#define INFO_LOG(t, ...) \
|
|
do \
|
|
{ \
|
|
GENERIC_LOG(Common::Log::t, Common::Log::LINFO, __VA_ARGS__); \
|
|
} while (0)
|
|
#define DEBUG_LOG(t, ...) \
|
|
do \
|
|
{ \
|
|
GENERIC_LOG(Common::Log::t, Common::Log::LDEBUG, __VA_ARGS__); \
|
|
} while (0)
|
|
|
|
// fmtlib capable API
|
|
|
|
#define GENERIC_LOG_FMT(t, v, format, ...) \
|
|
do \
|
|
{ \
|
|
if (v <= MAX_LOGLEVEL) \
|
|
{ \
|
|
/* Use a macro-like name to avoid shadowing warnings */ \
|
|
constexpr auto GENERIC_LOG_FMT_N = Common::CountFmtReplacementFields(format); \
|
|
Common::Log::GenericLogFmt<GENERIC_LOG_FMT_N>(v, t, __FILE__, __LINE__, FMT_STRING(format), \
|
|
##__VA_ARGS__); \
|
|
} \
|
|
} while (0)
|
|
|
|
#define ERROR_LOG_FMT(t, ...) \
|
|
do \
|
|
{ \
|
|
GENERIC_LOG_FMT(Common::Log::t, Common::Log::LERROR, __VA_ARGS__); \
|
|
} while (0)
|
|
#define WARN_LOG_FMT(t, ...) \
|
|
do \
|
|
{ \
|
|
GENERIC_LOG_FMT(Common::Log::t, Common::Log::LWARNING, __VA_ARGS__); \
|
|
} while (0)
|
|
#define NOTICE_LOG_FMT(t, ...) \
|
|
do \
|
|
{ \
|
|
GENERIC_LOG_FMT(Common::Log::t, Common::Log::LNOTICE, __VA_ARGS__); \
|
|
} while (0)
|
|
#define INFO_LOG_FMT(t, ...) \
|
|
do \
|
|
{ \
|
|
GENERIC_LOG_FMT(Common::Log::t, Common::Log::LINFO, __VA_ARGS__); \
|
|
} while (0)
|
|
#define DEBUG_LOG_FMT(t, ...) \
|
|
do \
|
|
{ \
|
|
GENERIC_LOG_FMT(Common::Log::t, Common::Log::LDEBUG, __VA_ARGS__); \
|
|
} while (0)
|