]> sjero.net Git - linphone/commitdiff
Fix logging for tunnel on Android.
authorGhislain MARY <ghislain.mary@belledonne-communications.com>
Thu, 3 Jan 2013 15:14:35 +0000 (16:14 +0100)
committerGhislain MARY <ghislain.mary@belledonne-communications.com>
Thu, 3 Jan 2013 15:14:35 +0000 (16:14 +0100)
coreapi/TunnelManager.cc
coreapi/linphonecore_jni.cc

index 028191ed0342f633026d06ce70a6341cac08fd4a..8ce6da7e59234c33d161baa071497d7d0453fb12 100644 (file)
@@ -355,7 +355,8 @@ void TunnelManager::sOnIterate(TunnelManager *zis){
 }
 
 #ifdef ANDROID
-static void linphone_android_log_handler(int lev, const char *fmt, va_list args){
+extern void linphone_android_log_handler(int prio, const char *fmt, va_list args);
+static void linphone_android_tunnel_log_handler(int lev, const char *fmt, va_list args) {
        int prio;
        switch(lev){
        case TUNNEL_DEBUG:      prio = ANDROID_LOG_DEBUG;       break;
@@ -363,9 +364,9 @@ static void linphone_android_log_handler(int lev, const char *fmt, va_list args)
        case TUNNEL_NOTICE:     prio = ANDROID_LOG_INFO;        break;
        case TUNNEL_WARN:       prio = ANDROID_LOG_WARN;        break;
        case TUNNEL_ERROR:      prio = ANDROID_LOG_ERROR;       break;
-       default:                        prio = ANDROID_LOG_DEFAULT;     break;
+       default:                prio = ANDROID_LOG_DEFAULT;     break;
        }
-       __android_log_vprint(prio, LOG_DOMAIN, fmt, args);
+       linphone_android_log_handler(prio, fmt, args);
 }
 #endif /*ANDROID*/
 
@@ -376,7 +377,7 @@ void TunnelManager::enableLogs(bool value) {
 void TunnelManager::enableLogs(bool isEnabled,LogHandler logHandler) {
        if (logHandler != NULL) SetLogHandler(logHandler);
 #ifdef ANDROID
-       else SetLogHandler(linphone_android_log_handler);
+       else SetLogHandler(linphone_android_tunnel_log_handler);
 #else
        else SetLogHandler(default_log_handler);
 #endif
index 102d2177799cafc509a1d2daafdc297be426bb11..2303cc5b15108af6d159cdb4bc890da7b37b8b38 100644 (file)
@@ -55,22 +55,14 @@ static JavaVM *jvm=0;
 static const char* LogDomain = "Linphone";
 
 #ifdef ANDROID
-static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){
-       int prio;
-       char str[4096];
+void linphone_android_log_handler(int prio, const char *fmt, va_list args) {
+       char str[4096];
        char *current;
        char *next;
-       switch(lev){
-       case ORTP_DEBUG:        prio = ANDROID_LOG_DEBUG;       break;
-       case ORTP_MESSAGE:      prio = ANDROID_LOG_INFO;        break;
-       case ORTP_WARNING:      prio = ANDROID_LOG_WARN;        break;
-       case ORTP_ERROR:        prio = ANDROID_LOG_ERROR;       break;
-       case ORTP_FATAL:        prio = ANDROID_LOG_FATAL;       break;
-       default:                prio = ANDROID_LOG_DEFAULT;     break;
-       }
-       vsnprintf(str, sizeof(str) - 1, fmt, args);
-       str[sizeof(str) - 1] = '\0';
-       if (strlen(str) < 512) {
+
+       vsnprintf(str, sizeof(str) - 1, fmt, args);
+       str[sizeof(str) - 1] = '\0';
+       if (strlen(str) < 512) {
                __android_log_write(prio, LogDomain, str);
        } else {
                current = str;
@@ -83,6 +75,19 @@ static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_l
        }
 }
 
+static void linphone_android_ortp_log_handler(OrtpLogLevel lev, const char *fmt, va_list args) {
+       int prio;
+       switch(lev){
+       case ORTP_DEBUG:        prio = ANDROID_LOG_DEBUG;       break;
+       case ORTP_MESSAGE:      prio = ANDROID_LOG_INFO;        break;
+       case ORTP_WARNING:      prio = ANDROID_LOG_WARN;        break;
+       case ORTP_ERROR:        prio = ANDROID_LOG_ERROR;       break;
+       case ORTP_FATAL:        prio = ANDROID_LOG_FATAL;       break;
+       default:                prio = ANDROID_LOG_DEFAULT;     break;
+       }
+       linphone_android_log_handler(prio, fmt, args);
+}
+
 int dumbMethodForAllowingUsageOfCpuFeaturesFromStaticLibMediastream() {
        return (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0);
 }
@@ -105,7 +110,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIE
                ,jstring  jdebugTag) {
        if (isDebug) {
                LogDomain = env->GetStringUTFChars(jdebugTag, NULL);
-               linphone_core_enable_logs_with_cb(linphone_android_log_handler);
+               linphone_core_enable_logs_with_cb(linphone_android_ortp_log_handler);
        } else {
                linphone_core_disable_logs();
        }