mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-04-04 14:08:30 +00:00
use only one set of logging macros instead of two and don't use free() as a function name
This commit is contained in:
parent
afad6daa7d
commit
95f1a0e645
74 changed files with 800 additions and 793 deletions
|
|
@ -11,21 +11,12 @@
|
|||
|
||||
//#define BUFFERED_LOGGING 1
|
||||
|
||||
//another msvc bug makes these not work, uncomment these and replace it with the one at the bottom when it's fixed
|
||||
//#define LOG_MESSAGE(logType, severity, text) Log::LogManager::getInstance().log({logType, severity, text})
|
||||
|
||||
//first parameter is of type Log::LogType and text is of type std::string
|
||||
#define LOG_MESSAGE(logType, severity, text) do{Log::LogMessage msg{logType, severity, text}; Log::LogManager::getInstance().log(msg);}while(0)
|
||||
|
||||
#define LOG_SUCCESS(logType, text) LOG_MESSAGE(logType, Log::Success, text)
|
||||
#define LOG_NOTICE(logType, text) LOG_MESSAGE(logType, Log::Notice, text)
|
||||
#define LOG_WARNING(logType, text) LOG_MESSAGE(logType, Log::Warning, text)
|
||||
#define LOG_ERROR(logType, text) LOG_MESSAGE(logType, Log::Error, text)
|
||||
|
||||
#define LOGF_SUCCESS(logType, fmtstring, ...) LOG_SUCCESS(logType, fmt::Format(fmtstring, ##__VA_ARGS__ ))
|
||||
#define LOGF_NOTICE(logType, fmtstring, ...) LOG_NOTICE(logType, fmt::Format(fmtstring, ##__VA_ARGS__ ))
|
||||
#define LOGF_WARNING(logType, fmtstring, ...) LOG_WARNING(logType, fmt::Format(fmtstring, ##__VA_ARGS__ ))
|
||||
#define LOGF_ERROR(logType, fmtstring, ...) LOG_ERROR(logType, fmt::Format(fmtstring, ##__VA_ARGS__ ))
|
||||
#define LOG_SUCCESS(logType, text, ...) log_message(logType, Log::Success, text, ##__VA_ARGS__)
|
||||
#define LOG_NOTICE(logType, text, ...) log_message(logType, Log::Notice, text, ##__VA_ARGS__)
|
||||
#define LOG_WARNING(logType, text, ...) log_message(logType, Log::Warning, text, ##__VA_ARGS__)
|
||||
#define LOG_ERROR(logType, text, ...) log_message(logType, Log::Error, text, ##__VA_ARGS__)
|
||||
|
||||
namespace Log
|
||||
{
|
||||
|
|
@ -139,3 +130,19 @@ static struct { inline operator Log::LogType() { return Log::LogType::HLE; } } H
|
|||
static struct { inline operator Log::LogType() { return Log::LogType::PPU; } } PPU;
|
||||
static struct { inline operator Log::LogType() { return Log::LogType::SPU; } } SPU;
|
||||
static struct { inline operator Log::LogType() { return Log::LogType::TTY; } } TTY;
|
||||
|
||||
inline void log_message(Log::LogType type, Log::LogSeverity sev, std::string text)
|
||||
{
|
||||
//another msvc bug makes this not work, uncomment this and delete everything else in this function when it's fixed
|
||||
//Log::LogManager::getInstance().log({logType, severity, text})
|
||||
|
||||
Log::LogMessage msg{type, sev, text};
|
||||
Log::LogManager::getInstance().log(msg);
|
||||
}
|
||||
|
||||
template<typename T, typename ...Ts>
|
||||
inline void log_message(Log::LogType type, Log::LogSeverity sev, std::string text, T arg, Ts... args)
|
||||
{
|
||||
Log::LogMessage msg{type, sev, fmt::Format(text,arg,args...)};
|
||||
Log::LogManager::getInstance().log(msg);
|
||||
}
|
||||
|
|
@ -25,8 +25,8 @@ class MTRingbuffer{
|
|||
public:
|
||||
MTRingbuffer() : mGet(0), mPut(0){}
|
||||
|
||||
//blocks until there's something to get, so check "free()" if you want to avoid blocking
|
||||
//also lock the get mutex around the free() check and the pop if you want to avoid racing
|
||||
//blocks until there's something to get, so check "spaceLeft()" if you want to avoid blocking
|
||||
//also lock the get mutex around the spaceLeft() check and the pop if you want to avoid racing
|
||||
T pop()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mMutGet);
|
||||
|
|
@ -63,7 +63,7 @@ public:
|
|||
//returns the amount of free places, this is the amount of actual free spaces-1
|
||||
//since mGet==mPut signals an empty buffer we can't actually use the last free
|
||||
//space, so we shouldn't report it as free.
|
||||
size_t free()
|
||||
size_t spaceLeft() //apparently free() is a macro definition in msvc in some conditions
|
||||
{
|
||||
if (mGet < mPut)
|
||||
{
|
||||
|
|
@ -81,8 +81,8 @@ public:
|
|||
|
||||
size_t size()
|
||||
{
|
||||
//the magic -1 is the same magic 1 that is explained in the free() function
|
||||
return mBuffer.size() - free() - 1;
|
||||
//the magic -1 is the same magic 1 that is explained in the spaceLeft() function
|
||||
return mBuffer.size() - spaceLeft() - 1;
|
||||
}
|
||||
|
||||
//takes random access iterator to T
|
||||
|
|
@ -94,7 +94,7 @@ public:
|
|||
|
||||
//if whatever we're trying to store is greater than the entire buffer the following loop will be infinite
|
||||
assert(mBuffer.size() > length);
|
||||
while (free() < length)
|
||||
while (spaceLeft() < length)
|
||||
{
|
||||
//if this is reached a lot it's time to increase the buffer size
|
||||
//or implement dynamic re-sizing
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue