made an option for logging to be synced by default instead of async

This commit is contained in:
georgemoralis 2024-03-11 14:06:39 +02:00
parent 02dcf4d45c
commit 8c4f386641
3 changed files with 32 additions and 9 deletions

View File

@ -13,6 +13,7 @@ bool isNeo = false;
u32 screenWidth = 1280; u32 screenWidth = 1280;
u32 screenHeight = 720; u32 screenHeight = 720;
std::string logFilter; std::string logFilter;
std::string logType = "sync";
bool isDebugDump = false; bool isDebugDump = false;
bool isNeoMode() { bool isNeoMode() {
@ -31,6 +32,10 @@ std::string getLogFilter() {
return logFilter; return logFilter;
} }
std::string getLogType() {
return logType;
}
bool debugDump() { bool debugDump() {
return isDebugDump; return isDebugDump;
} }
@ -59,6 +64,7 @@ void load(const std::filesystem::path& path) {
isNeo = toml::find_or<toml::boolean>(general, "isPS4Pro", false); isNeo = toml::find_or<toml::boolean>(general, "isPS4Pro", false);
logFilter = toml::find_or<toml::string>(general, "logFilter", ""); logFilter = toml::find_or<toml::string>(general, "logFilter", "");
logType = toml::find_or<toml::string>(general, "logType", "sync");
} }
} }
if (data.contains("GPU")) { if (data.contains("GPU")) {
@ -100,6 +106,7 @@ void save(const std::filesystem::path& path) {
data["General"]["isPS4Pro"] = isNeo; data["General"]["isPS4Pro"] = isNeo;
data["General"]["logFilter"] = logFilter; data["General"]["logFilter"] = logFilter;
data["General"]["logType"] = logType;
data["GPU"]["screenWidth"] = screenWidth; data["GPU"]["screenWidth"] = screenWidth;
data["GPU"]["screenHeight"] = screenHeight; data["GPU"]["screenHeight"] = screenHeight;
data["Debug"]["DebugDump"] = isDebugDump; data["Debug"]["DebugDump"] = isDebugDump;

View File

@ -12,6 +12,7 @@ void save(const std::filesystem::path& path);
bool isNeoMode(); bool isNeoMode();
std::string getLogFilter(); std::string getLogFilter();
std::string getLogType();
u32 getScreenWidth(); u32 getScreenWidth();
u32 getScreenHeight(); u32 getScreenHeight();

View File

@ -175,6 +175,8 @@ public:
using std::chrono::microseconds; using std::chrono::microseconds;
using std::chrono::steady_clock; using std::chrono::steady_clock;
if (Config::getLogType() == "async") {
message_queue.EmplaceWait(Entry{ message_queue.EmplaceWait(Entry{
.timestamp = duration_cast<microseconds>(steady_clock::now() - time_origin), .timestamp = duration_cast<microseconds>(steady_clock::now() - time_origin),
.log_class = log_class, .log_class = log_class,
@ -184,6 +186,19 @@ public:
.function = function, .function = function,
.message = std::move(message), .message = std::move(message),
}); });
} else {
const Entry entry = {
.timestamp = duration_cast<microseconds>(steady_clock::now() - time_origin),
.log_class = log_class,
.log_level = log_level,
.filename = filename,
.line_num = line_num,
.function = function,
.message = std::move(message),
};
ForEachBackend([&entry](auto& backend) { backend.Write(entry); });
}
} }
private: private: