Преглед изворни кода

Add code to send error messages to Android LogCat.

mingodad пре 13 година
родитељ
комит
dee70e666a
1 измењених фајлова са 13 додато и 1 уклоњено
  1. 13 1
      ext/sq_mongoose.cpp

+ 13 - 1
ext/sq_mongoose.cpp

@@ -1043,13 +1043,19 @@ SQUIRREL_API SQRESULT sqext_register_sq_socket(HSQUIRRELVM v);
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
 } /*extern "C"*/
 } /*extern "C"*/
-#endif
+#endif
 
 
 void sq_printfunc(HSQUIRRELVM v,const SQChar *s,...)
 void sq_printfunc(HSQUIRRELVM v,const SQChar *s,...)
 {
 {
 	va_list vl;
 	va_list vl;
 	va_start(vl, s);
 	va_start(vl, s);
+#ifdef JNI_ENABLE_LOG
+    char buf[2048];
+    vsnprintf(buf, sizeof(buf), s, vl);
+    jniLog(-1, buf);
+#else
 	vfprintf(stdout, s, vl);
 	vfprintf(stdout, s, vl);
+#endif
 	va_end(vl);
 	va_end(vl);
 }
 }
 
 
@@ -1057,7 +1063,13 @@ void sq_errorfunc(HSQUIRRELVM v,const SQChar *s,...)
 {
 {
 	va_list vl;
 	va_list vl;
 	va_start(vl, s);
 	va_start(vl, s);
+#ifdef JNI_ENABLE_LOG
+    char buf[2048];
+    vsnprintf(buf, sizeof(buf), s, vl);
+    jniLog(-2, buf);
+#else
 	vfprintf(stderr, s, vl);
 	vfprintf(stderr, s, vl);
+#endif
 	va_end(vl);
 	va_end(vl);
 }
 }