You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/04/28 14:29:15 UTC
svn commit: r769367 - in /commons/sandbox/runtime/trunk/src:
main/java/org/apache/commons/runtime/
main/java/org/apache/commons/runtime/util/ main/native/
main/native/include/ main/native/os/unix/ main/native/os/win32/
main/native/shared/ test/org/apac...
Author: mturk
Date: Tue Apr 28 12:29:15 2009
New Revision: 769367
URL: http://svn.apache.org/viewvc?rev=769367&view=rev
Log:
Add Syslog implementations
Added:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/SyslogLevel.java
- copied, changed from r769281, commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SyslogLevel.java
commons/sandbox/runtime/trunk/src/main/native/os/unix/syslog.c (with props)
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSyslog.java (with props)
Removed:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SyslogLevel.java
Modified:
commons/sandbox/runtime/trunk/src/main/native/Makefile.in
commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h
commons/sandbox/runtime/trunk/src/main/native/os/win32/syslog.c
commons/sandbox/runtime/trunk/src/main/native/shared/string.c
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java
Copied: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/SyslogLevel.java (from r769281, commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SyslogLevel.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/SyslogLevel.java?p2=commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/SyslogLevel.java&p1=commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SyslogLevel.java&r1=769281&r2=769367&rev=769367&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SyslogLevel.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/SyslogLevel.java Tue Apr 28 12:29:15 2009
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.apache.commons.runtime;
+package org.apache.commons.runtime.util;
/**
* System log levels.
Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.in?rev=769367&r1=769366&r2=769367&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Tue Apr 28 12:29:15 2009
@@ -82,6 +82,7 @@
$(SRCDIR)/os/unix/main.$(OBJ) \
$(SRCDIR)/os/unix/group.$(OBJ) \
$(SRCDIR)/os/unix/user.$(OBJ) \
+ $(SRCDIR)/os/unix/syslog.$(OBJ) \
$(SRCDIR)/os/unix/uuid.$(OBJ) \
$(SRCDIR)/os/unix/uutils.$(OBJ) \
$(SRCDIR)/os/linux/platform.$(OBJ) \
@@ -92,6 +93,7 @@
$(SRCDIR)/os/unix/main.$(OBJ) \
$(SRCDIR)/os/unix/group.$(OBJ) \
$(SRCDIR)/os/unix/user.$(OBJ) \
+ $(SRCDIR)/os/unix/syslog.$(OBJ) \
$(SRCDIR)/os/unix/uuid.$(OBJ) \
$(SRCDIR)/os/unix/uutils.$(OBJ) \
$(SRCDIR)/os/solaris/platform.$(OBJ) \
@@ -102,6 +104,7 @@
$(SRCDIR)/os/unix/main.$(OBJ) \
$(SRCDIR)/os/unix/group.$(OBJ) \
$(SRCDIR)/os/unix/user.$(OBJ) \
+ $(SRCDIR)/os/unix/syslog.$(OBJ) \
$(SRCDIR)/os/unix/uuid.$(OBJ) \
$(SRCDIR)/os/unix/uutils.$(OBJ) \
$(SRCDIR)/os/darwin/platform.$(OBJ) \
@@ -110,6 +113,7 @@
HPUX_OBJS= \
$(SRCDIR)/os/unix/file.$(OBJ) \
$(SRCDIR)/os/unix/main.$(OBJ) \
+ $(SRCDIR)/os/unix/syslog.$(OBJ) \
$(SRCDIR)/os/unix/uuid.$(OBJ) \
$(SRCDIR)/os/unix/uutils.$(OBJ) \
$(SRCDIR)/os/hpux/platform.$(OBJ) \
Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h?rev=769367&r1=769366&r2=769367&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h Tue Apr 28 12:29:15 2009
@@ -101,6 +101,11 @@
wchar_t *_w##V = ACR_GetJavaStringW(_E, (V)); \
if (!_w##V) goto _cw##V;
+#define WITH_ZWSTR(V) \
+ if (_E) { \
+ wchar_t *_w##V = ACR_GetJavaStringW(_E, (V)); \
+ if (!_w##V && (V)) goto _cw##V;
+
#define END_WITH_WSTR(V) \
_cw##V : \
if (_w##V) free (_w##V); \
@@ -111,6 +116,11 @@
char *_c##V = ACR_GetJavaStringA(_E, (V)); \
if (!_c##V) goto _ca##V;
+#define WITH_ZCSTR(V) \
+ if (_E) { \
+ char *_c##V = ACR_GetJavaStringA(_E, (V)); \
+ if (!_c##V && (V)) goto _ca##V;
+
#define END_WITH_CSTR(V) \
_ca##V : \
if (_c##V) free (_c##V); \
Added: commons/sandbox/runtime/trunk/src/main/native/os/unix/syslog.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/syslog.c?rev=769367&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/syslog.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/syslog.c Tue Apr 28 12:29:15 2009
@@ -0,0 +1,89 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "acr.h"
+#include "acr_private.h"
+#include "acr_arch.h"
+#include "acr_error.h"
+#include "acr_string.h"
+
+/**
+ * POSIX syslog implementation
+ *
+ */
+
+#include <syslog.h>
+#include <stdarg.h>
+
+#ifndef LOG_WARN
+#define LOG_WARN LOG_WARNING
+#endif
+
+#define LOG_MSG_DOMAIN "runtime"
+
+ACR_JNI_EXPORT_DECLARE(void, util_Syslog, init0)(ACR_JNISTDARGS)
+{
+
+ UNREFERENCED_STDARGS;
+ openlog(LOG_MSG_DOMAIN, LOG_CONS | LOG_PID, LOG_LOCAL0);
+}
+
+ACR_JNI_EXPORT_DECLARE(void, util_Syslog, init1)(ACR_JNISTDARGS,
+ jstring domain)
+{
+
+ UNREFERENCED_O;
+
+ WITH_CSTR(domain) {
+
+ openlog(J2S(domain), LOG_CONS | LOG_PID, LOG_LOCAL0);
+ } END_WITH_CSTR(domain);
+}
+
+ACR_JNI_EXPORT_DECLARE(void, util_Syslog, close0)(ACR_JNISTDARGS)
+{
+ UNREFERENCED_STDARGS;
+ closelog();
+}
+
+ACR_JNI_EXPORT_DECLARE(void, util_Syslog, log0)(ACR_JNISTDARGS,
+ jint level,
+ jstring msg)
+{
+ UNREFERENCED_O;
+
+ WITH_CSTR(msg) {
+ int id = LOG_DEBUG;
+ switch (level) {
+ case ACR_LOG_EMERG:
+ id = LOG_EMERG;
+ break;
+ case ACR_LOG_ERROR:
+ id = LOG_ERR;
+ break;
+ case ACR_LOG_NOTICE:
+ id = LOG_NOTICE;
+ break;
+ case ACR_LOG_WARN:
+ id = LOG_WARN;
+ break;
+ case ACR_LOG_INFO:
+ id = LOG_INFO;
+ break;
+ }
+ syslog (id, "%s", J2S(msg));
+ } END_WITH_CSTR(msg);
+}
Propchange: commons/sandbox/runtime/trunk/src/main/native/os/unix/syslog.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/syslog.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/syslog.c?rev=769367&r1=769366&r2=769367&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/syslog.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/syslog.c Tue Apr 28 12:29:15 2009
@@ -91,14 +91,15 @@
}
}
-ACR_JNI_EXPORT_DECLARE(void, Syslog, init0)(ACR_JNISTDARGS)
+ACR_JNI_EXPORT_DECLARE(void, util_Syslog, init0)(ACR_JNISTDARGS)
{
UNREFERENCED_STDARGS;
acr_init_log_source(LOG_MSG_DOMAIN);
}
-ACR_JNI_EXPORT_DECLARE(void, Syslog, init1)(ACR_JNISTDARGS, jstring domain)
+ACR_JNI_EXPORT_DECLARE(void, util_Syslog, init1)(ACR_JNISTDARGS,
+ jstring domain)
{
UNREFERENCED_O;
WITH_CSTR(domain) {
@@ -106,9 +107,9 @@
} END_WITH_CSTR(domain);
}
-ACR_JNI_EXPORT_DECLARE(void, Syslog, log0)(ACR_JNISTDARGS,
- jint level,
- jstring msg)
+ACR_JNI_EXPORT_DECLARE(void, util_Syslog, log0)(ACR_JNISTDARGS,
+ jint level,
+ jstring msg)
{
UNREFERENCED_O;
WITH_WSTR(msg) {
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/string.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/string.c?rev=769367&r1=769366&r2=769367&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/string.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/string.c Tue Apr 28 12:29:15 2009
@@ -314,6 +314,9 @@
jthrowable ee;
char *rs = NULL;
+ if (!str) {
+ return NULL;
+ }
if ((*_E)->EnsureLocalCapacity(_E, 2) < 0) {
/* JNI out of memory error */
return NULL;
@@ -343,6 +346,7 @@
jstring rs;
jbyteArray ba;
jsize sl;
+
if (!str)
return NULL;
if ((*_E)->EnsureLocalCapacity(_E, 2) < 0) {
Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java?rev=769367&r1=769366&r2=769367&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java Tue Apr 28 12:29:15 2009
@@ -35,6 +35,7 @@
suite.addTest(TestProperties.suite());
suite.addTest(TestOS.suite());
suite.addTest(TestUUID.suite());
+ suite.addTest(TestSyslog.suite());
suite.addTest(TestUser.suite());
suite.addTest(TestGroup.suite());
suite.addTest(TestStatus.suite());
Added: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSyslog.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSyslog.java?rev=769367&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSyslog.java (added)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSyslog.java Tue Apr 28 12:29:15 2009
@@ -0,0 +1,50 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime;
+
+import org.apache.commons.runtime.util.Syslog;
+import org.apache.commons.runtime.util.SyslogLevel;
+import java.lang.System;
+import junit.framework.*;
+
+/**
+ * Syslog Test.
+ *
+ */
+public class TestSyslog extends TestCase
+{
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(TestSyslog.class);
+ return suite;
+ }
+
+ protected void setUp()
+ throws Exception
+ {
+ System.loadLibrary("acr");
+ }
+
+ public void testSyslog()
+ throws Exception
+ {
+ Syslog log = new Syslog();
+ assertNotNull("Syslog" + log);
+ log.log(SyslogLevel.INFO, "Syslog test message");
+ }
+
+}
Propchange: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSyslog.java
------------------------------------------------------------------------------
svn:eol-style = native