configurable loglevel in config file
This commit is contained in:
parent
c3135341c2
commit
c4b072e0e1
|
@ -7,8 +7,15 @@
|
|||
namespace Config {
|
||||
|
||||
bool isNeo = false;
|
||||
u32 screenWidth = 1280;
|
||||
u32 screenHeight = 720;
|
||||
u32 logLevel = 0; // TRACE = 0 , DEBUG = 1 , INFO = 2 , WARN = 3 , ERROR = 4 , CRITICAL = 5, OFF = 6
|
||||
|
||||
bool isNeoMode() { return isNeo; }
|
||||
u32 getScreenWidth() { return screenWidth; }
|
||||
u32 getScreenHeight() { return screenHeight; }
|
||||
u32 getLogLevel() { return logLevel; }
|
||||
|
||||
void load(const std::filesystem::path& path) {
|
||||
// If the configuration file does not exist, create it and return
|
||||
std::error_code error;
|
||||
|
@ -32,8 +39,19 @@ void load(const std::filesystem::path& path) {
|
|||
auto general = generalResult.unwrap();
|
||||
|
||||
isNeo = toml::find_or<toml::boolean>(general, "isPS4Pro", false);
|
||||
logLevel = toml::find_or<toml::integer>(general, "logLevel", false);
|
||||
}
|
||||
}
|
||||
if (data.contains("GPU")) {
|
||||
auto generalResult = toml::expect<toml::value>(data.at("GPU"));
|
||||
if (generalResult.is_ok()) {
|
||||
auto general = generalResult.unwrap();
|
||||
|
||||
screenWidth = toml::find_or<toml::integer>(general, "screenWidth", false);
|
||||
screenHeight = toml::find_or<toml::integer>(general, "screenHeight", false);
|
||||
}
|
||||
}
|
||||
int k = 0;
|
||||
}
|
||||
void save(const std::filesystem::path& path) {
|
||||
toml::basic_value<toml::preserve_comments> data;
|
||||
|
@ -54,6 +72,9 @@ void save(const std::filesystem::path& path) {
|
|||
}
|
||||
|
||||
data["General"]["isPS4Pro"] = isNeo;
|
||||
data["General"]["logLevel"] = logLevel;
|
||||
data["GPU"]["screenWidth"] = screenWidth;
|
||||
data["GPU"]["screenHeight"] = screenHeight;
|
||||
|
||||
std::ofstream file(path, std::ios::out);
|
||||
file << data;
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
#pragma once
|
||||
#include <filesystem>
|
||||
#include <types.h>
|
||||
|
||||
namespace Config {
|
||||
void load(const std::filesystem::path& path);
|
||||
void save(const std::filesystem::path& path);
|
||||
|
||||
bool isNeoMode();
|
||||
u32 getLogLevel();
|
||||
|
||||
u32 getScreenWidth();
|
||||
u32 getScreenHeight();
|
||||
|
||||
}; // namespace Config
|
|
@ -5,6 +5,7 @@
|
|||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include <vector>
|
||||
#include <Util/config.h>
|
||||
|
||||
namespace logging {
|
||||
std::vector<spdlog::sink_ptr> sinks;
|
||||
|
@ -17,6 +18,8 @@ int init(bool use_stdout) {
|
|||
spdlog::set_default_logger(std::make_shared<spdlog::logger>("shadps4 logger", begin(sinks), end(sinks)));
|
||||
auto f = std::make_unique<spdlog::pattern_formatter>("%^|%L|: %v%$", spdlog::pattern_time_type::local, std::string("")); // disable eol
|
||||
spdlog::set_formatter(std::move(f));
|
||||
spdlog::set_level(static_cast<spdlog::level::level_enum>(Config::getLogLevel()));
|
||||
spdlog::level::level_enum t = spdlog::get_level();
|
||||
return 0; // all ok
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue