[java-atk-wrapper] introduction of JAW_DEBUG macro



commit ed60a3e8d4bfbe558f5f8fdf37279399ee11fcf4
Author: giuseppe <giuseppe dhcp-64-92 muc redhat com>
Date:   Fri Jul 5 12:19:59 2019 +0200

    introduction of JAW_DEBUG macro

 jni/src/AtkWrapper.c | 20 +++++++++++++-------
 jni/src/jawimpl.c    |  4 +---
 jni/src/jawutil.h    | 11 ++++++++++-
 3 files changed, 24 insertions(+), 11 deletions(-)
---
diff --git a/jni/src/AtkWrapper.c b/jni/src/AtkWrapper.c
index 907e6e2..365b70c 100644
--- a/jni/src/AtkWrapper.c
+++ b/jni/src/AtkWrapper.c
@@ -29,6 +29,9 @@
 #include "jawtoplevel.h"
 #include "AtkWrapper.h"
 
+gboolean jaw_debug = TRUE;
+FILE *log_file;
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -49,8 +52,6 @@ typedef enum _SignalType SignalType;
 gboolean jaw_accessibility_init (void);
 void jaw_accessibility_shutdown (void);
 
-gboolean jaw_debug = FALSE;
-
 static gint key_dispatch_result;
 static GMainLoop* jni_main_loop;
 static GMainContext *jni_main_context;
@@ -87,10 +88,16 @@ static gpointer jni_loop_callback(void *data)
 JNIEXPORT jboolean
 JNICALL Java_org_GNOME_Accessibility_AtkWrapper_initNativeLibrary(void)
 {
-  const gchar* debug_env = g_getenv("JAW_DEBUG");
-  if (g_strcmp0(debug_env, "1") == 0) {
-    jaw_debug = TRUE;
-  }
+    if (jaw_debug)
+    {
+        log_file = fopen("log_file.txt","w+");
+        if (!log_file)
+        {
+            printf("Error open log file\n");
+            exit(1);
+        }
+    }
+    JAW_DEBUG("%s()",__func__);
 
   if (jaw_initialized)
     return JNI_TRUE;
@@ -1201,4 +1208,3 @@ JNICALL Java_org_GNOME_Accessibility_AtkWrapper_getInstance(JNIEnv *jniEnv,
 #ifdef __cplusplus
 }
 #endif
-
diff --git a/jni/src/jawimpl.c b/jni/src/jawimpl.c
index df7e50f..3f4f8e3 100644
--- a/jni/src/jawimpl.c
+++ b/jni/src/jawimpl.c
@@ -53,7 +53,6 @@ static GMutex typeTableMutex;
 static GHashTable *typeTable = NULL;
 static GMutex objectTableMutex;
 static GHashTable *objectTable = NULL;
-static gboolean jaw_debug = FALSE;
 
 static void
 object_table_insert (JNIEnv *jniEnv, jobject ac, JawImpl* jaw_impl)
@@ -368,7 +367,7 @@ jaw_impl_get_type (guint tflag)
     NULL
   };
 
-  static const GInterfaceInfo atk_editable_text_info = 
+  static const GInterfaceInfo atk_editable_text_info =
   {
     (GInterfaceInitFunc) jaw_editable_text_interface_init,
     (GInterfaceFinalizeFunc) NULL,
@@ -672,4 +671,3 @@ jaw_impl_get_atk_relation_type(JNIEnv *env, jstring jrel_key)
 #ifdef __cplusplus
 }
 #endif
-
diff --git a/jni/src/jawutil.h b/jni/src/jawutil.h
index aecfaa2..9e5269e 100644
--- a/jni/src/jawutil.h
+++ b/jni/src/jawutil.h
@@ -22,6 +22,16 @@
 
 #include <jni.h>
 #include <atk/atk.h>
+#include <time.h>
+
+extern gboolean jaw_debug;
+extern FILE *log_file;
+
+#define JAW_DEBUG(fmt, ...) do { \
+    if (jaw_debug) { \
+        fprintf(log_file, "TIME:[%lu] PID:{%d} " fmt "\n", (unsigned long) time(NULL), (int)getpid(), 
##__VA_ARGS__); \
+    } \
+} while (0)
 
 G_BEGIN_DECLS
 
@@ -79,4 +89,3 @@ void jaw_util_detach(void);
 G_END_DECLS
 
 #endif
-


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]