diff --git a/src/app/main.prerequisites.hpp b/src/app/main.prerequisites.hpp index 90a32f75d2..c88838c7a0 100644 --- a/src/app/main.prerequisites.hpp +++ b/src/app/main.prerequisites.hpp @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright © 2013-2021 The Komodo Platform Developers. * + * Copyright © 2013-2023 The Komodo Platform Developers. * * * * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * * the top-level directory of this distribution for the individual copyright * @@ -180,15 +180,15 @@ static void init_logging() auto rotating_sink = std::make_shared(path.string(), spdlog_max_file_size, spdlog_max_file_rotation); #endif +#if defined(DEBUG) || defined(_WIN32) || defined(WIN32) std::vector sinks{stdout_sink, rotating_sink}; +#else + std::vector sinks{rotating_sink}; +#endif auto logger = std::make_shared("log_mt", sinks.begin(), sinks.end(), tp, spdlog::async_overflow_policy::block); spdlog::register_logger(logger); spdlog::set_default_logger(logger); -#ifdef DEBUG spdlog::set_level(spdlog::level::trace); -#else - spdlog::set_level(spdlog::level::info); -#endif spdlog::set_pattern("[%T] [%^%l%$] [%s:%#] [%t]: %v"); } @@ -352,10 +352,10 @@ inline int run_app(int argc, char** argv) { #if !defined(ATOMICDEX_HOT_RELOAD) - SPDLOG_INFO("Installing qt_message_handler"); + SPDLOG_DEBUG("Installing qt_message_handler"); qInstallMessageHandler(&qt_message_handler); #endif - SPDLOG_INFO( + SPDLOG_DEBUG( "SSL: {} {} {}", QSslSocket::supportsSsl(), QSslSocket::sslLibraryBuildVersionString().toStdString(), QSslSocket::sslLibraryVersionString().toStdString()); diff --git a/src/core/atomicdex/utilities/kill.cpp b/src/core/atomicdex/utilities/kill.cpp index 55fa3c5221..b4b225b3fc 100644 --- a/src/core/atomicdex/utilities/kill.cpp +++ b/src/core/atomicdex/utilities/kill.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright © 2013-2021 The Komodo Platform Developers. * + * Copyright © 2013-2023 The Komodo Platform Developers. * * * * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * * the top-level directory of this distribution for the individual copyright * @@ -14,6 +14,9 @@ * * ******************************************************************************/ +#include +#include + //! PCH Headers #include "atomicdex/pch.hpp" @@ -26,11 +29,30 @@ namespace atomic_dex kill_executable(const char* exec_name) { #if defined(__APPLE__) || defined(__linux__) - std::string cmd_line = "killall " + std::string(exec_name); - std::system(cmd_line.c_str()); + std::string cmd_line_check = "pgrep " + std::string(exec_name); + std::string response = execute(cmd_line_check); + if (response != "") + { + std::string cmd_line = "killall " + std::string(exec_name); + std::string response = execute(cmd_line); + } #else std::string cmd_line = "taskkill /F /IM " + std::string(exec_name) + ".exe /T"; - std::system(cmd_line.c_str()); + std::string response = execute(cmd_line); #endif } + + std::string + execute(const std::string& command) + { + system((command + " > temp.txt").c_str()); + + std::ifstream ifs("temp.txt"); + std::string ret{ std::istreambuf_iterator(ifs), std::istreambuf_iterator() }; + ifs.close(); // must close the inout stream so the file can be cleaned up + if (std::remove("temp.txt") != 0) { + SPDLOG_DEBUG("Error deleting temporary file"); + } + return ret; + } } // namespace atomic_dex diff --git a/src/core/atomicdex/utilities/kill.hpp b/src/core/atomicdex/utilities/kill.hpp index 787013adbe..f295cb43b2 100644 --- a/src/core/atomicdex/utilities/kill.hpp +++ b/src/core/atomicdex/utilities/kill.hpp @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright © 2013-2021 The Komodo Platform Developers. * + * Copyright © 2013-2023 The Komodo Platform Developers. * * * * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * * the top-level directory of this distribution for the individual copyright * @@ -21,4 +21,5 @@ namespace atomic_dex { ENTT_API void kill_executable(const char* exec_name); + std::string execute(const std::string& command); } diff --git a/src/core/atomicdex/utilities/log.prerequisites.hpp b/src/core/atomicdex/utilities/log.prerequisites.hpp index c9d4db54e8..09fd2333ed 100644 --- a/src/core/atomicdex/utilities/log.prerequisites.hpp +++ b/src/core/atomicdex/utilities/log.prerequisites.hpp @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright © 2013-2021 The Komodo Platform Developers. * + * Copyright © 2013-2023 The Komodo Platform Developers. * * * * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * * the top-level directory of this distribution for the individual copyright *