From 105e8e26231405c8d635039e2d0eb2925f871689 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 5 Jan 2019 18:54:48 -0800 Subject: [PATCH] add logging Keep some stuff added to debug problem with dict checksums on server. --- .../eehouse/android/xw4/DictLangCache.java | 2 +- .../org/eehouse/android/xw4/NetUtils.java | 24 +++++++++++++++++-- xwords4/android/jni/jniutlswrapper.c | 9 +++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictLangCache.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictLangCache.java index 9573533a5..3105ecea9 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictLangCache.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictLangCache.java @@ -326,7 +326,7 @@ public class DictLangCache { public static void inval( final Context context, String name, DictLoc loc, boolean added ) { - DBUtils.dictsRemoveInfo( context, name ); + DBUtils.dictsRemoveInfo( context, DictUtils.removeDictExtn( name ) ); if ( added ) { DictAndLoc dal = new DictAndLoc( name, loc ); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NetUtils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NetUtils.java index 1c07bf43b..3ea61d723 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NetUtils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NetUtils.java @@ -275,8 +275,10 @@ public class NetUtils { } result = new String( bas.toByteArray() ); } else { - Log.w( TAG, "runConn: responseCode: %d for url: %s", - responseCode, conn.getURL() ); + Log.w( TAG, "runConn: responseCode: %d/%s for url: %s", + responseCode, conn.getResponseMessage(), + conn.getURL() ); + logErrorStream( conn.getErrorStream() ); } } catch ( java.net.ProtocolException pe ) { Log.ex( TAG, pe ); @@ -288,6 +290,24 @@ public class NetUtils { return result; } + private static void logErrorStream( InputStream is ) + { + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + for ( ; ; ) { + int length = is.read( buffer ); + if ( length == -1 ) { + break; + } + baos.write( buffer, 0, length ); + } + Log.e( TAG, baos.toString() ); + } catch (Exception ex) { + Log.e( TAG, ex.getMessage() ); + } + } + // This handles multiple params but only every gets passed one! private static String getPostDataString( Map params ) { diff --git a/xwords4/android/jni/jniutlswrapper.c b/xwords4/android/jni/jniutlswrapper.c index 3deccbbdd..fbb54f202 100644 --- a/xwords4/android/jni/jniutlswrapper.c +++ b/xwords4/android/jni/jniutlswrapper.c @@ -103,6 +103,15 @@ and_util_getMD5SumForDict( JNIUtilCtxt* jniutil, const XP_UCHAR* name, jstring result = (*env)->CallObjectMethod( env, jniutil->jjniutil, mid, jname, jbytes ); deleteLocalRefs( env, jname, jbytes, DELETE_NO_REF ); + +#ifdef DEBUG + if ( !!result ) { + const char* chars = (*env)->GetStringUTFChars( env, result, NULL ); + XP_LOGF( "%s(%s, len=%d) => %s", __func__, name, len, chars ); + (*env)->ReleaseStringUTFChars( env, result, chars ); + } +#endif + return result; }