[java-atk-wrapper] introduced two different macros for log levels
- From: Samuel Thibault <sthibaul src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [java-atk-wrapper] introduced two different macros for log levels
- Date: Wed, 10 Jul 2019 20:33:51 +0000 (UTC)
commit e1a3a992ca3378cf2926de40239ce749d851b94b
Author: giuseppe <giuseppe dhcp-64-47 muc redhat com>
Date: Wed Jul 10 16:34:52 2019 +0200
introduced two different macros for log levels
JAW_DEBUG_F for the functions
JAW_DEBUG_I for the info and a levelling of debugging with an integer.
jni/src/AtkWrapper.c | 13 +++++++++----
jni/src/jawutil.h | 18 ++++++++++++++----
2 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/jni/src/AtkWrapper.c b/jni/src/AtkWrapper.c
index f62d6e5..09a3aa0 100644
--- a/jni/src/AtkWrapper.c
+++ b/jni/src/AtkWrapper.c
@@ -29,7 +29,7 @@
#include "jawtoplevel.h"
#include "AtkWrapper.h"
-gboolean jaw_debug = FALSE;
+int jaw_debug = 0;
FILE *log_file;
#ifdef __cplusplus
@@ -89,8 +89,13 @@ 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 (debug_env)
+ {
+ int val_debug = atoi(debug_env);
+ if(val_debug > 5)
+ jaw_debug = 5;
+ else
+ jaw_debug = val_debug;
}
if (jaw_debug)
{
@@ -101,7 +106,7 @@ JNICALL Java_org_GNOME_Accessibility_AtkWrapper_initNativeLibrary(void)
exit(1);
}
}
- JAW_DEBUG("%s()",__func__);
+ JAW_DEBUG_F(2,"");
if (jaw_initialized)
return JNI_TRUE;
diff --git a/jni/src/jawutil.h b/jni/src/jawutil.h
index 8870101..7ce7cb5 100644
--- a/jni/src/jawutil.h
+++ b/jni/src/jawutil.h
@@ -25,16 +25,26 @@
#include <unistd.h>
#include <time.h>
-extern gboolean jaw_debug;
+extern int jaw_debug;
extern FILE *log_file;
-#define JAW_DEBUG(fmt, ...) do { \
+#define JAW_DEBUG(lvl, fmt, ...) do { \
if (jaw_debug) { \
- fprintf(log_file, "TIME:[%lu] PID:{%d} " fmt "\n", (unsigned long) time(NULL), (int)getpid(),
##__VA_ARGS__); \
- fflush(log_file); \
+ if (lvl <= jaw_debug) \
+ fprintf(log_file, "TIME:[%lu] PID:{%d} " fmt "\n", (unsigned long) time(NULL), (int)getpid(), ##
__VA_ARGS__); \
} \
} while (0)
+#define JAW_DEBUG_I(msg, ...) JAW_DEBUG(1, "%s: " msg , __func__, ##__VA_ARGS__)
+
+#define JAW_DEBUG_F(lvl, msg, ...) JAW_DEBUG(lvl, "%s(" msg ")", __func__, ##__VA_ARGS__)
+
+#define JAW_DEBUG_JNI(msg, ...) JAW_DEBUG_F(2, msg, ##__VA_ARGS__)
+
+#define JAW_DEBUG_C(msg, ...) JAW_DEBUG_F(3, msg, ##__VA_ARGS__)
+
+#define JAW_DEBUG_ALL(msg, ...) JAW_DEBUG_F(4, msg, ##__VA_ARGS__)
+
G_BEGIN_DECLS
#define INTERFACE_ACTION 0x00000001
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]