aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2015-01-11 14:33:29 -0800
committerGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2015-01-11 14:33:29 -0800
commit6df03450a7057ee74341079df672679ba9663348 (patch)
tree27e2eded6d090fb7a0f97fe6020c9435fbbd6670
parent4a784c148634202e1a919fcccaaf6b77c6d3b6e4 (diff)
Added API to disable/enable logs
-rw-r--r--src/java/TypesUtils.cpp3
-rw-r--r--src/java/com/libmailcore/Log.java6
-rw-r--r--src/java/native/com_libmailcore_Log.cpp15
-rw-r--r--src/java/native/com_libmailcore_Log.h29
4 files changed, 50 insertions, 3 deletions
diff --git a/src/java/TypesUtils.cpp b/src/java/TypesUtils.cpp
index e79c4745..503a6449 100644
--- a/src/java/TypesUtils.cpp
+++ b/src/java/TypesUtils.cpp
@@ -63,7 +63,6 @@ jobject mailcore::timeToJavaDate(JNIEnv * env, time_t t)
void mailcore::MCJNIRegisterNativeClass(const std::type_info * info, ObjectToJavaConverter converter)
{
- MCLogEnabled = 1;
MCLog("MCJNIRegisterNativeClass");
init();
@@ -87,7 +86,6 @@ void mailcore::MCJNIRegisterNativeClass(const std::type_info * info, ObjectToJav
void mailcore::MCJNIRegisterJavaClass(const char * className, JavaToObjectConverter converter)
{
- MCLogEnabled = 1;
MCLog("MCJNIRegisterJavaClass %s", className);
init();
@@ -504,7 +502,6 @@ static void init(void)
static void real_init(void)
{
- MCLogEnabled = 1;
MCLog("real_init");
MCLog("init cppClassHash");
cppClassHash = chash_new(CHASH_DEFAULTSIZE, CHASH_COPYKEY);
diff --git a/src/java/com/libmailcore/Log.java b/src/java/com/libmailcore/Log.java
new file mode 100644
index 00000000..5d202242
--- /dev/null
+++ b/src/java/com/libmailcore/Log.java
@@ -0,0 +1,6 @@
+package com.libmailcore;
+
+public class Log {
+ static public native void setEnabled(boolean enabled);
+ static public native boolean isEnabled();
+}
diff --git a/src/java/native/com_libmailcore_Log.cpp b/src/java/native/com_libmailcore_Log.cpp
new file mode 100644
index 00000000..865ba61f
--- /dev/null
+++ b/src/java/native/com_libmailcore_Log.cpp
@@ -0,0 +1,15 @@
+#include "com_libmailcore_Log.h"
+
+#include "MCLog.h"
+
+JNIEXPORT void JNICALL Java_com_libmailcore_Log_setEnabled
+ (JNIEnv * env, jclass cls, jboolean enabled)
+{
+ MCLogEnabled = true;
+}
+
+JNIEXPORT jboolean JNICALL Java_com_libmailcore_Log_isEnabled
+ (JNIEnv * env, jclass cls)
+{
+ return MCLogEnabled;
+}
diff --git a/src/java/native/com_libmailcore_Log.h b/src/java/native/com_libmailcore_Log.h
new file mode 100644
index 00000000..4a46b391
--- /dev/null
+++ b/src/java/native/com_libmailcore_Log.h
@@ -0,0 +1,29 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_libmailcore_Log */
+
+#ifndef _Included_com_libmailcore_Log
+#define _Included_com_libmailcore_Log
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: com_libmailcore_Log
+ * Method: setEnabled
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_libmailcore_Log_setEnabled
+ (JNIEnv *, jclass, jboolean);
+
+/*
+ * Class: com_libmailcore_Log
+ * Method: isEnabled
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_libmailcore_Log_isEnabled
+ (JNIEnv *, jclass);
+
+#ifdef __cplusplus
+}
+#endif
+#endif