1
0
mirror of https://github.com/etesync/android synced 2024-12-23 23:18:46 +00:00

Enable verbose logging of allow loggers (for instance, okhttp) / dav4android update

This commit is contained in:
Ricki Hirner 2016-10-04 22:41:52 +02:00
parent 3813c1e0c8
commit 3acc05b605
2 changed files with 10 additions and 12 deletions

View File

@ -17,6 +17,7 @@ import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.os.Process;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.NotificationManagerCompat; import android.support.v4.app.NotificationManagerCompat;
@ -87,9 +88,6 @@ public class App extends Application {
} }
public void reinitLogger() { public void reinitLogger() {
// don't use Android default logging, we have our own handlers
log.setUseParentHandlers(false);
@Cleanup ServiceDB.OpenHelper dbHelper = new ServiceDB.OpenHelper(this); @Cleanup ServiceDB.OpenHelper dbHelper = new ServiceDB.OpenHelper(this);
Settings settings = new Settings(dbHelper.getReadableDatabase()); Settings settings = new Settings(dbHelper.getReadableDatabase());
@ -97,14 +95,14 @@ public class App extends Application {
logVerbose = logToFile || Log.isLoggable(log.getName(), Log.DEBUG); logVerbose = logToFile || Log.isLoggable(log.getName(), Log.DEBUG);
// set logging level according to preferences // set logging level according to preferences
log.setLevel(logVerbose ? Level.ALL : Level.INFO); final Logger rootLogger = Logger.getLogger("");
rootLogger.setLevel(logVerbose ? Level.ALL : Level.INFO);
// remove all handlers // remove all handlers and add our own logcat handler
for (Handler handler : log.getHandlers()) rootLogger.setUseParentHandlers(false);
log.removeHandler(handler); for (Handler handler : rootLogger.getHandlers())
rootLogger.removeHandler(handler);
// add logcat handler rootLogger.addHandler(LogcatHandler.INSTANCE);
log.addHandler(LogcatHandler.INSTANCE);
NotificationManagerCompat nm = NotificationManagerCompat.from(this); NotificationManagerCompat nm = NotificationManagerCompat.from(this);
// log to external file according to preferences // log to external file according to preferences
@ -118,7 +116,7 @@ public class App extends Application {
File dir = getExternalFilesDir(null); File dir = getExternalFilesDir(null);
if (dir != null) if (dir != null)
try { try {
String fileName = new File(dir, "davdroid-" + android.os.Process.myPid() + "-" + String fileName = new File(dir, "davdroid-" + Process.myPid() + "-" +
DateFormatUtils.format(System.currentTimeMillis(), "yyyyMMdd-HHmmss") + ".txt").toString(); DateFormatUtils.format(System.currentTimeMillis(), "yyyyMMdd-HHmmss") + ".txt").toString();
log.info("Logging to " + fileName); log.info("Logging to " + fileName);

@ -1 +1 @@
Subproject commit e70f7a4135b124af9fd696f6863c50ea4c91562f Subproject commit 9a334f69c781be37bd26eca3f18734c5f6826a8e