gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Thu Jul 11 20:17:06 EDT 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/22f22b0a (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b3a4cd62 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/429077ee (commit)
	 via  https://github.com/Gnucash/gnucash/commit/42b6fb99 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/898a9cdb (commit)
	from  https://github.com/Gnucash/gnucash/commit/9f40cac2 (commit)



commit 22f22b0a280e0ad65a74ac60228ce64d0650f334
Merge: 9f40cac25 b3a4cd627
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Jul 12 08:16:46 2019 +0800

    Merge branch 'wrapqoflog' into maint


commit b3a4cd62775705b2543438f912ca71dad591bf0e
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Jul 7 08:30:54 2019 +0800

    completion redefine gnc:debug

diff --git a/libgnucash/scm/utilities.scm b/libgnucash/scm/utilities.scm
index d359dd4db..4e3af3fdc 100644
--- a/libgnucash/scm/utilities.scm
+++ b/libgnucash/scm/utilities.scm
@@ -66,9 +66,18 @@
 (define (gnc:msg . items)
   (gnc-scm-log-msg (strify items)))
 
-(define (gnc:debug . items)
-  (when (qof-log-check "gnc" G-LOG-LEVEL-DEBUG)
-    (gnc-scm-log-debug (strify items))))
+;; this definition of gnc:debug is different from others because we
+;; want to check loglevel is debug *once* at gnc:debug definition
+;; instead of every call to gnc:debug. if loglevel isn't debug then
+;; gnc:debug becomes a NOOP.
+(define gnc:debug
+  (cond
+   ((qof-log-check "gnc" QOF-LOG-DEBUG)
+    (display "debugging enabled\n")
+    (lambda items (gnc-scm-log-debug (strify items))))
+
+   (else
+    (lambda items #f))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; the following functions are initialized to log message to tracefile

commit 429077ee8e5728315e491f00e44bba85c160e59b
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Jul 7 08:30:41 2019 +0800

    completion wrap qoflog

diff --git a/libgnucash/engine/engine.i b/libgnucash/engine/engine.i
index 95c134f37..34b49e93c 100644
--- a/libgnucash/engine/engine.i
+++ b/libgnucash/engine/engine.i
@@ -83,6 +83,19 @@ engine-common.i */
 
 %include "engine-common.i"
 %include "engine-deprecated.h"
+
+#if defined(SWIGGUILE)
+%ignore QofLogModule;
+%typemap(in) QofLogModule {
+     $1 = (const char *)SWIG_scm2str($input);
+ }
+
+%typemap(freearg) QofLogModule {
+    SWIG_free((char*)$1);
+ }
+
+#endif
+
 %include "qoflog.h"
 
 %inline %{
@@ -327,7 +340,12 @@ void qof_book_set_string_option(QofBook* book, const char* opt_name, const char*
     SET_ENUM("QOF-COMPARE-CONTAINS");
     SET_ENUM("QOF-COMPARE-NCONTAINS");
 
-    SET_ENUM("QOF-LOG-DEBUG");  /* errors out */
+    SET_ENUM("QOF-LOG-DEBUG");
+    SET_ENUM("QOF-LOG-FATAL");
+    SET_ENUM("QOF-LOG-ERROR");
+    SET_ENUM("QOF-LOG-WARNING");
+    SET_ENUM("QOF-LOG-MESSAGE");
+    SET_ENUM("QOF-LOG-INFO");
 
     SET_ENUM("QOF-NUMERIC-MATCH-ANY");
     SET_ENUM("QOF-NUMERIC-MATCH-CREDIT");
diff --git a/libgnucash/engine/qoflog.h b/libgnucash/engine/qoflog.h
index 915425246..345ad5f1a 100644
--- a/libgnucash/engine/qoflog.h
+++ b/libgnucash/engine/qoflog.h
@@ -96,15 +96,15 @@ extern "C"
 
 #define QOF_MOD_ENGINE "qof.engine"
 
-#define LOG_LEVEL_LIST(_) \
-  _(QOF_LOG_FATAL,   = G_LOG_LEVEL_ERROR)   \
-  _(QOF_LOG_ERROR,   = G_LOG_LEVEL_CRITICAL)   \
-  _(QOF_LOG_WARNING, = G_LOG_LEVEL_WARNING) \
-  _(QOF_LOG_MESSAGE, = G_LOG_LEVEL_MESSAGE) \
-  _(QOF_LOG_INFO,    = G_LOG_LEVEL_INFO)    \
-  _(QOF_LOG_DEBUG,   = G_LOG_LEVEL_DEBUG)
-
-DEFINE_ENUM (QofLogLevel, LOG_LEVEL_LIST);
+typedef enum
+{
+    QOF_LOG_FATAL   = G_LOG_LEVEL_ERROR,
+    QOF_LOG_ERROR   = G_LOG_LEVEL_CRITICAL,
+    QOF_LOG_WARNING = G_LOG_LEVEL_WARNING,
+    QOF_LOG_MESSAGE = G_LOG_LEVEL_MESSAGE,
+    QOF_LOG_INFO    = G_LOG_LEVEL_INFO,
+    QOF_LOG_DEBUG   = G_LOG_LEVEL_DEBUG
+} QofLogLevel;
 
 const char* qof_log_level_to_string(QofLogLevel lvl);
 QofLogLevel qof_log_level_from_string(const char *str);
diff --git a/libgnucash/scm/CMakeLists.txt b/libgnucash/scm/CMakeLists.txt
index 731e44a33..5b3ce0e86 100644
--- a/libgnucash/scm/CMakeLists.txt
+++ b/libgnucash/scm/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_subdirectory(test)
 
-set(GUILE_DEPENDS      scm-core-utils scm-gnc-module)
+set(GUILE_DEPENDS      scm-core-utils scm-gnc-module gncmod-engine)
 
 
 gnc_add_scheme_targets(scm-scm

commit 42b6fb993b9391c5725513d1e487f04c7b578082
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Jul 6 11:14:56 2019 +0800

    call strify only if debugging enabled

diff --git a/libgnucash/scm/utilities.scm b/libgnucash/scm/utilities.scm
index 509bb5376..d359dd4db 100644
--- a/libgnucash/scm/utilities.scm
+++ b/libgnucash/scm/utilities.scm
@@ -27,6 +27,10 @@
 
 (use-modules (gnucash core-utils))
 
+(eval-when (compile load eval expand)
+  (load-extension "libgncmod-engine" "scm_init_sw_engine_module"))
+(use-modules (sw_engine))
+
 ;; Load the srfis (eventually, we should see where these are needed
 ;; and only have the use-modules statements in those files).
 (use-modules (srfi srfi-1))
@@ -63,7 +67,8 @@
   (gnc-scm-log-msg (strify items)))
 
 (define (gnc:debug . items)
-  (gnc-scm-log-debug (strify items)))
+  (when (qof-log-check "gnc" G-LOG-LEVEL-DEBUG)
+    (gnc-scm-log-debug (strify items))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; the following functions are initialized to log message to tracefile

commit 898a9cdb8e1a8cad34125e6599ff62587297b01b
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Jul 6 11:14:50 2019 +0800

    wrap qoflog

diff --git a/libgnucash/engine/engine.i b/libgnucash/engine/engine.i
index ec8dd3d15..95c134f37 100644
--- a/libgnucash/engine/engine.i
+++ b/libgnucash/engine/engine.i
@@ -24,6 +24,7 @@
 #include <config.h>
 #include <glib.h>
 #include "qof.h"
+#include "qoflog.h"
 #include "Query.h"
 #include "gnc-budget.h"
 #include "gnc-commodity.h"
@@ -82,6 +83,7 @@ engine-common.i */
 
 %include "engine-common.i"
 %include "engine-deprecated.h"
+%include "qoflog.h"
 
 %inline %{
 static const GncGUID * gncPriceGetGUID(GNCPrice *x)
@@ -325,6 +327,8 @@ void qof_book_set_string_option(QofBook* book, const char* opt_name, const char*
     SET_ENUM("QOF-COMPARE-CONTAINS");
     SET_ENUM("QOF-COMPARE-NCONTAINS");
 
+    SET_ENUM("QOF-LOG-DEBUG");  /* errors out */
+
     SET_ENUM("QOF-NUMERIC-MATCH-ANY");
     SET_ENUM("QOF-NUMERIC-MATCH-CREDIT");
     SET_ENUM("QOF-NUMERIC-MATCH-DEBIT");
diff --git a/libgnucash/engine/qoflog.h b/libgnucash/engine/qoflog.h
index f7d6cbd35..915425246 100644
--- a/libgnucash/engine/qoflog.h
+++ b/libgnucash/engine/qoflog.h
@@ -104,7 +104,7 @@ extern "C"
   _(QOF_LOG_INFO,    = G_LOG_LEVEL_INFO)    \
   _(QOF_LOG_DEBUG,   = G_LOG_LEVEL_DEBUG)
 
-DEFINE_ENUM (QofLogLevel, LOG_LEVEL_LIST)
+DEFINE_ENUM (QofLogLevel, LOG_LEVEL_LIST);
 
 const char* qof_log_level_to_string(QofLogLevel lvl);
 QofLogLevel qof_log_level_from_string(const char *str);



Summary of changes:
 libgnucash/engine/engine.i    | 22 ++++++++++++++++++++++
 libgnucash/engine/qoflog.h    | 18 +++++++++---------
 libgnucash/scm/CMakeLists.txt |  2 +-
 libgnucash/scm/utilities.scm  | 18 ++++++++++++++++--
 4 files changed, 48 insertions(+), 12 deletions(-)



More information about the gnucash-changes mailing list