Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no console logs for release builds #2201

Merged
merged 1 commit into from Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions 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 *
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
@@ -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
@@ -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
@@ -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