• R/O
  • SSH
  • HTTPS

senna-java: Commit


Commit MetaInfo

Revision10 (tree)
Time2008-12-22 18:01:03
Authormir

Log Message

* src/test/senna/SnippetTest.java: add logging
* src/test/senna/IndexTest.java: add logging
* src/jni/senna_SennaLogger.c (Java_senna_SennaLogger_write): works now
* src/jni/senna_SennaLogger.c (Java_senna_SennaLogger_open): refactorying

Change Summary

Incremental Difference

--- trunk/ChangeLog (revision 9)
+++ trunk/ChangeLog (revision 10)
@@ -1,4 +1,10 @@
11 2008-12-22 Tetsuro IKEDA <ikdttr@gmail.com>
2+ * src/test/senna/SnippetTest.java: add logging
3+ * src/test/senna/IndexTest.java: add logging
4+ * src/jni/senna_SennaLogger.c (Java_senna_SennaLogger_write): works now
5+ * src/jni/senna_SennaLogger.c (Java_senna_SennaLogger_open): refactorying
6+
7+2008-12-22 Tetsuro IKEDA <ikdttr@gmail.com>
28 * src/java/senna/SennaLogger.java: add write method
39 * src/jni/senna_SennaLogger.h: add write method
410 * src/jni/senna_SennaLogger.c: add write method
--- trunk/src/test/senna/SnippetTest.java (revision 9)
+++ trunk/src/test/senna/SnippetTest.java (revision 10)
@@ -28,13 +28,16 @@
2828
2929 protected void setUp() throws Exception {
3030 Senna.init();
31+ SennaLogger.open("senna.log",Senna.SEN_LOG_DEBUG);
3132 }
3233
3334 protected void tearDown() throws Exception {
35+ SennaLogger.close();
3436 Senna.fin();
3537 }
3638
3739 public void testSnippet() throws Exception {
40+ SennaLogger.write(Senna.SEN_LOG_DEBUG,"== SnippetTest#testSnippet() ==");
3841 Snippet snip = new Snippet(Senna.SEN_ENC_UTF8,
3942 Senna.SEN_SNIP_NORMALIZE, 60, 1, "{", "}", 0);
4043 assertNotNull(snip);
--- trunk/src/test/senna/IndexTest.java (revision 9)
+++ trunk/src/test/senna/IndexTest.java (revision 10)
@@ -28,13 +28,16 @@
2828
2929 protected void setUp() throws Exception {
3030 Senna.init();
31+ SennaLogger.open("senna.log",Senna.SEN_LOG_DEBUG);
3132 }
3233
3334 protected void tearDown() throws Exception {
35+ SennaLogger.close();
3436 Senna.fin();
3537 }
3638
3739 public void testCreate() throws Exception {
40+ SennaLogger.write(Senna.SEN_LOG_DEBUG, "=== IndexTest#testCreate() ===");
3841 // create
3942 Index index = Index.create("tests/testindex");
4043 assertNotNull(index);
@@ -50,7 +53,8 @@
5053 }
5154
5255 public void testInsert() throws Exception {
53- Index index = Index.create("tests/testindex");
56+ SennaLogger.write(Senna.SEN_LOG_DEBUG, "=== IndexTest#testInsert() ===");
57+ Index index = Index.create("tests/testindex",0,0,0,Senna.SEN_ENC_UTF8);
5458 index.printInfo();
5559 index.insert("ほげ", "東京都");
5660 Records records = index.sel("東京");
--- trunk/src/jni/senna_SennaLogger.c (revision 9)
+++ trunk/src/jni/senna_SennaLogger.c (revision 10)
@@ -16,6 +16,7 @@
1616 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1717 */
1818
19+#include <string.h>
1920 #include "senna_java.h"
2021 #include "senna_SennaLogger.h"
2122
@@ -49,14 +50,14 @@
4950 JNIEXPORT void JNICALL
5051 Java_senna_SennaLogger_open(JNIEnv *env, jclass clazz, jstring path_str, jint level)
5152 {
52- log_file_path = (*env)->GetStringUTFChars(env, path_str, NULL);
53- log_level = level;
54-
5553 if (!fp)
5654 {
55+ log_file_path = (*env)->GetStringUTFChars(env, path_str, NULL);
5756 fp = fopen(log_file_path, "a");
57+ (*env)->ReleaseStringUTFChars(env, path_str, log_file_path);
5858 }
5959
60+ log_level = level;
6061 senna_logger.max_level = (sen_log_level) log_level;
6162 sen_logger_info_set(&senna_logger);
6263 }
@@ -106,7 +107,12 @@
106107 */
107108 JNIEXPORT void JNICALL
108109 Java_senna_SennaLogger_write(JNIEnv *env, jclass clazz,
109- jint level, jstring message)
110+ jint level, jstring str)
110111 {
111- SEN_LOG(level, message);
112+ char buf[1024];
113+ const char *msg;
114+ msg = (*env)->GetStringUTFChars(env, str, NULL);
115+ strncpy(buf, msg, 1024);
116+ SEN_LOG((sen_log_level) level, buf);
117+ (*env)->ReleaseStringUTFChars(env, str, msg);
112118 }
--- trunk/src/jni/Makefile (revision 9)
+++ trunk/src/jni/Makefile (revision 10)
@@ -24,7 +24,7 @@
2424 senna_Snippet.o: senna_Snippet.c senna_Snippet.h
2525 $(CC) $(OPT) $(INCLUDES) -o $@ -g -c $<
2626
27-senna_Logger.o: senna_SennaLogger.c senna_SennaLogger.h
27+senna_SennaLogger.o: senna_SennaLogger.c senna_SennaLogger.h
2828 $(CC) $(OPT) $(INCLUDES) -o $@ -g -c $<
2929
3030 clean:
Show on old repository browser