diff --git a/Utilities/Log.cpp b/Utilities/Log.cpp index 1f736617cf..562be95d8a 100644 --- a/Utilities/Log.cpp +++ b/Utilities/Log.cpp @@ -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 lock(mListenerLock); for (auto &listener : mListeners) @@ -82,7 +82,7 @@ void LogChannel::removeListener(std::shared_ptr 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(msg.mType)].mName); + text.insert(0, gTypeNameTable[static_cast(msg.mType)].mName); + } - mFile.Write(msg.mText); + mFile.Write(text); } }; diff --git a/Utilities/Log.h b/Utilities/Log.h index 8dbeb71e07..46bb34124a 100644 --- a/Utilities/Log.h +++ b/Utilities/Log.h @@ -61,15 +61,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 @@ -78,7 +78,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 listener); void removeListener(std::shared_ptr listener); std::string name; diff --git a/rpcs3/Gui/ConLogFrame.cpp b/rpcs3/Gui/ConLogFrame.cpp index 9e9d0209fc..879da2e003 100644 --- a/rpcs3/Gui/ConLogFrame.cpp +++ b/rpcs3/Gui/ConLogFrame.cpp @@ -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)