diff --git a/meson.build b/meson.build index c45b3ea3..4d2ab478 100644 --- a/meson.build +++ b/meson.build @@ -25,8 +25,10 @@ pre_args = [ # Define DEBUG for debug builds only (debugoptimized is not included on this one) if get_option('buildtype') == 'debug' pre_args += '-DDEBUG' + pre_args += '-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE' else pre_args += '-DNDEBUG' + pre_args += '-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_' + get_option('loglevel').to_upper() endif # TODO: this is very incomplete diff --git a/meson_options.txt b/meson_options.txt index 6036bd27..302787c7 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -14,3 +14,4 @@ option('with_wayland', type : 'feature', value : 'disabled') option('with_dbus', type : 'feature', value : 'enabled') option('with_dlsym', type : 'feature', value : 'disabled') 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') diff --git a/src/battery.cpp b/src/battery.cpp index 9e3e0435..65fe93dd 100644 --- a/src/battery.cpp +++ b/src/battery.cpp @@ -27,7 +27,7 @@ void BatteryStats::update() { if (!batt_check) { numBattery(); if (batt_count == 0) { - spdlog::error("No battery found"); + SPDLOG_ERROR("No battery found"); } } diff --git a/src/config.cpp b/src/config.cpp index 25611422..c7a859b1 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -111,12 +111,12 @@ void parseConfigFile(overlay_params& params) { std::ifstream stream(*p); if (!stream.good()) { // 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; } stream.imbue(std::locale::classic()); - spdlog::info("parsing config: '{}'", *p); + SPDLOG_INFO("parsing config: '{}'", *p); while (std::getline(stream, line)) { parseConfigLine(line, params.options); diff --git a/src/cpu.cpp b/src/cpu.cpp index 86fa7a9d..e209fcea 100644 --- a/src/cpu.cpp +++ b/src/cpu.cpp @@ -117,13 +117,13 @@ bool CPUStats::Init() m_cpuData.clear(); if (!file.is_open()) { - spdlog::error("Failed to opening " PROCSTATFILE); + SPDLOG_ERROR("Failed to opening " PROCSTATFILE); return false; } do { if (!std::getline(file, line)) { - spdlog::debug("Failed to read all of " PROCSTATFILE); + SPDLOG_DEBUG("Failed to read all of " PROCSTATFILE); return false; } else if (starts_with(line, "cpu")) { if (first) { @@ -176,7 +176,7 @@ bool CPUStats::UpdateCPUData() bool ret = false; if (!file.is_open()) { - spdlog::error("Failed to opening " PROCSTATFILE); + SPDLOG_ERROR("Failed to opening " PROCSTATFILE); 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", &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) { - spdlog::debug("Failed to parse 'cpu' line:{}", line); + SPDLOG_DEBUG("Failed to parse 'cpu' line:{}", line); return false; } 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; } 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(); } @@ -399,7 +399,7 @@ static bool find_fallback_temp_input(const std::string path, std::string& input) if (!ends_with(file, "_input")) continue; input = path + "/" + file; - spdlog::debug("fallback cpu temp input: {}", input); + SPDLOG_DEBUG("fallback cpu temp input: {}", input); return true; } return false; @@ -416,7 +416,7 @@ bool CPUStats::GetCpuFile() { for (auto& dir : dirs) { path = hwmon + dir; name = read_line(path + "/name"); - spdlog::debug("hwmon: sensor name: {}", name); + SPDLOG_DEBUG("hwmon: sensor name: {}", name); if (name == "coretemp") { 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))) { - spdlog::error("Could not find cpu temp sensor location"); + SPDLOG_ERROR("Could not find cpu temp sensor location"); return false; } else { - spdlog::debug("hwmon: using input: {}", input); + SPDLOG_DEBUG("hwmon: using input: {}", input); m_cpuTempFile = fopen(input.c_str(), "r"); } 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, "curr", socCurrentInput, "Isoc")) return nullptr; - spdlog::debug("hwmon: using input: {}", coreVoltageInput); - spdlog::debug("hwmon: using input: {}", coreCurrentInput); - spdlog::debug("hwmon: using input: {}", socVoltageInput); - spdlog::debug("hwmon: using input: {}", socCurrentInput); + SPDLOG_DEBUG("hwmon: using input: {}", coreVoltageInput); + SPDLOG_DEBUG("hwmon: using input: {}", coreCurrentInput); + SPDLOG_DEBUG("hwmon: using input: {}", socVoltageInput); + SPDLOG_DEBUG("hwmon: using input: {}", socCurrentInput); powerData->coreVoltageFile = fopen(coreVoltageInput.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", socPowerInput, "SVI2_P_SoC")) return nullptr; - spdlog::debug("hwmon: using input: {}", corePowerInput); - spdlog::debug("hwmon: using input: {}", socPowerInput); + SPDLOG_DEBUG("hwmon: using input: {}", corePowerInput); + SPDLOG_DEBUG("hwmon: using input: {}", socPowerInput); powerData->corePowerFile = fopen(corePowerInput.c_str(), "r"); powerData->socPowerFile = fopen(socPowerInput.c_str(), "r"); @@ -530,7 +530,7 @@ bool CPUStats::InitCpuPowerData() { for (auto& dir : dirs) { path = hwmon + dir; name = read_line(path + "/name"); - spdlog::debug("hwmon: sensor name: {}", name); + SPDLOG_DEBUG("hwmon: sensor name: {}", name); if (name == "k10temp") { cpuPowerData = (CPUPowerData*)init_cpu_power_data_k10temp(path); @@ -547,7 +547,7 @@ bool CPUStats::InitCpuPowerData() { for (auto& dir : powercap_dirs) { path = powercap + dir; name = read_line(path + "/name"); - spdlog::debug("powercap: name: {}", name); + SPDLOG_DEBUG("powercap: name: {}", name); if (name == "package-0") { cpuPowerData = (CPUPowerData*)init_cpu_power_data_rapl(path); break; @@ -556,7 +556,7 @@ bool CPUStats::InitCpuPowerData() { } if(cpuPowerData == nullptr) { - spdlog::error("Failed to initialize CPU power data"); + SPDLOG_ERROR("Failed to initialize CPU power data"); return false; } diff --git a/src/dbus.cpp b/src/dbus.cpp index f1fc38be..b06dde2a 100644 --- a/src/dbus.cpp +++ b/src/dbus.cpp @@ -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")) { - spdlog::error("Could not load libdbus-1.so.3"); + SPDLOG_ERROR("Could not load libdbus-1.so.3"); return false; } @@ -173,12 +173,12 @@ bool dbus_manager::init(const std::string& requested_player) { if (nullptr == (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); 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)); dbus_list_name_to_owner(); @@ -197,7 +197,7 @@ bool dbus_manager::select_active_player() { // If the requested player is available, use it if (m_name_owners.count(m_requested_player) > 0) { 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); } } else { @@ -217,7 +217,7 @@ bool dbus_manager::select_active_player() { if(it != m_name_owners.end()){ 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); return true; } else { - spdlog::debug("No active players"); + SPDLOG_DEBUG("No active players"); if (!old_active_player.empty()) { onNoPlayer(); } @@ -325,7 +325,7 @@ void dbus_manager::connect_to_signals() { auto signal = format_signal(kv); m_dbus_ldr.bus_add_match(m_dbus_conn, signal.c_str(), &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); // return; } @@ -343,7 +343,7 @@ void dbus_manager::disconnect_from_signals() { auto signal = format_signal(kv); m_dbus_ldr.bus_remove_match(m_dbus_conn, signal.c_str(), &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); } } diff --git a/src/dbus_helpers.h b/src/dbus_helpers.h index b0191592..e60a74b6 100644 --- a/src/dbus_helpers.h +++ b/src/dbus_helpers.h @@ -137,7 +137,7 @@ template auto DBusMessageIter_wrap::get_primitive() -> T { auto requested_type = detail::dbus_type_identifier; if (requested_type != type()) { - spdlog::error("Type mismatch: '{}' vs '{}'", + SPDLOG_ERROR("Type mismatch: '{}' vs '{}'", ((char)requested_type), (char)type()); #ifndef NDEBUG exit(-1); @@ -191,13 +191,13 @@ auto DBusMessageIter_wrap::get_stringified() -> std::string { if (is_unsigned()) return std::to_string(get_unsigned()); if (is_signed()) return std::to_string(get_signed()); if (is_double()) return std::to_string(get_primitive()); - spdlog::error("stringify failed"); + SPDLOG_ERROR("stringify failed"); return std::string(); } auto DBusMessageIter_wrap::get_array_iter() -> DBusMessageIter_wrap { if (!is_array()) { - spdlog::error("Not an array; {}", (char)type()); + SPDLOG_ERROR("Not an array; {}", (char)type()); 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 { 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); } @@ -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, timeout, &err); if (reply == nullptr) { - spdlog::error("[{}]: {}", __func__, err.message); + SPDLOG_ERROR("[{}]: {}", __func__, err.message); free_if_owning(); m_DBus->error_free(&err); } diff --git a/src/file_utils.cpp b/src/file_utils.cpp index f3ef8a3f..7b88cc20 100644 --- a/src/file_utils.cpp +++ b/src/file_utils.cpp @@ -23,7 +23,7 @@ bool find_folder(const char* root, const char* prefix, std::string& dest) struct dirent* dp; DIR* dirp = opendir(root); if (!dirp) { - spdlog::error("Error opening directory '{}': {}", root, strerror(errno)); + SPDLOG_ERROR("Error opening directory '{}': {}", root, strerror(errno)); return false; } @@ -52,7 +52,7 @@ std::vector ls(const char* root, const char* prefix, LS_FLAGS flags DIR* dirp = opendir(root); if (!dirp) { - spdlog::error("Error opening directory '{}': {}", root, strerror(errno)); + SPDLOG_ERROR("Error opening directory '{}': {}", root, strerror(errno)); return list; } diff --git a/src/gl/imgui_impl_opengl3.cpp b/src/gl/imgui_impl_opengl3.cpp index ee94964e..36523097 100644 --- a/src/gl/imgui_impl_opengl3.cpp +++ b/src/gl/imgui_impl_opengl3.cpp @@ -139,13 +139,13 @@ static bool CheckShader(GLuint handle, const char* desc) glGetShaderiv(handle, GL_COMPILE_STATUS, &status); glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &log_length); 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) { ImVector buf; buf.resize((int)(log_length + 1)); glGetShaderInfoLog(handle, log_length, NULL, (GLchar*)buf.begin()); - spdlog::error("{}", buf.begin()); + SPDLOG_ERROR("{}", buf.begin()); } 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_INFO_LOG_LENGTH, &log_length); 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) { ImVector buf; buf.resize((int)(log_length + 1)); glGetProgramInfoLog(handle, log_length, NULL, (GLchar*)buf.begin()); - spdlog::error("{}", buf.begin()); + SPDLOG_ERROR("{}", buf.begin()); } return (GLboolean)status == GL_TRUE; } @@ -479,12 +479,12 @@ void ImGui_ImplOpenGL3_NewFrame() if (!g_ShaderHandle) ImGui_ImplOpenGL3_CreateDeviceObjects(); 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(); } if (!glIsTexture(g_FontTexture)) { - spdlog::debug("GL Texture lost? Regenerating."); + SPDLOG_DEBUG("GL Texture lost? Regenerating."); g_FontTexture = 0; ImGui_ImplOpenGL3_CreateFontsTexture(); } diff --git a/src/gl/inject_egl.cpp b/src/gl/inject_egl.cpp index 5d7268cb..6499d10c 100644 --- a/src/gl/inject_egl.cpp +++ b/src/gl/inject_egl.cpp @@ -22,7 +22,7 @@ void* get_egl_proc_address(const char* name) { if (!pfn_eglGetProcAddress) { void *handle = real_dlopen("libEGL.so.1", RTLD_LAZY|RTLD_LOCAL); 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 { pfn_eglGetProcAddress = reinterpret_cast(real_dlsym(handle, "eglGetProcAddress")); } @@ -35,7 +35,7 @@ void* get_egl_proc_address(const char* name) { func = get_proc_address( name ); if (!func) { - spdlog::debug("Failed to get function '{}'", name); + SPDLOG_DEBUG("Failed to get function '{}'", name); } return func; @@ -43,7 +43,7 @@ void* get_egl_proc_address(const char* name) { //EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext 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; return ret; } @@ -105,7 +105,7 @@ EXPORT_C_(void *) mangohud_find_egl_ptr(const char *name) EXPORT_C_(void *) eglGetProcAddress(const char* procName) { void* real_func = get_egl_proc_address(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) return func; diff --git a/src/gl/inject_glx.cpp b/src/gl/inject_glx.cpp index 47e8a3ff..e56fc157 100644 --- a/src/gl/inject_glx.cpp +++ b/src/gl/inject_glx.cpp @@ -48,7 +48,7 @@ void* get_glx_proc_address(const char* name) { func = get_proc_address( name ); if (!func) { - spdlog::error("Failed to get function '{}'", name); + SPDLOG_ERROR("Failed to get function '{}'", name); } 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); if (ctx) refcnt++; - spdlog::debug("{}: {}", __func__, ctx); + SPDLOG_DEBUG("{}: {}", __func__, 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); if (ctx) refcnt++; - spdlog::debug("{}: {}", __func__, ctx); + SPDLOG_DEBUG("{}: {}", __func__, 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); if (ctx) refcnt++; - spdlog::debug("{}: {}", __func__, ctx); + SPDLOG_DEBUG("{}: {}", __func__, ctx); return ctx; } @@ -91,18 +91,18 @@ EXPORT_C_(void) glXDestroyContext(void *dpy, void *ctx) refcnt--; if (refcnt <= 0) imgui_shutdown(); - spdlog::debug("{}: {}", __func__, ctx); + SPDLOG_DEBUG("{}: {}", __func__, ctx); } EXPORT_C_(int) glXMakeCurrent(void* dpy, void* drawable, void* ctx) { glx.Load(); - spdlog::debug("{}: {}, {}", __func__, drawable, ctx); + SPDLOG_DEBUG("{}: {}, {}", __func__, drawable, ctx); int ret = glx.MakeCurrent(dpy, drawable, ctx); if (!is_blacklisted()) { if (ret) { 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 @@ -147,7 +147,7 @@ static void do_imgui_swap(void *dpy, void *drawable) break; } - spdlog::trace("swap buffers: {}x{}", width, height); + SPDLOG_TRACE("swap buffers: {}x{}", 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) { - spdlog::debug("{}: {}", __func__, interval); + SPDLOG_DEBUG("{}: {}", __func__, interval); glx.Load(); if (!glx.SwapIntervalEXT) return; @@ -197,7 +197,7 @@ EXPORT_C_(void) glXSwapIntervalEXT(void *dpy, void *draw, int interval) { } EXPORT_C_(int) glXSwapIntervalSGI(int interval) { - spdlog::debug("{}: {}", __func__, interval); + SPDLOG_DEBUG("{}: {}", __func__, interval); glx.Load(); if (!glx.SwapIntervalSGI) return -1; @@ -209,7 +209,7 @@ EXPORT_C_(int) glXSwapIntervalSGI(int interval) { } EXPORT_C_(int) glXSwapIntervalMESA(unsigned int interval) { - spdlog::debug("{}: {}", __func__, interval); + SPDLOG_DEBUG("{}: {}", __func__, interval); glx.Load(); if (!glx.SwapIntervalMESA) return -1; @@ -239,7 +239,7 @@ EXPORT_C_(int) glXGetSwapIntervalMESA() { } } - spdlog::debug("{}: {}", __func__, interval); + SPDLOG_DEBUG("{}: {}", __func__, 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) { void *real_func = get_glx_proc_address((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) return func; @@ -294,7 +294,7 @@ EXPORT_C_(void *) glXGetProcAddress(const unsigned char* procName) { EXPORT_C_(void *) glXGetProcAddressARB(const unsigned char* procName) { void *real_func = get_glx_proc_address((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) return func; diff --git a/src/gpu.cpp b/src/gpu.cpp index 776d5518..bddefd6a 100644 --- a/src/gpu.cpp +++ b/src/gpu.cpp @@ -191,7 +191,7 @@ struct amdgpu_handles period = 10000000; /* 10ms */ ticks = ticks_per_sec * std::chrono::nanoseconds(period) / 1s; 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() @@ -234,20 +234,20 @@ bool amdgpu_open(const char *path) { int fd = open(path, O_RDWR | O_CLOEXEC); if (fd < 0) { - spdlog::error("Failed to open DRM device: {}", strerror(errno)); + SPDLOG_ERROR("Failed to open DRM device: {}", strerror(errno)); return false; } drmVersionPtr ver = libdrm_ptr->drmGetVersion(fd); if (!ver) { - spdlog::error("Failed to query driver version: {}", strerror(errno)); + SPDLOG_ERROR("Failed to query driver version: {}", strerror(errno)); close(fd); return false; } 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); libdrm_ptr->drmFreeVersion(ver); return false; @@ -264,7 +264,7 @@ bool amdgpu_open(const char *path) { uint32_t drm_major, drm_minor; amdgpu_device_handle 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); return false; } diff --git a/src/loaders/loader_dbus.cpp b/src/loaders/loader_dbus.cpp index b91b21aa..313b585f 100644 --- a/src/loaders/loader_dbus.cpp +++ b/src/loaders/loader_dbus.cpp @@ -27,7 +27,7 @@ bool libdbus_loader::Load(const std::string& library_name) { #if defined(LIBRARY_LOADER_DBUS_H_DLOPEN) library_ = dlopen(library_name.c_str(), RTLD_LAZY); if (!library_) { - spdlog::error("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror()); + SPDLOG_ERROR("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror()); return false; } diff --git a/src/loaders/loader_glx.cpp b/src/loaders/loader_glx.cpp index ca22f636..aa453b8d 100644 --- a/src/loaders/loader_glx.cpp +++ b/src/loaders/loader_glx.cpp @@ -25,7 +25,7 @@ bool glx_loader::Load() { if (!handle) handle = real_dlopen("libGL.so.1", RTLD_LAZY); 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; } diff --git a/src/loaders/loader_libdrm.cpp b/src/loaders/loader_libdrm.cpp index 3f0a8247..595104d2 100644 --- a/src/loaders/loader_libdrm.cpp +++ b/src/loaders/loader_libdrm.cpp @@ -28,13 +28,13 @@ bool libdrm_loader::Load() { #if defined(LIBRARY_LOADER_LIBDRM_H_DLOPEN) library_drm = dlopen("libdrm.so.2", RTLD_LAZY); 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; } library_amdgpu = dlopen("libdrm_amdgpu.so.1", RTLD_LAZY); 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); return false; } diff --git a/src/loaders/loader_nvctrl.cpp b/src/loaders/loader_nvctrl.cpp index a3e91155..5e14a12c 100644 --- a/src/loaders/loader_nvctrl.cpp +++ b/src/loaders/loader_nvctrl.cpp @@ -36,7 +36,7 @@ bool libnvctrl_loader::Load(const std::string& library_name) { #if defined(LIBRARY_LOADER_NVCTRL_H_DLOPEN) library_ = dlopen(library_name.c_str(), RTLD_LAZY); if (!library_) { - spdlog::error("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror()); + SPDLOG_ERROR("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror()); return false; } diff --git a/src/loaders/loader_nvml.cpp b/src/loaders/loader_nvml.cpp index 7d2c93c2..5ec66134 100644 --- a/src/loaders/loader_nvml.cpp +++ b/src/loaders/loader_nvml.cpp @@ -39,7 +39,7 @@ bool libnvml_loader::Load(const std::string& library_name) { #if defined(LIBRARY_LOADER_NVML_H_DLOPEN) library_ = dlopen(library_name.c_str(), RTLD_LAZY); if (!library_) { - spdlog::error("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror()); + SPDLOG_ERROR("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror()); return false; } #endif diff --git a/src/loaders/loader_x11.cpp b/src/loaders/loader_x11.cpp index 93ea05a4..4db6f78e 100644 --- a/src/loaders/loader_x11.cpp +++ b/src/loaders/loader_x11.cpp @@ -16,7 +16,7 @@ bool libx11_loader::Load(const std::string& library_name) { library_ = dlopen(library_name.c_str(), RTLD_LAZY); if (!library_) { - spdlog::error("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror()); + SPDLOG_ERROR("Failed to open " MANGOHUD_ARCH " {}: {}", library_name, dlerror()); return false; } diff --git a/src/logging.cpp b/src/logging.cpp index 05b2d641..4afa84cb 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -59,7 +59,7 @@ void upload_files(const std::vector& logFiles){ void writeFile(string filename){ 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); if (out){ out << "os," << "cpu," << "gpu," << "ram," << "kernel," << "driver," << "cpuscheduler" << endl; @@ -109,7 +109,7 @@ Logger::Logger(overlay_params* in_params) m_values_valid(false), m_params(in_params) { - spdlog::debug("Logger constructed!"); + SPDLOG_DEBUG("Logger constructed!"); } void Logger::start_logging() { diff --git a/src/notify.cpp b/src/notify.cpp index 27ac8f33..72c189a8 100644 --- a/src/notify.cpp +++ b/src/notify.cpp @@ -28,7 +28,7 @@ static void fileChanged(void *params_void) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); parse_overlay_config(&local_params, getenv("MANGOHUD_CONFIG")); 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); 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); if (nt.fd < 0) { - spdlog::error("inotify_init1 failed: {}", strerror(errno)); + SPDLOG_ERROR("inotify_init1 failed: {}", strerror(errno)); return false; } diff --git a/src/nvctrl.cpp b/src/nvctrl.cpp index 185a118b..daedd80d 100644 --- a/src/nvctrl.cpp +++ b/src/nvctrl.cpp @@ -26,7 +26,7 @@ static bool find_nv_x11(libnvctrl_loader& nvctrl, Display*& dpy) if (d) { if (nvctrl.XNVCTRLIsNvScreen(d, 0)) { dpy = d; - spdlog::debug("XNVCtrl is using display {}", buf); + SPDLOG_DEBUG("XNVCtrl is using display {}", buf); return true; } g_x11->XCloseDisplay(d); @@ -42,7 +42,7 @@ bool checkXNVCtrl() auto& nvctrl = get_libnvctrl_loader(); if (!nvctrl.IsLoaded()) { - spdlog::error("XNVCtrl loader failed to load"); + SPDLOG_ERROR("XNVCtrl loader failed to load"); return false; } @@ -50,7 +50,7 @@ bool checkXNVCtrl() nvctrlSuccess = find_nv_x11(nvctrl, dpy); if (!nvctrlSuccess) { - spdlog::error("XNVCtrl didn't find the correct display"); + SPDLOG_ERROR("XNVCtrl didn't find the correct display"); 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* c = nullptr; 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; } diff --git a/src/nvml.cpp b/src/nvml.cpp index 5e4ef7b8..d5848fe1 100644 --- a/src/nvml.cpp +++ b/src/nvml.cpp @@ -17,19 +17,19 @@ bool checkNVML(const char* pciBusId){ if (nvml.IsLoaded()){ result = nvml.nvmlInit(); if (NVML_SUCCESS != result) { - spdlog::error("Nvidia module not loaded"); + SPDLOG_ERROR("Nvidia module not loaded"); } else { nvmlReturn_t ret = NVML_ERROR_UNKNOWN; if (pciBusId && ((ret = nvml.nvmlDeviceGetHandleByPciBusId(pciBusId, &nvidiaDevice)) != NVML_SUCCESS)) { - spdlog::error("Getting device handle by PCI bus ID failed: {}", nvml.nvmlErrorString(ret)); - spdlog::error("Using index 0."); + SPDLOG_ERROR("Getting device handle by PCI bus ID failed: {}", nvml.nvmlErrorString(ret)); + SPDLOG_ERROR("Using index 0."); } if (ret != NVML_SUCCESS) ret = nvml.nvmlDeviceGetHandleByIndex(0, &nvidiaDevice); 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); if (ret == NVML_SUCCESS) @@ -38,7 +38,7 @@ bool checkNVML(const char* pciBusId){ return nvmlSuccess; } } else { - spdlog::error("Failed to load NVML"); + SPDLOG_ERROR("Failed to load NVML"); } return false; diff --git a/src/overlay.cpp b/src/overlay.cpp index 6055fe9d..427defaf 100644 --- a/src/overlay.cpp +++ b/src/overlay.cpp @@ -518,10 +518,10 @@ void init_gpu_stats(uint32_t& vendorID, overlay_params& params) << std::setw(1) << pci.func; params.pci_dev = ss.str(); pci_dev = params.pci_dev.c_str(); - spdlog::debug("PCI device ID: '{}'", pci_dev); + SPDLOG_DEBUG("PCI device ID: '{}'", pci_dev); } else { - spdlog::error("Failed to parse PCI device ID: '{}'", pci_dev); - spdlog::error("Specify it as 'domain:bus:slot.func'"); + SPDLOG_ERROR("Failed to parse PCI device ID: '{}'", pci_dev); + 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) { 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"); 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) { 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)) { - spdlog::debug("skipping GPU, no PCI ID match"); + SPDLOG_DEBUG("skipping GPU, no PCI ID match"); continue; } } - spdlog::debug("using amdgpu path: {}", path); + SPDLOG_DEBUG("using amdgpu path: {}", path); #ifdef HAVE_LIBDRM_AMDGPU int idx = -1; @@ -580,11 +580,11 @@ void init_gpu_stats(uint32_t& vendorID, overlay_params& params) getAmdGpuInfo_actual = getAmdGpuInfo_libdrm; 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 } 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 @@ -620,7 +620,7 @@ void init_gpu_stats(uint32_t& vendorID, overlay_params& params) } #endif if (!params.permit_upload) - spdlog::info("Uploading is disabled (permit_upload = 0)"); + SPDLOG_INFO("Uploading is disabled (permit_upload = 0)"); } void init_system_info(){ @@ -714,13 +714,13 @@ void init_system_info(){ if (ld_preload) setenv("LD_PRELOAD", ld_preload, 1); - spdlog::debug("Ram:{}", ram); - spdlog::debug("Cpu:{}", cpu); - spdlog::debug("Kernel:{}", kernel); - spdlog::debug("Os:{}", os); - spdlog::debug("Gpu:{}", gpu); - spdlog::debug("Driver:{}", driver); - spdlog::debug("CPU Scheduler:{}", cpusched); + SPDLOG_DEBUG("Ram:{}", ram); + SPDLOG_DEBUG("Cpu:{}", cpu); + SPDLOG_DEBUG("Kernel:{}", kernel); + SPDLOG_DEBUG("Os:{}", os); + SPDLOG_DEBUG("Gpu:{}", gpu); + SPDLOG_DEBUG("Driver:{}", driver); + SPDLOG_DEBUG("CPU Scheduler:{}", cpusched); #endif } diff --git a/src/overlay_params.cpp b/src/overlay_params.cpp index 8949cdfb..eaf43e8a 100644 --- a/src/overlay_params.cpp +++ b/src/overlay_params.cpp @@ -95,8 +95,8 @@ parse_control(const char *str) { int ret = os_socket_listen_abstract(str, 1); if (ret < 0) { - spdlog::error("Couldn't create socket pipe at '{}'\n", str); - spdlog::error("ERROR: '{}'", strerror(errno)); + SPDLOG_ERROR("Couldn't create socket pipe at '{}'\n", str); + SPDLOG_ERROR("ERROR: '{}'", strerror(errno)); return ret; } @@ -129,7 +129,7 @@ parse_string_to_keysym_vec(const char *str) if (xk) keys.push_back(xk); else - spdlog::error("Unrecognized key: '{}'", ks); + SPDLOG_ERROR("Unrecognized key: '{}'", ks); } } return keys; @@ -170,7 +170,7 @@ parse_fps_limit(const char *str) try { as_int = static_cast(std::stoul(value)); } catch (const std::invalid_argument&) { - spdlog::error("invalid fps_limit value: '{}'", value); + SPDLOG_ERROR("invalid fps_limit value: '{}'", value); continue; } @@ -320,17 +320,17 @@ parse_benchmark_percentiles(const char *str) try { as_float = parse_float(value, &float_len); } catch (const std::invalid_argument&) { - spdlog::error("invalid benchmark percentile: '{}'", value); + SPDLOG_ERROR("invalid benchmark percentile: '{}'", value); continue; } if (float_len != value.length()) { - spdlog::error("invalid benchmark percentile: '{}'", value); + SPDLOG_ERROR("invalid benchmark percentile: '{}'", value); continue; } 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; } @@ -498,7 +498,7 @@ parse_string(const char *s, char *out_param, char *out_value) } 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); } @@ -549,7 +549,7 @@ parse_overlay_env(struct overlay_params *params, OVERLAY_PARAMS #undef OVERLAY_PARAM_BOOL #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 #undef OVERLAY_PARAM_BOOL #undef OVERLAY_PARAM_CUSTOM - spdlog::error("Unknown option '{}'", it.first.c_str()); + SPDLOG_ERROR("Unknown option '{}'", it.first.c_str()); } } diff --git a/src/shared_x11.cpp b/src/shared_x11.cpp index 48760709..ec2b25c5 100644 --- a/src/shared_x11.cpp +++ b/src/shared_x11.cpp @@ -17,7 +17,7 @@ bool init_x11() { return true; if (!g_x11->IsLoaded()) { - spdlog::error("X11 loader failed to load"); + SPDLOG_ERROR("X11 loader failed to load"); failed = true; return false; } @@ -35,7 +35,7 @@ bool init_x11() { failed = !display; if (failed) - spdlog::error("XOpenDisplay failed to open display '{}'", displayid); + SPDLOG_ERROR("XOpenDisplay failed to open display '{}'", displayid); return !!display; } diff --git a/src/vulkan.cpp b/src/vulkan.cpp index 2d13982d..c0784289 100644 --- a/src/vulkan.cpp +++ b/src/vulkan.cpp @@ -208,7 +208,7 @@ static void unmap_object(uint64_t obj) do { \ VkResult __result = (expr); \ if (__result != VK_SUCCESS) { \ - spdlog::error("'{}' line {} failed with {}", \ + SPDLOG_ERROR("'{}' line {} failed with {}", \ #expr, __LINE__, vk_Result_to_str(__result)); \ } \ } 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) { - spdlog::debug("Recreating font image"); + SPDLOG_DEBUG("Recreating font image"); VkDescriptorSet desc_set = (VkDescriptorSet)io.Fonts->TexID; create_fonts(instance_data->params, data->sw_stats.font1, data->sw_stats.font_text); unsigned char* pixels; @@ -728,7 +728,7 @@ static void check_fonts(struct swapchain_data* data) io.Fonts->SetTexID((ImTextureID)desc_set); data->font_uploaded = false; 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); } }