From 37a62a8d0b590710b902376ca3320cc05e954b63 Mon Sep 17 00:00:00 2001 From: saturneric Date: Fri, 26 Jul 2024 18:24:34 +0200 Subject: feat: remove spdlog and clean up log --- src/core/function/gpg/GpgAdvancedOperator.cpp | 62 ++++++++++----------------- 1 file changed, 23 insertions(+), 39 deletions(-) (limited to 'src/core/function/gpg/GpgAdvancedOperator.cpp') diff --git a/src/core/function/gpg/GpgAdvancedOperator.cpp b/src/core/function/gpg/GpgAdvancedOperator.cpp index cb8fec00..18b38460 100644 --- a/src/core/function/gpg/GpgAdvancedOperator.cpp +++ b/src/core/function/gpg/GpgAdvancedOperator.cpp @@ -39,10 +39,9 @@ void GpgFrontend::GpgAdvancedOperator::ClearGpgPasswordCache( OperationCallback cb) { const auto gpgconf_path = Module::RetrieveRTValueTypedOrDefault<>( "core", "gpgme.ctx.gpgconf_path", QString{}); - GF_CORE_LOG_DEBUG("got gpgconf path from rt: {}", gpgconf_path); if (gpgconf_path.isEmpty()) { - GF_CORE_LOG_ERROR("cannot get valid gpgconf path from rt, abort."); + qCWarning(core, "cannot get valid gpgconf path from rt, abort."); cb(-1, TransferParams()); return; } @@ -51,7 +50,6 @@ void GpgFrontend::GpgAdvancedOperator::ClearGpgPasswordCache( {gpgconf_path, QStringList{"--reload", "gpg-agent"}, [=](int exit_code, const QString & /*p_out*/, const QString & /*p_err*/) { - GF_CORE_LOG_DEBUG("gpgconf reload exit code: {}", exit_code); cb(exit_code == 0 ? 0 : -1, TransferParams()); }}); } @@ -60,10 +58,9 @@ void GpgFrontend::GpgAdvancedOperator::ReloadGpgComponents( OperationCallback cb) { const auto gpgconf_path = Module::RetrieveRTValueTypedOrDefault<>( "core", "gpgme.ctx.gpgconf_path", QString{}); - GF_CORE_LOG_DEBUG("got gpgconf path from rt: {}", gpgconf_path); if (gpgconf_path.isEmpty()) { - GF_CORE_LOG_ERROR("cannot get valid gpgconf path from rt, abort."); + qCWarning(core, "cannot get valid gpgconf path from rt, abort."); cb(-1, TransferParams()); return; } @@ -71,7 +68,7 @@ void GpgFrontend::GpgAdvancedOperator::ReloadGpgComponents( GpgFrontend::GpgCommandExecutor::ExecuteSync( {gpgconf_path, QStringList{"--reload"}, [=](int exit_code, const QString &, const QString &) { - GF_CORE_LOG_DEBUG("gpgconf reload exit code: {}", exit_code); + qCDebug(core, "gpgconf reload exit code: %d", exit_code); cb(exit_code == 0 ? 0 : -1, TransferParams()); }}); } @@ -79,59 +76,53 @@ void GpgFrontend::GpgAdvancedOperator::ReloadGpgComponents( void GpgFrontend::GpgAdvancedOperator::KillAllGpgComponents() { const auto gpgconf_path = Module::RetrieveRTValueTypedOrDefault<>( "core", "gpgme.ctx.gpgconf_path", QString{}); - GF_CORE_LOG_DEBUG("got gpgconf path from rt: {}", gpgconf_path); if (gpgconf_path.isEmpty()) { - GF_CORE_LOG_ERROR("cannot get valid gpgconf path from rt, abort."); + qCWarning(core, "cannot get valid gpgconf path from rt, abort."); return; } GpgFrontend::GpgCommandExecutor::ExecuteSync( {gpgconf_path, QStringList{"--verbose", "--kill", "all"}, [=](int exit_code, const QString &p_out, const QString &p_err) { - GF_CORE_LOG_DEBUG("gpgconf --kill all command got exit code: {}", - exit_code); bool success = true; if (exit_code != 0) { success = false; - GF_CORE_LOG_ERROR( - "gpgconf execute error, process stderr: {}, process stdout: {}", - p_err, p_out); + qCWarning(core) << "gpgconf execute error, process stderr: " << p_err + << ", process stdout: " << p_out; return; } - GF_CORE_LOG_DEBUG("gpgconf --kill --all execute result: {}", success); + qCDebug(core, "gpgconf --kill --all execute result: %d", success); }}); } void GpgFrontend::GpgAdvancedOperator::RestartGpgComponents() { const auto gpgconf_path = Module::RetrieveRTValueTypedOrDefault<>( "core", "gpgme.ctx.gpgconf_path", QString{}); - GF_CORE_LOG_DEBUG("got gpgconf path from rt: {}", gpgconf_path); if (gpgconf_path.isEmpty()) { - GF_CORE_LOG_ERROR("cannot get valid gpgconf path from rt, abort."); + qCWarning(core, "cannot get valid gpgconf path from rt, abort."); return; } GpgFrontend::GpgCommandExecutor::ExecuteSync( {gpgconf_path, QStringList{"--verbose", "--kill", "all"}, [=](int exit_code, const QString &p_out, const QString &p_err) { - GF_CORE_LOG_DEBUG("gpgconf --kill all command got exit code: {}", - exit_code); + qCDebug(core, "gpgconf --kill all command got exit code: %d", + exit_code); bool success = true; if (exit_code != 0) { success = false; - GF_CORE_LOG_ERROR( - "gpgconf execute error, process stderr: {}, process stdout: {}", - p_err, p_out); + qCWarning(core) << "gpgconf execute error, process stderr: " << p_err + << ", process stdout: " << p_out; return; } - GF_CORE_LOG_DEBUG("gpgconf --kill --all execute result: {}", success); + qCDebug(core, "gpgconf --kill --all execute result: %d", success); if (!success) { - GF_CORE_LOG_ERROR( - "restart all component after core initilized failed"); + qCWarning(core, + "restart all component after core initilized failed"); Module::UpsertRTValue( "core", "gpg_advanced_operator.restart_gpg_components", false); return; @@ -150,10 +141,9 @@ void GpgFrontend::GpgAdvancedOperator::RestartGpgComponents() { void GpgFrontend::GpgAdvancedOperator::ResetConfigures(OperationCallback cb) { const auto gpgconf_path = Module::RetrieveRTValueTypedOrDefault<>( "core", "gpgme.ctx.gpgconf_path", QString{}); - GF_CORE_LOG_DEBUG("got gpgconf path from rt: {}", gpgconf_path); if (gpgconf_path.isEmpty()) { - GF_CORE_LOG_ERROR("cannot get valid gpgconf path from rt, abort."); + qCWarning(core, "cannot get valid gpgconf path from rt, abort."); cb(-1, TransferParams()); return; } @@ -161,7 +151,7 @@ void GpgFrontend::GpgAdvancedOperator::ResetConfigures(OperationCallback cb) { GpgFrontend::GpgCommandExecutor::ExecuteSync( {gpgconf_path, QStringList{"--apply-defaults"}, [=](int exit_code, const QString &, const QString &) { - GF_CORE_LOG_DEBUG("gpgconf apply-defaults exit code: {}", exit_code); + qCDebug(core, "gpgconf apply-defaults exit code: %d", exit_code); cb(exit_code == 0 ? 0 : -1, TransferParams()); }}); } @@ -174,14 +164,12 @@ void GpgFrontend::GpgAdvancedOperator::StartGpgAgent(OperationCallback cb) { const auto gpg_agent_path = Module::RetrieveRTValueTypedOrDefault<>( kGnuPGInfoGatheringModuleID, "gnupg.gpg_agent_path", QString{}); - GF_CORE_LOG_DEBUG("got gnupg agent path from rt: {}", gpg_agent_path); const auto home_path = Module::RetrieveRTValueTypedOrDefault<>( kGnuPGInfoGatheringModuleID, "gnupg.home_path", QString{}); - GF_CORE_LOG_DEBUG("got gnupg home path from rt: {}", home_path); if (gpg_agent_path.isEmpty()) { - GF_CORE_LOG_ERROR("cannot get valid gpg agent path from rt, abort."); + qCWarning(core, "cannot get valid gpg agent path from rt, abort."); cb(-1, TransferParams()); return; } @@ -189,7 +177,7 @@ void GpgFrontend::GpgAdvancedOperator::StartGpgAgent(OperationCallback cb) { GpgFrontend::GpgCommandExecutor::ExecuteSync( {gpg_agent_path, QStringList{"--homedir", home_path, "--daemon"}, [=](int exit_code, const QString &, const QString &) { - GF_CORE_LOG_DEBUG("gpgconf daemon exit code: {}", exit_code); + qCDebug(core, "gpgconf daemon exit code: %d", exit_code); cb(exit_code >= 0 ? 0 : -1, TransferParams()); }}); } @@ -202,14 +190,12 @@ void GpgFrontend::GpgAdvancedOperator::StartDirmngr(OperationCallback cb) { const auto dirmngr_path = Module::RetrieveRTValueTypedOrDefault<>( kGnuPGInfoGatheringModuleID, "gnupg.dirmngr_path", QString{}); - GF_CORE_LOG_DEBUG("got gnupg dirmngr path from rt: {}", dirmngr_path); const auto home_path = Module::RetrieveRTValueTypedOrDefault<>( kGnuPGInfoGatheringModuleID, "gnupg.home_path", QString{}); - GF_CORE_LOG_DEBUG("got gnupg home path from rt: {}", home_path); if (dirmngr_path.isEmpty()) { - GF_CORE_LOG_ERROR("cannot get valid dirmngr path from rt, abort."); + qCWarning(core, "cannot get valid dirmngr path from rt, abort."); cb(-1, TransferParams()); return; } @@ -217,7 +203,7 @@ void GpgFrontend::GpgAdvancedOperator::StartDirmngr(OperationCallback cb) { GpgFrontend::GpgCommandExecutor::ExecuteSync( {dirmngr_path, QStringList{"--homedir", home_path, "--daemon"}, [=](int exit_code, const QString &, const QString &) { - GF_CORE_LOG_DEBUG("gpgconf daemon exit code: {}", exit_code); + qCDebug(core, "gpgconf daemon exit code: %d", exit_code); cb(exit_code >= 0 ? 0 : -1, TransferParams()); }}); } @@ -230,14 +216,12 @@ void GpgFrontend::GpgAdvancedOperator::StartKeyBoxd(OperationCallback cb) { const auto keyboxd_path = Module::RetrieveRTValueTypedOrDefault<>( kGnuPGInfoGatheringModuleID, "gnupg.keyboxd_path", QString{}); - GF_CORE_LOG_DEBUG("got gnupg keyboxd path from rt: {}", keyboxd_path); const auto home_path = Module::RetrieveRTValueTypedOrDefault<>( kGnuPGInfoGatheringModuleID, "gnupg.home_path", QString{}); - GF_CORE_LOG_DEBUG("got gnupg home path from rt: {}", home_path); if (keyboxd_path.isEmpty()) { - GF_CORE_LOG_ERROR("cannot get valid keyboxd path from rt, abort."); + qCWarning(core, "cannot get valid keyboxd path from rt, abort."); cb(-1, TransferParams()); return; } @@ -245,7 +229,7 @@ void GpgFrontend::GpgAdvancedOperator::StartKeyBoxd(OperationCallback cb) { GpgFrontend::GpgCommandExecutor::ExecuteSync( {keyboxd_path, QStringList{"--homedir", home_path, "--daemon"}, [=](int exit_code, const QString &, const QString &) { - GF_CORE_LOG_DEBUG("gpgconf daemon exit code: {}", exit_code); + qCDebug(core, "gpgconf daemon exit code: %d", exit_code); cb(exit_code >= 0 ? 0 : -1, TransferParams()); }}); } -- cgit v1.2.3