1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-23 11:21:29 +00:00

Improve logging

This commit is contained in:
Felix Ableitner 2017-10-07 02:02:27 +09:00
parent 1fd86211dc
commit d58a3c9634
9 changed files with 22 additions and 9 deletions

View file

@ -132,7 +132,7 @@ public class LogActivity extends SyncthingActivity {
if (syncthingLog) {
pb = new ProcessBuilder("/system/bin/logcat", "-t", "300", "-v", "raw", "-s", "SyncthingNativeCode");
} else {
pb = new ProcessBuilder("/system/bin/logcat", "-t", "300", "-v", "time", "'*'");
pb = new ProcessBuilder("/system/bin/logcat", "-t", "300", "-v", "time", "*:i ps:s art:s");
}
pb.redirectErrorStream(true);
process = pb.start();

View file

@ -100,8 +100,8 @@ public abstract class ApiRequest {
}, error -> {
if (errorListener != null)
errorListener.onError(error);
Log.w(TAG, "Request to " + uri + " failed: " + error.getMessage());
else
Log.w(TAG, "Request to " + uri + " failed", error);
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {

View file

@ -4,10 +4,12 @@ package com.nutomic.syncthingandroid.http;
import android.content.Context;
import android.net.Uri;
import android.os.Handler;
import android.util.Log;
import com.android.volley.Request;
import com.android.volley.VolleyError;
import java.net.ConnectException;
import java.net.URL;
import java.util.Collections;
@ -16,6 +18,7 @@ import java.util.Collections;
*/
public class PollWebGuiAvailableTask extends ApiRequest {
private static final String TAG = "PollWebGuiAvailableTask";
/**
* Interval in ms, at which connections to the web gui are performed on first start
* to find out if it's online.
@ -28,6 +31,7 @@ public class PollWebGuiAvailableTask extends ApiRequest {
public PollWebGuiAvailableTask(Context context, URL url, String apiKey,
OnSuccessListener listener) {
super(context, url, "", apiKey);
Log.i(TAG, "Starting to poll for web gui availability");
mListener = listener;
performRequest();
}
@ -39,6 +43,13 @@ public class PollWebGuiAvailableTask extends ApiRequest {
private void onError(VolleyError error) {
mHandler.postDelayed(this::performRequest, WEB_GUI_POLL_INTERVAL);
Throwable cause = error.getCause();
if (cause == null || cause.getClass().equals(ConnectException.class)) {
Log.v(TAG, "Polling web gui");
} else {
Log.w(TAG, "Unexpected error while polling web gui", error);
}
}
}

View file

@ -154,7 +154,7 @@ public class EventProcessor implements SyncthingService.OnWebGuiAvailableListene
// Ignored.
break;
default:
Log.i(TAG, "Unhandled event " + event.type);
Log.v(TAG, "Unhandled event " + event.type);
}
}

View file

@ -120,6 +120,7 @@ public class SyncthingRunnable implements Runnable {
niceSyncthing();
ret = process.waitFor();
Log.i(TAG, "Syncthing exited with code " + ret);
mSyncthing.set(null);
lInfo.join();
lWarn.join();

View file

@ -306,6 +306,7 @@ public class SyncthingService extends Service implements
* Sets {@link #mCurrentState} to newState, and calls onKilledListener once Syncthing is killed.
*/
private void shutdown(State newState, SyncthingRunnable.OnSyncthingKilled onKilledListener) {
Log.i(TAG, "Shutting down background service");
onApiChange(newState);
if (mEventProcessor != null)

View file

@ -79,6 +79,7 @@ public class ConfigXml {
Log.w(TAG, "Cannot read '" + mConfigFile + "'", e);
throw new OpenConfigException();
}
Log.i(TAG, "Loaded Syncthing config file");
}
private void generateKeysConfig(Context context) {

View file

@ -31,6 +31,7 @@ public class FolderObserver extends FileObserver {
public FolderObserver(OnFolderFileChangeListener listener, Folder folder)
throws FolderNotExistingException {
this(listener, folder, "");
Log.i(TAG, "Observer created for (folder " + folder.id + ")");
}
public class FolderNotExistingException extends Exception {
@ -62,7 +63,7 @@ public class FolderObserver extends FileObserver {
mListener = listener;
mFolder = folder;
mPath = path;
Log.v(TAG, "observer created for " + new File(mFolder.path, mPath).toString() + " (folder " + folder.id + ")");
Log.v(TAG, "Observer created for " + new File(mFolder.path, mPath).toString() + " (folder " + folder.id + ")");
startWatching();
File currentFolder = new File(folder.path, path);

View file

@ -5,13 +5,11 @@
<item
android:id="@+id/switch_logs"
android:title="@string/view_android_log"
app:showAsAction="ifRoom" />
android:title="@string/view_android_log" />
<item
android:id="@+id/menu_share"
android:title="@string/share_title"
app:actionProviderClass="android.support.v7.widget.ShareActionProvider"
app:showAsAction="ifRoom" />
app:actionProviderClass="android.support.v7.widget.ShareActionProvider" />
</menu>