changeset 81:5c8f58479d59

8069058: Logging from native code is disabled Summary: Enable logging from native code. Default severity is ERROR and can't be changed for now. Reviewed-by: raimandi
author snazarki
date Thu, 15 Jan 2015 19:10:10 +0400
parents b4a41ec5f5b2
children 7016cd2773b3
files Makefile src/se/native/com/oracle/dio/dio_common.cpp
diffstat 2 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Tue Dec 30 14:36:06 2014 +0300
+++ b/Makefile	Thu Jan 15 19:10:10 2015 +0400
@@ -144,7 +144,7 @@
 JAR := $(JAVA_HOME)/bin/jar
 MKDIR := mkdir -p
 TARGET_CPU_LEGACY_LIB := arm
-TARGET_C_FLAGS = -fPIC -Wno-psabi -DJAVACALL_REPORT_LEVEL=4 -DENABLE_DEVICEACCESS -c -MMD -MF $(NATIVE_OUT_DIR)/$(@).d
+TARGET_C_FLAGS = -fPIC -Wno-psabi -DJAVACALL_REPORT_LEVEL=0 -DENABLE_DEVICEACCESS -c -MMD -MF $(NATIVE_OUT_DIR)/$(@).d
 TARGET_INCLUDES := $(foreach d,$(DIO_INCLUDE_DIRS),-I$(d)) -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
 TARGET_CXX_FLAGS := -fPIC -Wno-psabi -DJAVACALL_REPORT_LEVEL=4 -DENABLE_DEVICEACCESS -c
 TARGET_LD_FLAGS:= -Xlinker -z -Xlinker defs -Xlinker -O1 \
--- a/src/se/native/com/oracle/dio/dio_common.cpp	Tue Dec 30 14:36:06 2014 +0300
+++ b/src/se/native/com/oracle/dio/dio_common.cpp	Thu Jan 15 19:10:10 2015 +0400
@@ -361,6 +361,8 @@
 
 extern "C" {
 
+static int global_severity = 1; // WARNINGS, ERRORS, CRITICALS
+
 /* Native logging initialization */
 void javacall_logging_initialize(void) {
     // Stubbed, unless this feature is required
@@ -369,12 +371,14 @@
 void javacall_logging_printf(int severity, javacall_logging_channel channelID,
         const char* filename, int lineno, const char *format, ...)
 {
-    va_list args;
-    va_start(args, format);
-    printf("From: %s, line %d\n", filename, lineno);
-    vprintf(format, args);
-    printf("\n");
-    va_end(args);
+    if (severity >= global_severity) {
+        va_list args;
+        va_start(args, format);
+        printf("From: %s, line %d\n", filename, lineno);
+        vprintf(format, args);
+        printf("\n");
+        va_end(args);
+    }
 }
 
 /*******************************************************************************