Use spdlog macros so logging can be completely disabled during compile-time

libinput_only
jackun 3 years ago
parent 46c2183b5d
commit a82e27d978
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -25,8 +25,10 @@ pre_args = [
# Define DEBUG for debug builds only (debugoptimized is not included on this one) # Define DEBUG for debug builds only (debugoptimized is not included on this one)
if get_option('buildtype') == 'debug' if get_option('buildtype') == 'debug'
pre_args += '-DDEBUG' pre_args += '-DDEBUG'
pre_args += '-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE'
else else
pre_args += '-DNDEBUG' pre_args += '-DNDEBUG'
pre_args += '-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_' + get_option('loglevel').to_upper()
endif endif
# TODO: this is very incomplete # TODO: this is very incomplete

@ -14,3 +14,4 @@ option('with_wayland', type : 'feature', value : 'disabled')
option('with_dbus', type : 'feature', value : 'enabled') option('with_dbus', type : 'feature', value : 'enabled')
option('with_dlsym', type : 'feature', value : 'disabled') option('with_dlsym', type : 'feature', value : 'disabled')
option('with_libdrm_amdgpu', type : 'feature', value : 'enabled', description: 'Get amdgpu sensor info through libdrm_amdgpu') option('with_libdrm_amdgpu', type : 'feature', value : 'enabled', description: 'Get amdgpu sensor info through libdrm_amdgpu')
option('loglevel', type: 'combo', choices : ['trace', 'debug', 'info', 'warn', 'err', 'critical', 'off'], value : 'info', description: 'Max log level in non-debug build')

@ -27,7 +27,7 @@ void BatteryStats::update() {
if (!batt_check) { if (!batt_check) {
numBattery(); numBattery();
if (batt_count == 0) { if (batt_count == 0) {
spdlog::error("No battery found"); SPDLOG_ERROR("No battery found");
} }
} }

@ -111,12 +111,12 @@ void parseConfigFile(overlay_params& params) {
std::ifstream stream(*p); std::ifstream stream(*p);
if (!stream.good()) { if (!stream.good()) {
// printing just so user has an idea of possible configs // printing just so user has an idea of possible configs
spdlog::info("skipping config: '{}' [ not found ]", *p); SPDLOG_INFO("skipping config: '{}' [ not found ]", *p);
continue; continue;
} }
stream.imbue(std::locale::classic()); stream.imbue(std::locale::classic());
spdlog::info("parsing config: '{}'", *p); SPDLOG_INFO("parsing config: '{}'", *p);
while (std::getline(stream, line)) while (std::getline(stream, line))
{ {
parseConfigLine(line, params.options); parseConfigLine(line, params.options);

@ -117,13 +117,13 @@ bool CPUStats::Init()
m_cpuData.clear(); m_cpuData.clear();
if (!file.is_open()) { if (!file.is_open()) {
spdlog::error("Failed to opening " PROCSTATFILE); SPDLOG_ERROR("Failed to opening " PROCSTATFILE);
return false; return false;
} }
do { do {
if (!std::getline(file, line)) { if (!std::getline(file, line)) {
spdlog::debug("Failed to read all of " PROCSTATFILE); SPDLOG_DEBUG("Failed to read all of " PROCSTATFILE);
return false; return false;
} else if (starts_with(line, "cpu")) { } else if (starts_with(line, "cpu")) {
if (first) { if (first) {
@ -176,7 +176,7 @@ bool CPUStats::UpdateCPUData()
bool ret = false; bool ret = false;
if (!file.is_open()) { if (!file.is_open()) {
spdlog::error("Failed to opening " PROCSTATFILE); SPDLOG_ERROR("Failed to opening " PROCSTATFILE);
return false; return false;
} }
@ -190,20 +190,20 @@ bool CPUStats::UpdateCPUData()
} else if (sscanf(line.c_str(), "cpu%4d %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu", } else if (sscanf(line.c_str(), "cpu%4d %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu",
&cpuid, &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal, &guest, &guestnice) == 11) { &cpuid, &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal, &guest, &guestnice) == 11) {
//spdlog::debug("Parsing 'cpu{}' line:{}", cpuid, line); //SPDLOG_DEBUG("Parsing 'cpu{}' line:{}", cpuid, line);
if (!ret) { if (!ret) {
spdlog::debug("Failed to parse 'cpu' line:{}", line); SPDLOG_DEBUG("Failed to parse 'cpu' line:{}", line);
return false; return false;
} }
if (cpuid < 0 /* can it? */) { if (cpuid < 0 /* can it? */) {
spdlog::debug("Cpu id '{}' is out of bounds", cpuid); SPDLOG_DEBUG("Cpu id '{}' is out of bounds", cpuid);
return false; return false;
} }
if ((size_t)cpuid >= m_cpuData.size()) { if ((size_t)cpuid >= m_cpuData.size()) {
spdlog::debug("Cpu id '{}' is out of bounds, reiniting", cpuid); SPDLOG_DEBUG("Cpu id '{}' is out of bounds, reiniting", cpuid);
return Reinit(); return Reinit();
} }
@ -399,7 +399,7 @@ static bool find_fallback_temp_input(const std::string path, std::string& input)
if (!ends_with(file, "_input")) if (!ends_with(file, "_input"))
continue; continue;
input = path + "/" + file; input = path + "/" + file;
spdlog::debug("fallback cpu temp input: {}", input); SPDLOG_DEBUG("fallback cpu temp input: {}", input);
return true; return true;
} }
return false; return false;
@ -416,7 +416,7 @@ bool CPUStats::GetCpuFile() {
for (auto& dir : dirs) { for (auto& dir : dirs) {
path = hwmon + dir; path = hwmon + dir;
name = read_line(path + "/name"); name = read_line(path + "/name");
spdlog::debug("hwmon: sensor name: {}", name); SPDLOG_DEBUG("hwmon: sensor name: {}", name);
if (name == "coretemp") { if (name == "coretemp") {
find_temp_input(path, input, "Package id 0"); find_temp_input(path, input, "Package id 0");
@ -434,11 +434,11 @@ bool CPUStats::GetCpuFile() {
} }
if (path.empty() || (!file_exists(input) && !find_fallback_temp_input(path, input))) { if (path.empty() || (!file_exists(input) && !find_fallback_temp_input(path, input))) {
spdlog::error("Could not find cpu temp sensor location"); SPDLOG_ERROR("Could not find cpu temp sensor location");
return false; return false;
} else { } else {
spdlog::debug("hwmon: using input: {}", input); SPDLOG_DEBUG("hwmon: using input: {}", input);
m_cpuTempFile = fopen(input.c_str(), "r"); m_cpuTempFile = fopen(input.c_str(), "r");
} }
return true; return true;
@ -476,10 +476,10 @@ CPUPowerData_k10temp* init_cpu_power_data_k10temp(const std::string path) {
if(!find_input(path, "in", socVoltageInput, "Vsoc")) return nullptr; if(!find_input(path, "in", socVoltageInput, "Vsoc")) return nullptr;
if(!find_input(path, "curr", socCurrentInput, "Isoc")) return nullptr; if(!find_input(path, "curr", socCurrentInput, "Isoc")) return nullptr;
spdlog::debug("hwmon: using input: {}", coreVoltageInput); SPDLOG_DEBUG("hwmon: using input: {}", coreVoltageInput);
spdlog::debug("hwmon: using input: {}", coreCurrentInput); SPDLOG_DEBUG("hwmon: using input: {}", coreCurrentInput);
spdlog::debug("hwmon: using input: {}", socVoltageInput); SPDLOG_DEBUG("hwmon: using input: {}", socVoltageInput);
spdlog::debug("hwmon: using input: {}", socCurrentInput); SPDLOG_DEBUG("hwmon: using input: {}", socCurrentInput);
powerData->coreVoltageFile = fopen(coreVoltageInput.c_str(), "r"); powerData->coreVoltageFile = fopen(coreVoltageInput.c_str(), "r");
powerData->coreCurrentFile = fopen(coreCurrentInput.c_str(), "r"); powerData->coreCurrentFile = fopen(coreCurrentInput.c_str(), "r");
@ -497,8 +497,8 @@ CPUPowerData_zenpower* init_cpu_power_data_zenpower(const std::string path) {
if(!find_input(path, "power", corePowerInput, "SVI2_P_Core")) return nullptr; if(!find_input(path, "power", corePowerInput, "SVI2_P_Core")) return nullptr;
if(!find_input(path, "power", socPowerInput, "SVI2_P_SoC")) return nullptr; if(!find_input(path, "power", socPowerInput, "SVI2_P_SoC")) return nullptr;
spdlog::debug("hwmon: using input: {}", corePowerInput); SPDLOG_DEBUG("hwmon: using input: {}", corePowerInput);
spdlog::debug("hwmon: using input: {}", socPowerInput); SPDLOG_DEBUG("hwmon: using input: {}", socPowerInput);
powerData->corePowerFile = fopen(corePowerInput.c_str(), "r"); powerData->corePowerFile = fopen(corePowerInput.c_str(), "r");
powerData->socPowerFile = fopen(socPowerInput.c_str(), "r"); powerData->socPowerFile = fopen(socPowerInput.c_str(), "r");
@ -530,7 +530,7 @@ bool CPUStats::InitCpuPowerData() {
for (auto& dir : dirs) { for (auto& dir : dirs) {
path = hwmon + dir; path = hwmon + dir;
name = read_line(path + "/name"); name = read_line(path + "/name");
spdlog::debug("hwmon: sensor name: {}", name); SPDLOG_DEBUG("hwmon: sensor name: {}", name);
if (name == "k10temp") { if (name == "k10temp") {
cpuPowerData = (CPUPowerData*)init_cpu_power_data_k10temp(path); cpuPowerData = (CPUPowerData*)init_cpu_power_data_k10temp(path);
@ -547,7 +547,7 @@ bool CPUStats::InitCpuPowerData() {
for (auto& dir : powercap_dirs) { for (auto& dir : powercap_dirs) {
path = powercap + dir; path = powercap + dir;
name = read_line(path + "/name"); name = read_line(path + "/name");
spdlog::debug("powercap: name: {}", name); SPDLOG_DEBUG("powercap: name: {}", name);
if (name == "package-0") { if (name == "package-0") {
cpuPowerData = (CPUPowerData*)init_cpu_power_data_rapl(path); cpuPowerData = (CPUPowerData*)init_cpu_power_data_rapl(path);
break; break;
@ -556,7 +556,7 @@ bool CPUStats::InitCpuPowerData() {
} }
if(cpuPowerData == nullptr) { if(cpuPowerData == nullptr) {
spdlog::error("Failed to initialize CPU power data"); SPDLOG_ERROR("Failed to initialize CPU power data");
return false; return false;
} }

@ -163,7 +163,7 @@ bool dbus_manager::init(const std::string& requested_player) {
} }
if (!m_dbus_ldr.IsLoaded() && !m_dbus_ldr.Load("libdbus-1.so.3")) { if (!m_dbus_ldr.IsLoaded() && !m_dbus_ldr.Load("libdbus-1.so.3")) {
spdlog::error("Could not load libdbus-1.so.3"); SPDLOG_ERROR("Could not load libdbus-1.so.3");
return false; return false;
} }
@ -173,12 +173,12 @@ bool dbus_manager::init(const std::string& requested_player) {
if (nullptr == if (nullptr ==
(m_dbus_conn = m_dbus_ldr.bus_get(DBUS_BUS_SESSION, &m_error))) { (m_dbus_conn = m_dbus_ldr.bus_get(DBUS_BUS_SESSION, &m_error))) {
spdlog::error("{}", m_error.message); SPDLOG_ERROR("{}", m_error.message);
m_dbus_ldr.error_free(&m_error); m_dbus_ldr.error_free(&m_error);
return false; return false;
} }
spdlog::debug("Connected to D-Bus as \"{}\"", SPDLOG_DEBUG("Connected to D-Bus as \"{}\"",
m_dbus_ldr.bus_get_unique_name(m_dbus_conn)); m_dbus_ldr.bus_get_unique_name(m_dbus_conn));
dbus_list_name_to_owner(); dbus_list_name_to_owner();
@ -197,7 +197,7 @@ bool dbus_manager::select_active_player() {
// If the requested player is available, use it // If the requested player is available, use it
if (m_name_owners.count(m_requested_player) > 0) { if (m_name_owners.count(m_requested_player) > 0) {
m_active_player = m_requested_player; m_active_player = m_requested_player;
spdlog::debug("Selecting requested player: {}", m_requested_player); SPDLOG_DEBUG("Selecting requested player: {}", m_requested_player);
get_media_player_metadata(meta, m_active_player); get_media_player_metadata(meta, m_active_player);
} }
} else { } else {
@ -217,7 +217,7 @@ bool dbus_manager::select_active_player() {
if(it != m_name_owners.end()){ if(it != m_name_owners.end()){
m_active_player = it->first; m_active_player = it->first;
spdlog::debug("Selecting fallback player: {}", m_active_player); SPDLOG_DEBUG("Selecting fallback player: {}", m_active_player);
} }
} }
} }
@ -226,7 +226,7 @@ bool dbus_manager::select_active_player() {
onNewPlayer(meta); onNewPlayer(meta);
return true; return true;
} else { } else {
spdlog::debug("No active players"); SPDLOG_DEBUG("No active players");
if (!old_active_player.empty()) { if (!old_active_player.empty()) {
onNoPlayer(); onNoPlayer();
} }
@ -325,7 +325,7 @@ void dbus_manager::connect_to_signals() {
auto signal = format_signal(kv); auto signal = format_signal(kv);
m_dbus_ldr.bus_add_match(m_dbus_conn, signal.c_str(), &m_error); m_dbus_ldr.bus_add_match(m_dbus_conn, signal.c_str(), &m_error);
if (m_dbus_ldr.error_is_set(&m_error)) { if (m_dbus_ldr.error_is_set(&m_error)) {
spdlog::error("{}: {}", m_error.name, m_error.message); SPDLOG_ERROR("{}: {}", m_error.name, m_error.message);
m_dbus_ldr.error_free(&m_error); m_dbus_ldr.error_free(&m_error);
// return; // return;
} }
@ -343,7 +343,7 @@ void dbus_manager::disconnect_from_signals() {
auto signal = format_signal(kv); auto signal = format_signal(kv);
m_dbus_ldr.bus_remove_match(m_dbus_conn, signal.c_str(), &m_error); m_dbus_ldr.bus_remove_match(m_dbus_conn, signal.c_str(), &m_error);
if (m_dbus_ldr.error_is_set(&m_error)) { if (m_dbus_ldr.error_is_set(&m_error)) {
spdlog::error("{}: {}", m_error.name, m_error.message); SPDLOG_ERROR("{}: {}", m_error.name, m_error.message);
m_dbus_ldr.error_free(&m_error); m_dbus_ldr.error_free(&m_error);
} }
} }

@ -137,7 +137,7 @@ template <class T>
auto DBusMessageIter_wrap::get_primitive() -> T { auto DBusMessageIter_wrap::get_primitive() -> T {
auto requested_type = detail::dbus_type_identifier<T>; auto requested_type = detail::dbus_type_identifier<T>;
if (requested_type != type()) { if (requested_type != type()) {
spdlog::error("Type mismatch: '{}' vs '{}'", SPDLOG_ERROR("Type mismatch: '{}' vs '{}'",
((char)requested_type), (char)type()); ((char)requested_type), (char)type());
#ifndef NDEBUG #ifndef NDEBUG
exit(-1); exit(-1);
@ -191,13 +191,13 @@ auto DBusMessageIter_wrap::get_stringified() -> std::string {
if (is_unsigned()) return std::to_string(get_unsigned()); if (is_unsigned()) return std::to_string(get_unsigned());
if (is_signed()) return std::to_string(get_signed()); if (is_signed()) return std::to_string(get_signed());
if (is_double()) return std::to_string(get_primitive<double>()); if (is_double()) return std::to_string(get_primitive<double>());
spdlog::error("stringify failed"); SPDLOG_ERROR("stringify failed");
return std::string(); return std::string();
} }
auto DBusMessageIter_wrap::get_array_iter() -> DBusMessageIter_wrap { auto DBusMessageIter_wrap::get_array_iter() -> DBusMessageIter_wrap {
if (!is_array()) { if (!is_array()) {
spdlog::error("Not an array; {}", (char)type()); SPDLOG_ERROR("Not an array; {}", (char)type());
return DBusMessageIter_wrap(DBusMessageIter{}, m_DBus); return DBusMessageIter_wrap(DBusMessageIter{}, m_DBus);
} }
@ -208,7 +208,7 @@ auto DBusMessageIter_wrap::get_array_iter() -> DBusMessageIter_wrap {
auto DBusMessageIter_wrap::get_dict_entry_iter() -> DBusMessageIter_wrap { auto DBusMessageIter_wrap::get_dict_entry_iter() -> DBusMessageIter_wrap {
if (type() != DBUS_TYPE_DICT_ENTRY) { if (type() != DBUS_TYPE_DICT_ENTRY) {
spdlog::error("Not a dict entry {}", (char)type()); SPDLOG_ERROR("Not a dict entry {}", (char)type());
return DBusMessageIter_wrap(DBusMessageIter{}, m_DBus); return DBusMessageIter_wrap(DBusMessageIter{}, m_DBus);
} }
@ -335,7 +335,7 @@ DBusMessage_wrap DBusMessage_wrap::send_with_reply_and_block(
auto reply = m_DBus->connection_send_with_reply_and_block(conn, m_msg, auto reply = m_DBus->connection_send_with_reply_and_block(conn, m_msg,
timeout, &err); timeout, &err);
if (reply == nullptr) { if (reply == nullptr) {
spdlog::error("[{}]: {}", __func__, err.message); SPDLOG_ERROR("[{}]: {}", __func__, err.message);
free_if_owning(); free_if_owning();
m_DBus->error_free(&err); m_DBus->error_free(&err);
} }

@ -23,7 +23,7 @@ bool find_folder(const char* root, const char* prefix, std::string& dest)
struct dirent* dp; struct dirent* dp;
DIR* dirp = opendir(root); DIR* dirp = opendir(root);
if (!dirp) { if (!dirp) {
spdlog::error("Error opening directory '{}': {}", root, strerror(errno)); SPDLOG_ERROR("Error opening directory '{}': {}", root, strerror(errno));
return false; return false;
} }
@ -52,7 +52,7 @@ std::vector<std::string> ls(const char* root, const char* prefix, LS_FLAGS flags
DIR* dirp = opendir(root); DIR* dirp = opendir(root);
if (!dirp) { if (!dirp) {
spdlog::error("Error opening directory '{}': {}", root, strerror(errno)); SPDLOG_ERROR("Error opening directory '{}': {}", root, strerror(errno));
return list; return list;
} }

@ -139,13 +139,13 @@ static bool CheckShader(GLuint handle, const char* desc)
glGetShaderiv(handle, GL_COMPILE_STATUS, &status); glGetShaderiv(handle, GL_COMPILE_STATUS, &status);
glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &log_length); glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &log_length);
if ((GLboolean)status == GL_FALSE) if ((GLboolean)status == GL_FALSE)
spdlog::error("ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile {}!", desc); SPDLOG_ERROR("ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile {}!", desc);
if (log_length > 1) if (log_length > 1)
{ {
ImVector<char> buf; ImVector<char> buf;
buf.resize((int)(log_length + 1)); buf.resize((int)(log_length + 1));
glGetShaderInfoLog(handle, log_length, NULL, (GLchar*)buf.begin()); glGetShaderInfoLog(handle, log_length, NULL, (GLchar*)buf.begin());
spdlog::error("{}", buf.begin()); SPDLOG_ERROR("{}", buf.begin());
} }
return (GLboolean)status == GL_TRUE; return (GLboolean)status == GL_TRUE;
} }
@ -157,13 +157,13 @@ static bool CheckProgram(GLuint handle, const char* desc)
glGetProgramiv(handle, GL_LINK_STATUS, &status); glGetProgramiv(handle, GL_LINK_STATUS, &status);
glGetProgramiv(handle, GL_INFO_LOG_LENGTH, &log_length); glGetProgramiv(handle, GL_INFO_LOG_LENGTH, &log_length);
if ((GLboolean)status == GL_FALSE) if ((GLboolean)status == GL_FALSE)
spdlog::error("ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link {}! (with GLSL '{}')", desc, g_GlslVersionString); SPDLOG_ERROR("ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link {}! (with GLSL '{}')", desc, g_GlslVersionString);
if (log_length > 1) if (log_length > 1)
{ {
ImVector<char> buf; ImVector<char> buf;
buf.resize((int)(log_length + 1)); buf.resize((int)(log_length + 1));
glGetProgramInfoLog(handle, log_length, NULL, (GLchar*)buf.begin()); glGetProgramInfoLog(handle, log_length, NULL, (GLchar*)buf.begin());
spdlog::error("{}", buf.begin()); SPDLOG_ERROR("{}", buf.begin());
} }
return (GLboolean)status == GL_TRUE; return (GLboolean)status == GL_TRUE;
} }
@ -479,12 +479,12 @@ void ImGui_ImplOpenGL3_NewFrame()
if (!g_ShaderHandle) if (!g_ShaderHandle)
ImGui_ImplOpenGL3_CreateDeviceObjects(); ImGui_ImplOpenGL3_CreateDeviceObjects();
else if (!glIsProgram(g_ShaderHandle)) { // TODO Got created in a now dead context? else if (!glIsProgram(g_ShaderHandle)) { // TODO Got created in a now dead context?
spdlog::debug("Recreating lost objects"); SPDLOG_DEBUG("Recreating lost objects");
ImGui_ImplOpenGL3_CreateDeviceObjects(); ImGui_ImplOpenGL3_CreateDeviceObjects();
} }
if (!glIsTexture(g_FontTexture)) { if (!glIsTexture(g_FontTexture)) {
spdlog::debug("GL Texture lost? Regenerating."); SPDLOG_DEBUG("GL Texture lost? Regenerating.");
g_FontTexture = 0; g_FontTexture = 0;
ImGui_ImplOpenGL3_CreateFontsTexture(); ImGui_ImplOpenGL3_CreateFontsTexture();
} }

@ -22,7 +22,7 @@ void* get_egl_proc_address(const char* name) {
if (!pfn_eglGetProcAddress) { if (!pfn_eglGetProcAddress) {
void *handle = real_dlopen("libEGL.so.1", RTLD_LAZY|RTLD_LOCAL); void *handle = real_dlopen("libEGL.so.1", RTLD_LAZY|RTLD_LOCAL);
if (!handle) { if (!handle) {
spdlog::error("Failed to open " MANGOHUD_ARCH " libEGL.so.1: {}", dlerror()); SPDLOG_ERROR("Failed to open " MANGOHUD_ARCH " libEGL.so.1: {}", dlerror());
} else { } else {
pfn_eglGetProcAddress = reinterpret_cast<decltype(pfn_eglGetProcAddress)>(real_dlsym(handle, "eglGetProcAddress")); pfn_eglGetProcAddress = reinterpret_cast<decltype(pfn_eglGetProcAddress)>(real_dlsym(handle, "eglGetProcAddress"));
} }
@ -35,7 +35,7 @@ void* get_egl_proc_address(const char* name) {
func = get_proc_address( name ); func = get_proc_address( name );
if (!func) { if (!func) {
spdlog::debug("Failed to get function '{}'", name); SPDLOG_DEBUG("Failed to get function '{}'", name);
} }
return func; return func;
@ -43,7 +43,7 @@ void* get_egl_proc_address(const char* name) {
//EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); //EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
EXPORT_C_(int) eglMakeCurrent_OFF(void *dpy, void *draw, void *read,void *ctx) { EXPORT_C_(int) eglMakeCurrent_OFF(void *dpy, void *draw, void *read,void *ctx) {
spdlog::trace("{}: draw: {}, ctx: {}", __func__, draw, ctx); SPDLOG_TRACE("{}: draw: {}, ctx: {}", __func__, draw, ctx);
int ret = 0; int ret = 0;
return ret; return ret;
} }
@ -105,7 +105,7 @@ EXPORT_C_(void *) mangohud_find_egl_ptr(const char *name)
EXPORT_C_(void *) eglGetProcAddress(const char* procName) { EXPORT_C_(void *) eglGetProcAddress(const char* procName) {
void* real_func = get_egl_proc_address(procName); void* real_func = get_egl_proc_address(procName);
void* func = mangohud_find_egl_ptr(procName); void* func = mangohud_find_egl_ptr(procName);
spdlog::trace("{}: proc: {}, real: {}, fun: {}", __func__, procName, real_func, func); SPDLOG_TRACE("{}: proc: {}, real: {}, fun: {}", __func__, procName, real_func, func);
if (func && real_func) if (func && real_func)
return func; return func;

@ -48,7 +48,7 @@ void* get_glx_proc_address(const char* name) {
func = get_proc_address( name ); func = get_proc_address( name );
if (!func) { if (!func) {
spdlog::error("Failed to get function '{}'", name); SPDLOG_ERROR("Failed to get function '{}'", name);
} }
return func; return func;
@ -60,7 +60,7 @@ EXPORT_C_(void *) glXCreateContext(void *dpy, void *vis, void *shareList, int di
void *ctx = glx.CreateContext(dpy, vis, shareList, direct); void *ctx = glx.CreateContext(dpy, vis, shareList, direct);
if (ctx) if (ctx)
refcnt++; refcnt++;
spdlog::debug("{}: {}", __func__, ctx); SPDLOG_DEBUG("{}: {}", __func__, ctx);
return ctx; return ctx;
} }
@ -70,7 +70,7 @@ EXPORT_C_(void *) glXCreateContextAttribs(void *dpy, void *config,void *share_co
void *ctx = glx.CreateContextAttribs(dpy, config, share_context, direct, attrib_list); void *ctx = glx.CreateContextAttribs(dpy, config, share_context, direct, attrib_list);
if (ctx) if (ctx)
refcnt++; refcnt++;
spdlog::debug("{}: {}", __func__, ctx); SPDLOG_DEBUG("{}: {}", __func__, ctx);
return ctx; return ctx;
} }
@ -80,7 +80,7 @@ EXPORT_C_(void *) glXCreateContextAttribsARB(void *dpy, void *config,void *share
void *ctx = glx.CreateContextAttribsARB(dpy, config, share_context, direct, attrib_list); void *ctx = glx.CreateContextAttribsARB(dpy, config, share_context, direct, attrib_list);
if (ctx) if (ctx)
refcnt++; refcnt++;
spdlog::debug("{}: {}", __func__, ctx); SPDLOG_DEBUG("{}: {}", __func__, ctx);
return ctx; return ctx;
} }
@ -91,18 +91,18 @@ EXPORT_C_(void) glXDestroyContext(void *dpy, void *ctx)
refcnt--; refcnt--;
if (refcnt <= 0) if (refcnt <= 0)
imgui_shutdown(); imgui_shutdown();
spdlog::debug("{}: {}", __func__, ctx); SPDLOG_DEBUG("{}: {}", __func__, ctx);
} }
EXPORT_C_(int) glXMakeCurrent(void* dpy, void* drawable, void* ctx) { EXPORT_C_(int) glXMakeCurrent(void* dpy, void* drawable, void* ctx) {
glx.Load(); glx.Load();
spdlog::debug("{}: {}, {}", __func__, drawable, ctx); SPDLOG_DEBUG("{}: {}, {}", __func__, drawable, ctx);
int ret = glx.MakeCurrent(dpy, drawable, ctx); int ret = glx.MakeCurrent(dpy, drawable, ctx);
if (!is_blacklisted()) { if (!is_blacklisted()) {
if (ret) { if (ret) {
imgui_set_context(ctx); imgui_set_context(ctx);
spdlog::debug("GL ref count: {}", refcnt); SPDLOG_DEBUG("GL ref count: {}", refcnt);
} }
// Afaik -1 only works with EXT version if it has GLX_EXT_swap_control_tear, maybe EGL_MESA_swap_control_tear someday // Afaik -1 only works with EXT version if it has GLX_EXT_swap_control_tear, maybe EGL_MESA_swap_control_tear someday
@ -147,7 +147,7 @@ static void do_imgui_swap(void *dpy, void *drawable)
break; break;
} }
spdlog::trace("swap buffers: {}x{}", width, height); SPDLOG_TRACE("swap buffers: {}x{}", width, height);
imgui_render(width, height); imgui_render(width, height);
} }
} }
@ -185,7 +185,7 @@ EXPORT_C_(int64_t) glXSwapBuffersMscOML(void* dpy, void* drawable, int64_t targe
} }
EXPORT_C_(void) glXSwapIntervalEXT(void *dpy, void *draw, int interval) { EXPORT_C_(void) glXSwapIntervalEXT(void *dpy, void *draw, int interval) {
spdlog::debug("{}: {}", __func__, interval); SPDLOG_DEBUG("{}: {}", __func__, interval);
glx.Load(); glx.Load();
if (!glx.SwapIntervalEXT) if (!glx.SwapIntervalEXT)
return; return;
@ -197,7 +197,7 @@ EXPORT_C_(void) glXSwapIntervalEXT(void *dpy, void *draw, int interval) {
} }
EXPORT_C_(int) glXSwapIntervalSGI(int interval) { EXPORT_C_(int) glXSwapIntervalSGI(int interval) {
spdlog::debug("{}: {}", __func__, interval); SPDLOG_DEBUG("{}: {}", __func__, interval);
glx.Load(); glx.Load();
if (!glx.SwapIntervalSGI) if (!glx.SwapIntervalSGI)
return -1; return -1;
@ -209,7 +209,7 @@ EXPORT_C_(int) glXSwapIntervalSGI(int interval) {
} }
EXPORT_C_(int) glXSwapIntervalMESA(unsigned int interval) { EXPORT_C_(int) glXSwapIntervalMESA(unsigned int interval) {
spdlog::debug("{}: {}", __func__, interval); SPDLOG_DEBUG("{}: {}", __func__, interval);
glx.Load(); glx.Load();
if (!glx.SwapIntervalMESA) if (!glx.SwapIntervalMESA)
return -1; return -1;
@ -239,7 +239,7 @@ EXPORT_C_(int) glXGetSwapIntervalMESA() {
} }
} }
spdlog::debug("{}: {}", __func__, interval); SPDLOG_DEBUG("{}: {}", __func__, interval);
return interval; return interval;
} }
@ -283,7 +283,7 @@ EXPORT_C_(void *) mangohud_find_glx_ptr(const char *name)
EXPORT_C_(void *) glXGetProcAddress(const unsigned char* procName) { EXPORT_C_(void *) glXGetProcAddress(const unsigned char* procName) {
void *real_func = get_glx_proc_address((const char*)procName); void *real_func = get_glx_proc_address((const char*)procName);
void *func = mangohud_find_glx_ptr( (const char*)procName ); void *func = mangohud_find_glx_ptr( (const char*)procName );
spdlog::trace("{}: '{}', real: {}, fun: {}", __func__, procName, real_func, func); SPDLOG_TRACE("{}: '{}', real: {}, fun: {}", __func__, procName, real_func, func);
if (func && real_func) if (func && real_func)
return func; return func;
@ -294,7 +294,7 @@ EXPORT_C_(void *) glXGetProcAddress(const unsigned char* procName) {
EXPORT_C_(void *) glXGetProcAddressARB(const unsigned char* procName) { EXPORT_C_(void *) glXGetProcAddressARB(const unsigned char* procName) {
void *real_func = get_glx_proc_address((const char*)procName); void *real_func = get_glx_proc_address((const char*)procName);
void *func = mangohud_find_glx_ptr( (const char*)procName ); void *func = mangohud_find_glx_ptr( (const char*)procName );
spdlog::trace("{}: '{}', real: {}, fun: {}", __func__, procName, real_func, func); SPDLOG_TRACE("{}: '{}', real: {}, fun: {}", __func__, procName, real_func, func);
if (func && real_func) if (func && real_func)
return func; return func;

@ -191,7 +191,7 @@ struct amdgpu_handles
period = 10000000; /* 10ms */ period = 10000000; /* 10ms */
ticks = ticks_per_sec * std::chrono::nanoseconds(period) / 1s; ticks = ticks_per_sec * std::chrono::nanoseconds(period) / 1s;
sleep_interval = std::chrono::nanoseconds(period) / ticks; sleep_interval = std::chrono::nanoseconds(period) / ticks;
spdlog::debug("ticks: {}, {}ns", ticks, sleep_interval.count()); SPDLOG_DEBUG("ticks: {}, {}ns", ticks, sleep_interval.count());
} }
void amdgpu_poll() void amdgpu_poll()
@ -234,20 +234,20 @@ bool amdgpu_open(const char *path) {
int fd = open(path, O_RDWR | O_CLOEXEC); int fd = open(path, O_RDWR | O_CLOEXEC);
if (fd < 0) { if (fd < 0) {
spdlog::error("Failed to open DRM device: {}", strerror(errno)); SPDLOG_ERROR("Failed to open DRM device: {}", strerror(errno));
return false; return false;
} }
drmVersionPtr ver = libdrm_ptr->drmGetVersion(fd); drmVersionPtr ver = libdrm_ptr->drmGetVersion(fd);
if (!ver) { if (!ver) {
spdlog::error("Failed to query driver version: {}", strerror(errno)); SPDLOG_ERROR("Failed to query driver version: {}", strerror(errno));
close(fd); close(fd);
return false; return false;
} }
if (strcmp(ver->name, "amdgpu") || !DRM_ATLEAST_VERSION(ver, 3, 11)) { if (strcmp(ver->name, "amdgpu") || !DRM_ATLEAST_VERSION(ver, 3, 11)) {
spdlog::error("Unsupported driver/version: {} {}.{}.{}", ver->name, ver->version_major, ver->version_minor, ver->version_patchlevel); SPDLOG_ERROR("Unsupported driver/version: {} {}.{}.{}", ver->name, ver->version_major, ver->version_minor, ver->version_patchlevel);
close(fd); close(fd);
libdrm_ptr->drmFreeVersion(ver); libdrm_ptr->drmFreeVersion(ver);
return false; return false;
@ -264,7 +264,7 @@ bool amdgpu_open(const char *path) {
uint32_t drm_major, drm_minor; uint32_t drm_major, drm_minor;
amdgpu_device_handle dev; amdgpu_device_handle dev;
if (libdrm_ptr->amdgpu_device_initialize(fd, &drm_major, &drm_minor, &dev)){ if (libdrm_ptr->amdgpu_device_initialize(fd, &drm_major, &drm_minor, &dev)){
spdlog::error("Failed to initialize amdgpu device: {}", strerror(errno)); SPDLOG_ERROR("Failed to initialize amdgpu device: {}", strerror(errno));
close(fd); close(fd);
return false; return false;
} }

@ -27,7 +27,7 @@ bool libdbus_loader::Load(const std::string& library_name) {
#if defined(LIBRARY_LOADER_DBUS_H_DLOPEN) #if defined(LIBRARY_LOADER_DBUS_H_DLOPEN)
library_ = dlopen(library_name.c_str(), RTLD_LAZY); library_ = dlopen(library_name.c_str(), RTLD_LAZY);
if (!library_) { if (!library_) {
spdlog::error("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror()); SPDLOG_ERROR("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror());
return false; return false;
} }

@ -25,7 +25,7 @@ bool glx_loader::Load() {
if (!handle) if (!handle)
handle = real_dlopen("libGL.so.1", RTLD_LAZY); handle = real_dlopen("libGL.so.1", RTLD_LAZY);
if (!handle) { if (!handle) {
spdlog::error("Failed to open " MANGOHUD_ARCH " libGL.so.1: {}", dlerror()); SPDLOG_ERROR("Failed to open " MANGOHUD_ARCH " libGL.so.1: {}", dlerror());
return false; return false;
} }

@ -28,13 +28,13 @@ bool libdrm_loader::Load() {
#if defined(LIBRARY_LOADER_LIBDRM_H_DLOPEN) #if defined(LIBRARY_LOADER_LIBDRM_H_DLOPEN)
library_drm = dlopen("libdrm.so.2", RTLD_LAZY); library_drm = dlopen("libdrm.so.2", RTLD_LAZY);
if (!library_drm) { if (!library_drm) {
spdlog::error("Failed to open " MANGOHUD_ARCH " libdrm.so.2: {}", dlerror()); SPDLOG_ERROR("Failed to open " MANGOHUD_ARCH " libdrm.so.2: {}", dlerror());
return false; return false;
} }
library_amdgpu = dlopen("libdrm_amdgpu.so.1", RTLD_LAZY); library_amdgpu = dlopen("libdrm_amdgpu.so.1", RTLD_LAZY);
if (!library_amdgpu) { if (!library_amdgpu) {
spdlog::error("Failed to open " MANGOHUD_ARCH " libdrm_amdgpu.so.1: {}", dlerror()); SPDLOG_ERROR("Failed to open " MANGOHUD_ARCH " libdrm_amdgpu.so.1: {}", dlerror());
CleanUp(true); CleanUp(true);
return false; return false;
} }

@ -36,7 +36,7 @@ bool libnvctrl_loader::Load(const std::string& library_name) {
#if defined(LIBRARY_LOADER_NVCTRL_H_DLOPEN) #if defined(LIBRARY_LOADER_NVCTRL_H_DLOPEN)
library_ = dlopen(library_name.c_str(), RTLD_LAZY); library_ = dlopen(library_name.c_str(), RTLD_LAZY);
if (!library_) { if (!library_) {
spdlog::error("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror()); SPDLOG_ERROR("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror());
return false; return false;
} }

@ -39,7 +39,7 @@ bool libnvml_loader::Load(const std::string& library_name) {
#if defined(LIBRARY_LOADER_NVML_H_DLOPEN) #if defined(LIBRARY_LOADER_NVML_H_DLOPEN)
library_ = dlopen(library_name.c_str(), RTLD_LAZY); library_ = dlopen(library_name.c_str(), RTLD_LAZY);
if (!library_) { if (!library_) {
spdlog::error("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror()); SPDLOG_ERROR("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror());
return false; return false;
} }
#endif #endif

@ -16,7 +16,7 @@ bool libx11_loader::Load(const std::string& library_name) {
library_ = dlopen(library_name.c_str(), RTLD_LAZY); library_ = dlopen(library_name.c_str(), RTLD_LAZY);
if (!library_) { if (!library_) {
spdlog::error("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror()); SPDLOG_ERROR("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror());
return false; return false;
} }

@ -59,7 +59,7 @@ void upload_files(const std::vector<std::string>& logFiles){
void writeFile(string filename){ void writeFile(string filename){
auto& logArray = logger->get_log_data(); auto& logArray = logger->get_log_data();
spdlog::debug("Writing log file [{}], {} entries", filename, logArray.size()); SPDLOG_DEBUG("Writing log file [{}], {} entries", filename, logArray.size());
std::ofstream out(filename, ios::out | ios::app); std::ofstream out(filename, ios::out | ios::app);
if (out){ if (out){
out << "os," << "cpu," << "gpu," << "ram," << "kernel," << "driver," << "cpuscheduler" << endl; out << "os," << "cpu," << "gpu," << "ram," << "kernel," << "driver," << "cpuscheduler" << endl;
@ -109,7 +109,7 @@ Logger::Logger(overlay_params* in_params)
m_values_valid(false), m_values_valid(false),
m_params(in_params) m_params(in_params)
{ {
spdlog::debug("Logger constructed!"); SPDLOG_DEBUG("Logger constructed!");
} }
void Logger::start_logging() { void Logger::start_logging() {

@ -28,7 +28,7 @@ static void fileChanged(void *params_void) {
std::this_thread::sleep_for(std::chrono::milliseconds(100)); std::this_thread::sleep_for(std::chrono::milliseconds(100));
parse_overlay_config(&local_params, getenv("MANGOHUD_CONFIG")); parse_overlay_config(&local_params, getenv("MANGOHUD_CONFIG"));
if ((event->mask & IN_DELETE_SELF) || (nt->params->config_file_path != local_params.config_file_path)) { if ((event->mask & IN_DELETE_SELF) || (nt->params->config_file_path != local_params.config_file_path)) {
spdlog::debug("Watching config file: {}", local_params.config_file_path.c_str()); SPDLOG_DEBUG("Watching config file: {}", local_params.config_file_path.c_str());
inotify_rm_watch(nt->fd, nt->wd); inotify_rm_watch(nt->fd, nt->wd);
nt->wd = inotify_add_watch(nt->fd, local_params.config_file_path.c_str(), IN_MODIFY | IN_DELETE_SELF); nt->wd = inotify_add_watch(nt->fd, local_params.config_file_path.c_str(), IN_MODIFY | IN_DELETE_SELF);
} }
@ -45,7 +45,7 @@ bool start_notifier(notify_thread& nt)
{ {
nt.fd = inotify_init1(IN_NONBLOCK); nt.fd = inotify_init1(IN_NONBLOCK);
if (nt.fd < 0) { if (nt.fd < 0) {
spdlog::error("inotify_init1 failed: {}", strerror(errno)); SPDLOG_ERROR("inotify_init1 failed: {}", strerror(errno));
return false; return false;
} }

@ -26,7 +26,7 @@ static bool find_nv_x11(libnvctrl_loader& nvctrl, Display*& dpy)
if (d) { if (d) {
if (nvctrl.XNVCTRLIsNvScreen(d, 0)) { if (nvctrl.XNVCTRLIsNvScreen(d, 0)) {
dpy = d; dpy = d;
spdlog::debug("XNVCtrl is using display {}", buf); SPDLOG_DEBUG("XNVCtrl is using display {}", buf);
return true; return true;
} }
g_x11->XCloseDisplay(d); g_x11->XCloseDisplay(d);
@ -42,7 +42,7 @@ bool checkXNVCtrl()
auto& nvctrl = get_libnvctrl_loader(); auto& nvctrl = get_libnvctrl_loader();
if (!nvctrl.IsLoaded()) { if (!nvctrl.IsLoaded()) {
spdlog::error("XNVCtrl loader failed to load"); SPDLOG_ERROR("XNVCtrl loader failed to load");
return false; return false;
} }
@ -50,7 +50,7 @@ bool checkXNVCtrl()
nvctrlSuccess = find_nv_x11(nvctrl, dpy); nvctrlSuccess = find_nv_x11(nvctrl, dpy);
if (!nvctrlSuccess) { if (!nvctrlSuccess) {
spdlog::error("XNVCtrl didn't find the correct display"); SPDLOG_ERROR("XNVCtrl didn't find the correct display");
return false; return false;
} }
@ -92,7 +92,7 @@ static void parse_token(std::string token, string_map& options) {
char* get_attr_target_string(libnvctrl_loader& nvctrl, int attr, int target_type, int target_id) { char* get_attr_target_string(libnvctrl_loader& nvctrl, int attr, int target_type, int target_id) {
char* c = nullptr; char* c = nullptr;
if (!nvctrl.XNVCTRLQueryTargetStringAttribute(display.get(), target_type, target_id, 0, attr, &c)) { if (!nvctrl.XNVCTRLQueryTargetStringAttribute(display.get(), target_type, target_id, 0, attr, &c)) {
spdlog::error("Failed to query attribute '{}'", attr); SPDLOG_ERROR("Failed to query attribute '{}'", attr);
} }
return c; return c;
} }

@ -17,19 +17,19 @@ bool checkNVML(const char* pciBusId){
if (nvml.IsLoaded()){ if (nvml.IsLoaded()){
result = nvml.nvmlInit(); result = nvml.nvmlInit();
if (NVML_SUCCESS != result) { if (NVML_SUCCESS != result) {
spdlog::error("Nvidia module not loaded"); SPDLOG_ERROR("Nvidia module not loaded");
} else { } else {
nvmlReturn_t ret = NVML_ERROR_UNKNOWN; nvmlReturn_t ret = NVML_ERROR_UNKNOWN;
if (pciBusId && ((ret = nvml.nvmlDeviceGetHandleByPciBusId(pciBusId, &nvidiaDevice)) != NVML_SUCCESS)) { if (pciBusId && ((ret = nvml.nvmlDeviceGetHandleByPciBusId(pciBusId, &nvidiaDevice)) != NVML_SUCCESS)) {
spdlog::error("Getting device handle by PCI bus ID failed: {}", nvml.nvmlErrorString(ret)); SPDLOG_ERROR("Getting device handle by PCI bus ID failed: {}", nvml.nvmlErrorString(ret));
spdlog::error("Using index 0."); SPDLOG_ERROR("Using index 0.");
} }
if (ret != NVML_SUCCESS) if (ret != NVML_SUCCESS)
ret = nvml.nvmlDeviceGetHandleByIndex(0, &nvidiaDevice); ret = nvml.nvmlDeviceGetHandleByIndex(0, &nvidiaDevice);
if (ret != NVML_SUCCESS) if (ret != NVML_SUCCESS)
spdlog::error("Getting device handle failed: {}", nvml.nvmlErrorString(ret)); SPDLOG_ERROR("Getting device handle failed: {}", nvml.nvmlErrorString(ret));
nvmlSuccess = (ret == NVML_SUCCESS); nvmlSuccess = (ret == NVML_SUCCESS);
if (ret == NVML_SUCCESS) if (ret == NVML_SUCCESS)
@ -38,7 +38,7 @@ bool checkNVML(const char* pciBusId){
return nvmlSuccess; return nvmlSuccess;
} }
} else { } else {
spdlog::error("Failed to load NVML"); SPDLOG_ERROR("Failed to load NVML");
} }
return false; return false;

@ -518,10 +518,10 @@ void init_gpu_stats(uint32_t& vendorID, overlay_params& params)
<< std::setw(1) << pci.func; << std::setw(1) << pci.func;
params.pci_dev = ss.str(); params.pci_dev = ss.str();
pci_dev = params.pci_dev.c_str(); pci_dev = params.pci_dev.c_str();
spdlog::debug("PCI device ID: '{}'", pci_dev); SPDLOG_DEBUG("PCI device ID: '{}'", pci_dev);
} else { } else {
spdlog::error("Failed to parse PCI device ID: '{}'", pci_dev); SPDLOG_ERROR("Failed to parse PCI device ID: '{}'", pci_dev);
spdlog::error("Specify it as 'domain:bus:slot.func'"); SPDLOG_ERROR("Specify it as 'domain:bus:slot.func'");
} }
} }
@ -548,7 +548,7 @@ void init_gpu_stats(uint32_t& vendorID, overlay_params& params)
for (auto& dir : dirs) { for (auto& dir : dirs) {
path = drm + dir; path = drm + dir;
spdlog::debug("amdgpu path check: {}/device/vendor", path); SPDLOG_DEBUG("amdgpu path check: {}/device/vendor", path);
string device = read_line(path + "/device/device"); string device = read_line(path + "/device/device");
deviceID = strtol(device.c_str(), NULL, 16); deviceID = strtol(device.c_str(), NULL, 16);
@ -559,14 +559,14 @@ void init_gpu_stats(uint32_t& vendorID, overlay_params& params)
if (pci_bus_parsed && pci_dev) { if (pci_bus_parsed && pci_dev) {
string pci_device = read_symlink((path + "/device").c_str()); string pci_device = read_symlink((path + "/device").c_str());
spdlog::debug("PCI device symlink: '{}'", pci_device); SPDLOG_DEBUG("PCI device symlink: '{}'", pci_device);
if (!ends_with(pci_device, pci_dev)) { if (!ends_with(pci_device, pci_dev)) {
spdlog::debug("skipping GPU, no PCI ID match"); SPDLOG_DEBUG("skipping GPU, no PCI ID match");
continue; continue;
} }
} }
spdlog::debug("using amdgpu path: {}", path); SPDLOG_DEBUG("using amdgpu path: {}", path);
#ifdef HAVE_LIBDRM_AMDGPU #ifdef HAVE_LIBDRM_AMDGPU
int idx = -1; int idx = -1;
@ -580,11 +580,11 @@ void init_gpu_stats(uint32_t& vendorID, overlay_params& params)
getAmdGpuInfo_actual = getAmdGpuInfo_libdrm; getAmdGpuInfo_actual = getAmdGpuInfo_libdrm;
amdgpu_set_sampling_period(params.fps_sampling_period); amdgpu_set_sampling_period(params.fps_sampling_period);
spdlog::debug("Using libdrm"); SPDLOG_DEBUG("Using libdrm");
// fall through and open sysfs handles for fallback or check DRM version beforehand // fall through and open sysfs handles for fallback or check DRM version beforehand
} else if (!params.enabled[OVERLAY_PARAM_ENABLED_force_amdgpu_hwmon]) { } else if (!params.enabled[OVERLAY_PARAM_ENABLED_force_amdgpu_hwmon]) {
spdlog::error("Failed to open device '/dev/dri/card{}' with libdrm, falling back to using hwmon sysfs.", idx); SPDLOG_ERROR("Failed to open device '/dev/dri/card{}' with libdrm, falling back to using hwmon sysfs.", idx);
} }
#endif #endif
@ -620,7 +620,7 @@ void init_gpu_stats(uint32_t& vendorID, overlay_params& params)
} }
#endif #endif
if (!params.permit_upload) if (!params.permit_upload)
spdlog::info("Uploading is disabled (permit_upload = 0)"); SPDLOG_INFO("Uploading is disabled (permit_upload = 0)");
} }
void init_system_info(){ void init_system_info(){
@ -714,13 +714,13 @@ void init_system_info(){
if (ld_preload) if (ld_preload)
setenv("LD_PRELOAD", ld_preload, 1); setenv("LD_PRELOAD", ld_preload, 1);
spdlog::debug("Ram:{}", ram); SPDLOG_DEBUG("Ram:{}", ram);
spdlog::debug("Cpu:{}", cpu); SPDLOG_DEBUG("Cpu:{}", cpu);
spdlog::debug("Kernel:{}", kernel); SPDLOG_DEBUG("Kernel:{}", kernel);
spdlog::debug("Os:{}", os); SPDLOG_DEBUG("Os:{}", os);
spdlog::debug("Gpu:{}", gpu); SPDLOG_DEBUG("Gpu:{}", gpu);
spdlog::debug("Driver:{}", driver); SPDLOG_DEBUG("Driver:{}", driver);
spdlog::debug("CPU Scheduler:{}", cpusched); SPDLOG_DEBUG("CPU Scheduler:{}", cpusched);
#endif #endif
} }

@ -95,8 +95,8 @@ parse_control(const char *str)
{ {
int ret = os_socket_listen_abstract(str, 1); int ret = os_socket_listen_abstract(str, 1);
if (ret < 0) { if (ret < 0) {
spdlog::error("Couldn't create socket pipe at '{}'\n", str); SPDLOG_ERROR("Couldn't create socket pipe at '{}'\n", str);
spdlog::error("ERROR: '{}'", strerror(errno)); SPDLOG_ERROR("ERROR: '{}'", strerror(errno));
return ret; return ret;
} }
@ -129,7 +129,7 @@ parse_string_to_keysym_vec(const char *str)
if (xk) if (xk)
keys.push_back(xk); keys.push_back(xk);
else else
spdlog::error("Unrecognized key: '{}'", ks); SPDLOG_ERROR("Unrecognized key: '{}'", ks);
} }
} }
return keys; return keys;
@ -170,7 +170,7 @@ parse_fps_limit(const char *str)
try { try {
as_int = static_cast<uint32_t>(std::stoul(value)); as_int = static_cast<uint32_t>(std::stoul(value));
} catch (const std::invalid_argument&) { } catch (const std::invalid_argument&) {
spdlog::error("invalid fps_limit value: '{}'", value); SPDLOG_ERROR("invalid fps_limit value: '{}'", value);
continue; continue;
} }
@ -320,17 +320,17 @@ parse_benchmark_percentiles(const char *str)
try { try {
as_float = parse_float(value, &float_len); as_float = parse_float(value, &float_len);
} catch (const std::invalid_argument&) { } catch (const std::invalid_argument&) {
spdlog::error("invalid benchmark percentile: '{}'", value); SPDLOG_ERROR("invalid benchmark percentile: '{}'", value);
continue; continue;
} }
if (float_len != value.length()) { if (float_len != value.length()) {
spdlog::error("invalid benchmark percentile: '{}'", value); SPDLOG_ERROR("invalid benchmark percentile: '{}'", value);
continue; continue;
} }
if (as_float > 100 || as_float < 0) { if (as_float > 100 || as_float < 0) {
spdlog::error("benchmark percentile is not between 0 and 100 ({})", value); SPDLOG_ERROR("benchmark percentile is not between 0 and 100 ({})", value);
continue; continue;
} }
@ -498,7 +498,7 @@ parse_string(const char *s, char *out_param, char *out_value)
} }
if (*s && !i) { if (*s && !i) {
spdlog::error("syntax error: unexpected '{0:c}' ({0:d}) while " SPDLOG_ERROR("syntax error: unexpected '{0:c}' ({0:d}) while "
"parsing a string", *s); "parsing a string", *s);
} }
@ -549,7 +549,7 @@ parse_overlay_env(struct overlay_params *params,
OVERLAY_PARAMS OVERLAY_PARAMS
#undef OVERLAY_PARAM_BOOL #undef OVERLAY_PARAM_BOOL
#undef OVERLAY_PARAM_CUSTOM #undef OVERLAY_PARAM_CUSTOM
spdlog::error("Unknown option '{}'", key); SPDLOG_ERROR("Unknown option '{}'", key);
} }
} }
@ -689,7 +689,7 @@ parse_overlay_config(struct overlay_params *params,
OVERLAY_PARAMS OVERLAY_PARAMS
#undef OVERLAY_PARAM_BOOL #undef OVERLAY_PARAM_BOOL
#undef OVERLAY_PARAM_CUSTOM #undef OVERLAY_PARAM_CUSTOM
spdlog::error("Unknown option '{}'", it.first.c_str()); SPDLOG_ERROR("Unknown option '{}'", it.first.c_str());
} }
} }

@ -17,7 +17,7 @@ bool init_x11() {
return true; return true;
if (!g_x11->IsLoaded()) { if (!g_x11->IsLoaded()) {
spdlog::error("X11 loader failed to load"); SPDLOG_ERROR("X11 loader failed to load");
failed = true; failed = true;
return false; return false;
} }
@ -35,7 +35,7 @@ bool init_x11() {
failed = !display; failed = !display;
if (failed) if (failed)
spdlog::error("XOpenDisplay failed to open display '{}'", displayid); SPDLOG_ERROR("XOpenDisplay failed to open display '{}'", displayid);
return !!display; return !!display;
} }

@ -208,7 +208,7 @@ static void unmap_object(uint64_t obj)
do { \ do { \
VkResult __result = (expr); \ VkResult __result = (expr); \
if (__result != VK_SUCCESS) { \ if (__result != VK_SUCCESS) { \
spdlog::error("'{}' line {} failed with {}", \ SPDLOG_ERROR("'{}' line {} failed with {}", \
#expr, __LINE__, vk_Result_to_str(__result)); \ #expr, __LINE__, vk_Result_to_str(__result)); \
} \ } \
} while (0) } while (0)
@ -709,7 +709,7 @@ static void check_fonts(struct swapchain_data* data)
if (params.font_params_hash != data->sw_stats.font_params_hash) if (params.font_params_hash != data->sw_stats.font_params_hash)
{ {
spdlog::debug("Recreating font image"); SPDLOG_DEBUG("Recreating font image");
VkDescriptorSet desc_set = (VkDescriptorSet)io.Fonts->TexID; VkDescriptorSet desc_set = (VkDescriptorSet)io.Fonts->TexID;
create_fonts(instance_data->params, data->sw_stats.font1, data->sw_stats.font_text); create_fonts(instance_data->params, data->sw_stats.font1, data->sw_stats.font_text);
unsigned char* pixels; unsigned char* pixels;
@ -728,7 +728,7 @@ static void check_fonts(struct swapchain_data* data)
io.Fonts->SetTexID((ImTextureID)desc_set); io.Fonts->SetTexID((ImTextureID)desc_set);
data->font_uploaded = false; data->font_uploaded = false;
data->sw_stats.font_params_hash = params.font_params_hash; data->sw_stats.font_params_hash = params.font_params_hash;
spdlog::debug("Default font tex size: {}x{}px", width, height); SPDLOG_DEBUG("Default font tex size: {}x{}px", width, height);
} }
} }

Loading…
Cancel
Save