*/
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 : */
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 \
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]);