Skip to content

Commit

Permalink
Merge pull request #2201 from KomodoPlatform/no_syslog_for_release
Browse files Browse the repository at this point in the history
no console logs for release builds
  • Loading branch information
tonymorony authored Feb 13, 2023
2 parents bd59e40 + a431369 commit 08f4975
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/app/main.prerequisites.hpp
Original file line number Diff line number Diff line change
@@ -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 *
Expand Down Expand Up @@ -180,15 +180,15 @@ static void init_logging()
auto rotating_sink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>(path.string(), spdlog_max_file_size, spdlog_max_file_rotation);
#endif

#if defined(DEBUG) || defined(_WIN32) || defined(WIN32)
std::vector<spdlog::sink_ptr> sinks{stdout_sink, rotating_sink};
#else
std::vector<spdlog::sink_ptr> sinks{rotating_sink};
#endif
auto logger = std::make_shared<spdlog::async_logger>("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");
}

Expand Down Expand Up @@ -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());

Expand Down
30 changes: 26 additions & 4 deletions src/core/atomicdex/utilities/kill.cpp
Original file line number Diff line number Diff line change
@@ -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 *
Expand All @@ -14,6 +14,9 @@
* *
******************************************************************************/

#include <fstream>
#include <iostream>

//! PCH Headers
#include "atomicdex/pch.hpp"

Expand All @@ -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<char>(ifs), std::istreambuf_iterator<char>() };
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
3 changes: 2 additions & 1 deletion src/core/atomicdex/utilities/kill.hpp
Original file line number Diff line number Diff line change
@@ -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 *
Expand All @@ -21,4 +21,5 @@
namespace atomic_dex
{
ENTT_API void kill_executable(const char* exec_name);
std::string execute(const std::string& command);
}
2 changes: 1 addition & 1 deletion src/core/atomicdex/utilities/log.prerequisites.hpp
Original file line number Diff line number Diff line change
@@ -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 *
Expand Down

0 comments on commit 08f4975

Please sign in to comment.