mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-25 20:22:30 +01:00
Merge pull request #886 from Arkaran99/master
Avoid giving arguments by value for log
This commit is contained in:
commit
24c5e7d6cd
@ -11,13 +11,13 @@ using namespace Log;
|
||||
|
||||
LogManager *gLogManager = nullptr;
|
||||
|
||||
u32 LogMessage::size()
|
||||
u32 LogMessage::size() const
|
||||
{
|
||||
//1 byte for NULL terminator
|
||||
return (u32)(sizeof(LogMessage::size_type) + sizeof(LogType) + sizeof(LogSeverity) + sizeof(std::string::value_type) * mText.size() + 1);
|
||||
}
|
||||
|
||||
void LogMessage::serialize(char *output)
|
||||
void LogMessage::serialize(char *output) const
|
||||
{
|
||||
LogMessage::size_type size = this->size();
|
||||
memcpy(output, &size, sizeof(LogMessage::size_type));
|
||||
@ -60,7 +60,7 @@ LogChannel::LogChannel(const std::string& name) :
|
||||
, mLogLevel(Warning)
|
||||
{}
|
||||
|
||||
void LogChannel::log(LogMessage msg)
|
||||
void LogChannel::log(const LogMessage &msg)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mListenerLock);
|
||||
for (auto &listener : mListeners)
|
||||
@ -82,7 +82,7 @@ void LogChannel::removeListener(std::shared_ptr<LogListener> listener)
|
||||
|
||||
struct CoutListener : LogListener
|
||||
{
|
||||
void log(LogMessage msg)
|
||||
void log(const LogMessage &msg)
|
||||
{
|
||||
std::cerr << msg.mText << std::endl;
|
||||
}
|
||||
@ -103,13 +103,15 @@ struct FileListener : LogListener
|
||||
}
|
||||
}
|
||||
|
||||
void log(LogMessage msg)
|
||||
void log(const LogMessage &msg)
|
||||
{
|
||||
std::string text = msg.mText;
|
||||
if (mPrependChannelName)
|
||||
{
|
||||
msg.mText.insert(0, gTypeNameTable[static_cast<u32>(msg.mType)].mName);
|
||||
text.insert(0, gTypeNameTable[static_cast<u32>(msg.mType)].mName);
|
||||
|
||||
}
|
||||
mFile.Write(msg.mText);
|
||||
mFile.Write(text);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -63,15 +63,15 @@ namespace Log
|
||||
LogSeverity mServerity;
|
||||
std::string mText;
|
||||
|
||||
u32 size();
|
||||
void serialize(char *output);
|
||||
u32 size() const;
|
||||
void serialize(char *output) const;
|
||||
static LogMessage deserialize(char *input, u32* size_out=nullptr);
|
||||
};
|
||||
|
||||
struct LogListener
|
||||
{
|
||||
virtual ~LogListener() {};
|
||||
virtual void log(LogMessage msg) = 0;
|
||||
virtual void log(const LogMessage &msg) = 0;
|
||||
};
|
||||
|
||||
struct LogChannel
|
||||
@ -80,7 +80,7 @@ namespace Log
|
||||
LogChannel(const std::string& name);
|
||||
LogChannel(LogChannel& other) = delete;
|
||||
LogChannel& operator = (LogChannel& other) = delete;
|
||||
void log(LogMessage msg);
|
||||
void log(const LogMessage &msg);
|
||||
void addListener(std::shared_ptr<LogListener> listener);
|
||||
void removeListener(std::shared_ptr<LogListener> listener);
|
||||
std::string name;
|
||||
|
@ -97,7 +97,7 @@ struct wxWriter : Log::LogListener
|
||||
}
|
||||
|
||||
//put message into the log buffer
|
||||
void log(Log::LogMessage msg)
|
||||
void log(const Log::LogMessage &msg)
|
||||
{
|
||||
u8 logLevel = Ini.HLELogLvl.GetValue();
|
||||
if (msg.mType != Log::TTY && logLevel != 0)
|
||||
|
Loading…
Reference in New Issue
Block a user