diff options
author | saturneric <[email protected]> | 2024-07-29 19:29:56 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-07-29 19:29:56 +0000 |
commit | fa90ec4b5315b9e70a44a9625c143ce253f0e885 (patch) | |
tree | 8ffa82e33522de03974d6d0289aa831b4fd6ebdf /src/cmd.cpp | |
parent | fix: correct urls at appdata.xml (diff) | |
parent | Merge branch 'develop' of github.com:saturneric/GpgFrontend into develop (diff) | |
download | GpgFrontend-fa90ec4b5315b9e70a44a9625c143ce253f0e885.tar.gz GpgFrontend-fa90ec4b5315b9e70a44a9625c143ce253f0e885.zip |
Merge branch 'develop'
Diffstat (limited to 'src/cmd.cpp')
-rw-r--r-- | src/cmd.cpp | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/src/cmd.cpp b/src/cmd.cpp index d41b6de0..06222431 100644 --- a/src/cmd.cpp +++ b/src/cmd.cpp @@ -28,13 +28,16 @@ #include "cmd.h" -#include "core/utils/BuildInfoUtils.h" -#include "main.h" +#include <qdatetime.h> +#include <qglobal.h> +#include <qloggingcategory.h> +#include <qstring.h> +#include <qtextstream.h> -// std -#include <iostream> +#include "core/utils/BuildInfoUtils.h" // GpgFrontend + #include "GpgFrontendContext.h" #include "test/GpgFrontendTest.h" @@ -42,7 +45,7 @@ namespace GpgFrontend { auto PrintVersion() -> int { QTextStream stream(stdout); - stream << PROJECT_NAME << " " << GetProjectVersion() << '\n'; + stream << GetProjectName() << " " << GetProjectVersion() << '\n'; stream << "Copyright (©) 2021 Saturneric <[email protected]>" << '\n' << QCoreApplication::tr( "This is free software; see the source for copying conditions.") @@ -60,30 +63,29 @@ auto PrintVersion() -> int { return 0; } -auto ParseLogLevel(const QString& log_level) -> spdlog::level::level_enum { - if (log_level == "trace") { - return spdlog::level::trace; - } +auto ParseLogLevel(const QString& log_level) -> int { if (log_level == "debug") { - return spdlog::level::debug; - } - if (log_level == "info") { - return spdlog::level::info; + QLoggingCategory::setFilterRules( + "core.debug=true\nui.debug=true\ntest.debug=true\nmodule.debug=true"); + } else if (log_level == "info") { + QLoggingCategory::setFilterRules( + "*.debug=false\ncore.info=true\nui.info=true\ntest.info=" + "true\nmodule.info=true"); + } else if (log_level == "warning") { + QLoggingCategory::setFilterRules("*.debug=false\n*.info=false\n"); + } else if (log_level == "critical") { + QLoggingCategory::setFilterRules( + "*.debug=false\n*.info=false\n*.warning=false\n"); + } else { + qWarning() << "unknown log level: " << log_level; } - if (log_level == "warn") { - return spdlog::level::warn; - } - if (log_level == "error") { - return spdlog::level::err; - } - - return spdlog::level::info; + return 0; } auto RunTest(const GFCxtWPtr& p_ctx) -> int { GpgFrontend::GFCxtSPtr const ctx = p_ctx.lock(); if (ctx == nullptr) { - GF_MAIN_LOG_ERROR("cannot get gpgfrontend context for test running"); + qWarning("cannot get gpgfrontend context for test running"); return -1; } |