summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 226b7ea)
raw | patch | inline | side by side (parent: 226b7ea)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 22 Feb 2009 17:32:02 +0000 (18:32 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 22 Feb 2009 17:32:02 +0000 (18:32 +0100) |
bindings/java/org/collectd/api/CollectdAPI.java | patch | blob | history | |
src/Makefile.am | patch | blob | history | |
src/java.c | patch | blob | history |
diff --git a/bindings/java/org/collectd/api/CollectdAPI.java b/bindings/java/org/collectd/api/CollectdAPI.java
index 9dbe7c0d482a8008e260b9aa3ac3491372ac46b7..2b6e06cf9ea58f2a2840795710eed5f55d81f1ec 100644 (file)
*/
public class CollectdAPI
{
- /**
- * Java representation of collectd/src/plugin.h:plugin_dispatch_values
- */
- native public static int DispatchValues (ValueList vl);
-
- /**
- * Java representation of collectd/src/plugin.h:plugin_get_ds
- */
- native public static DataSet GetDS (String type);
+ private static final int LOG_ERR = 3;
+ private static final int LOG_WARNING = 4;
+ private static final int LOG_NOTICE = 5;
+ private static final int LOG_INFO = 6;
+ private static final int LOG_DEBUG = 7;
/**
* Java representation of collectd/src/plugin.h:plugin_register_config
*/
native public static int RegisterShutdown (String name,
CollectdShutdownInterface obj);
+
+ /**
+ * Java representation of collectd/src/plugin.h:plugin_dispatch_values
+ */
+ native public static int DispatchValues (ValueList vl);
+
+ /**
+ * Java representation of collectd/src/plugin.h:plugin_get_ds
+ */
+ native public static DataSet GetDS (String type);
+
+ /**
+ * Java representation of collectd/src/plugin.h:plugin_log
+ */
+ native private static void Log (int severity, String message);
+
+ public static void LogError (String message)
+ {
+ Log (LOG_ERR, message);
+ } /* void LogError */
+
+ public static void LogWarning (String message)
+ {
+ Log (LOG_WARNING, message);
+ } /* void LogWarning */
+
+ public static void LogNotice (String message)
+ {
+ Log (LOG_NOTICE, message);
+ } /* void LogNotice */
+
+ public static void LogInfo (String message)
+ {
+ Log (LOG_INFO, message);
+ } /* void LogInfo */
+
+ public static void LogDebug (String message)
+ {
+ Log (LOG_DEBUG, message);
+ } /* void LogDebug */
+
} /* class CollectdAPI */
/* vim: set sw=2 sts=2 et fdm=marker : */
diff --git a/src/Makefile.am b/src/Makefile.am
index e159026cac7a5c11cd9382270c94d59a5d4f57ae..2f16bf242f6137491d32cfee33c553d787c6d44b 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
utils_ignorelist.c utils_ignorelist.h \
utils_llist.c utils_llist.h \
utils_parse_option.c utils_parse_option.h \
+ utils_rwlock.c utils_rwlock.h \
utils_tail_match.c utils_tail_match.h \
utils_match.c utils_match.h \
utils_mount.c utils_mount.h \
diff --git a/src/java.c b/src/java.c
index 45f139c399cafc2e23f94a052a2e4a8c1be88cca..5538270668911f56dacf05f73acbf747a7c05fd5 100644 (file)
--- a/src/java.c
+++ b/src/java.c
CB_TYPE_SHUTDOWN));
} /* }}} jint cjni_api_register_shutdown */
+static void JNICALL cjni_api_log (JNIEnv *jvm_env, /* {{{ */
+ jobject this, jint severity, jobject o_message)
+{
+ const char *c_str;
+
+ c_str = (*jvm_env)->GetStringUTFChars (jvm_env, o_message, 0);
+ if (c_str == NULL)
+ {
+ ERROR ("java plugin: cjni_api_log: GetStringUTFChars failed.");
+ return;
+ }
+
+ if (severity < LOG_ERR)
+ severity = LOG_ERR;
+ if (severity > LOG_DEBUG)
+ severity = LOG_DEBUG;
+
+ plugin_log (severity, "%s", c_str);
+
+ (*jvm_env)->ReleaseStringUTFChars (jvm_env, o_message, c_str);
+} /* }}} void cjni_api_log */
+
/* List of ``native'' functions, i. e. C-functions that can be called from
* Java. */
static JNINativeMethod jni_api_functions[] = /* {{{ */
{ "RegisterShutdown",
"(Ljava/lang/String;Lorg/collectd/api/CollectdShutdownInterface;)I",
- cjni_api_register_shutdown }
+ cjni_api_register_shutdown },
+ { "Log",
+ "(ILjava/lang/String;)V",
+ cjni_api_log },
};
static size_t jni_api_functions_num = sizeof (jni_api_functions)
/ sizeof (jni_api_functions[0]);