aboutsummaryrefslogtreecommitdiffstats
path: root/lang/cpp/src/editinteractor.cpp
diff options
context:
space:
mode:
authorAndre Heinecke <[email protected]>2019-11-01 11:00:18 +0000
committerAndre Heinecke <[email protected]>2019-11-01 11:00:18 +0000
commita4d5394b4607382d846e8c156439ac182f9945d7 (patch)
treebd42beb7719791f7b4e6e50558019912684d0ee7 /lang/cpp/src/editinteractor.cpp
parentcore: Fix parsing of userid sigs after a subpkg (diff)
downloadgpgme-a4d5394b4607382d846e8c156439ac182f9945d7.tar.gz
gpgme-a4d5394b4607382d846e8c156439ac182f9945d7.zip
cpp: Add env var to control editinteractor debug
* lang/cpp/src/editinteractor.cpp (EditInteractor::Private::Private): Read "GPGMEPP_INTERACTOR_DEBUG" env var. (EditInteractor::Private::~Private): Close debug file. -- While it was possible for the application to control the debug through setDebugChannel it is often times helpful to just debug without changing the application using GPGME
Diffstat (limited to 'lang/cpp/src/editinteractor.cpp')
-rw-r--r--lang/cpp/src/editinteractor.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/lang/cpp/src/editinteractor.cpp b/lang/cpp/src/editinteractor.cpp
index f7c994a4..36d1be63 100644
--- a/lang/cpp/src/editinteractor.cpp
+++ b/lang/cpp/src/editinteractor.cpp
@@ -178,10 +178,25 @@ EditInteractor::Private::Private(EditInteractor *qq)
error(),
debug(nullptr)
{
-
+ const char *debug_env = getenv("GPGMEPP_INTERACTOR_DEBUG");
+ if (!debug_env) {
+ return;
+ }
+ if (!strcmp(debug_env, "stdout")) {
+ debug = stdout;
+ } else if (!strcmp(debug_env, "stderr")) {
+ debug = stderr;
+ } else if (debug_env) {
+ debug = std::fopen(debug_env, "a+");
+ }
}
-EditInteractor::Private::~Private() {}
+EditInteractor::Private::~Private()
+{
+ if (debug) {
+ std::fclose(debug);
+ }
+}
EditInteractor::EditInteractor()
: d(new Private(this))