diff --git a/.gitignore b/.gitignore index e1e1c7521b..5b1d516b8c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ .vscode .vs .idea +.kdev4 +*.kdev4 /[Bb]uild # Ignore executables (Linux, macOS, Windows) diff --git a/src/Core/Misc/PlogLogger.cpp b/src/Core/Misc/PlogLogger.cpp index 6ddf62ab58..41366543c6 100644 --- a/src/Core/Misc/PlogLogger.cpp +++ b/src/Core/Misc/PlogLogger.cpp @@ -7,6 +7,8 @@ #ifdef _WIN32 #include +#include + namespace plog { /** @@ -84,7 +86,31 @@ PlogLogger::PlogLogger() { } void PlogLogger::log(Core::ILogger::Severity logLevel, const std::string_view message) { - PLOG(PlogLogger::convertSeverity(logLevel)) << message; + PLOG(PlogLogger::convertSeverity(logLevel)) << fmt::format("NORMAL PLOGGER: {}", message); + + std::string log; + Core::ILogger::Severity severity; + this->mutex.lock(); + if (!this->last_msg.empty()) { + if (message == this->last_msg) { + this->count++; + } else { + log = this->last_msg.append(this->count > 0? fmt::format(FMT_STRING(" (x{})"), std::to_string(this->count + 1)) : ""); + severity = Core::ILogger::Severity{this->last_severity}; + + this->last_msg = std::string{message}; + this->last_severity = logLevel; + this->count = 0; + } + } else { + this->last_msg = std::string{message}; + this->last_severity = logLevel; + } + this->mutex.unlock(); + + if (!log.empty()) { + PLOG(PlogLogger::convertSeverity(severity)) << log; + } } void PlogLogger::setLogLevel(Core::ILogger::Severity logLevel) { diff --git a/src/Core/Misc/PlogLogger.hpp b/src/Core/Misc/PlogLogger.hpp index aebec31611..a7ccc540a3 100644 --- a/src/Core/Misc/PlogLogger.hpp +++ b/src/Core/Misc/PlogLogger.hpp @@ -4,8 +4,15 @@ #include "Core/Services/ILogger.hpp" #include +#include + class PlogLogger : public Core::ILogger { public: + int count = 0; + Core::ILogger::Severity last_severity; + std::string last_msg; + std::mutex mutex; + PlogLogger(); void setLogLevel(ILogger::Severity logLevel) override; std::string getLogFile() override; diff --git a/src/RageUtil/File/RageFile.h b/src/RageUtil/File/RageFile.h index 288afd1135..667cbb9cb0 100644 --- a/src/RageUtil/File/RageFile.h +++ b/src/RageUtil/File/RageFile.h @@ -3,6 +3,8 @@ #ifndef RAGE_FILE_H #define RAGE_FILE_H +#include + #include "RageFileBasic.h" struct lua_State;