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:
parent
1fd86211dc
commit
d58a3c9634
9 changed files with 22 additions and 9 deletions
|
@ -132,7 +132,7 @@ public class LogActivity extends SyncthingActivity {
|
||||||
if (syncthingLog) {
|
if (syncthingLog) {
|
||||||
pb = new ProcessBuilder("/system/bin/logcat", "-t", "300", "-v", "raw", "-s", "SyncthingNativeCode");
|
pb = new ProcessBuilder("/system/bin/logcat", "-t", "300", "-v", "raw", "-s", "SyncthingNativeCode");
|
||||||
} else {
|
} 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);
|
pb.redirectErrorStream(true);
|
||||||
process = pb.start();
|
process = pb.start();
|
||||||
|
|
|
@ -100,8 +100,8 @@ public abstract class ApiRequest {
|
||||||
}, error -> {
|
}, error -> {
|
||||||
if (errorListener != null)
|
if (errorListener != null)
|
||||||
errorListener.onError(error);
|
errorListener.onError(error);
|
||||||
|
else
|
||||||
Log.w(TAG, "Request to " + uri + " failed: " + error.getMessage());
|
Log.w(TAG, "Request to " + uri + " failed", error);
|
||||||
}) {
|
}) {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getHeaders() throws AuthFailureError {
|
public Map<String, String> getHeaders() throws AuthFailureError {
|
||||||
|
|
|
@ -4,10 +4,12 @@ package com.nutomic.syncthingandroid.http;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.volley.Request;
|
import com.android.volley.Request;
|
||||||
import com.android.volley.VolleyError;
|
import com.android.volley.VolleyError;
|
||||||
|
|
||||||
|
import java.net.ConnectException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
|
@ -16,6 +18,7 @@ import java.util.Collections;
|
||||||
*/
|
*/
|
||||||
public class PollWebGuiAvailableTask extends ApiRequest {
|
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
|
* Interval in ms, at which connections to the web gui are performed on first start
|
||||||
* to find out if it's online.
|
* to find out if it's online.
|
||||||
|
@ -28,6 +31,7 @@ public class PollWebGuiAvailableTask extends ApiRequest {
|
||||||
public PollWebGuiAvailableTask(Context context, URL url, String apiKey,
|
public PollWebGuiAvailableTask(Context context, URL url, String apiKey,
|
||||||
OnSuccessListener listener) {
|
OnSuccessListener listener) {
|
||||||
super(context, url, "", apiKey);
|
super(context, url, "", apiKey);
|
||||||
|
Log.i(TAG, "Starting to poll for web gui availability");
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
performRequest();
|
performRequest();
|
||||||
}
|
}
|
||||||
|
@ -39,6 +43,13 @@ public class PollWebGuiAvailableTask extends ApiRequest {
|
||||||
|
|
||||||
private void onError(VolleyError error) {
|
private void onError(VolleyError error) {
|
||||||
mHandler.postDelayed(this::performRequest, WEB_GUI_POLL_INTERVAL);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ public class EventProcessor implements SyncthingService.OnWebGuiAvailableListene
|
||||||
// Ignored.
|
// Ignored.
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log.i(TAG, "Unhandled event " + event.type);
|
Log.v(TAG, "Unhandled event " + event.type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,6 +120,7 @@ public class SyncthingRunnable implements Runnable {
|
||||||
niceSyncthing();
|
niceSyncthing();
|
||||||
|
|
||||||
ret = process.waitFor();
|
ret = process.waitFor();
|
||||||
|
Log.i(TAG, "Syncthing exited with code " + ret);
|
||||||
mSyncthing.set(null);
|
mSyncthing.set(null);
|
||||||
lInfo.join();
|
lInfo.join();
|
||||||
lWarn.join();
|
lWarn.join();
|
||||||
|
|
|
@ -306,6 +306,7 @@ public class SyncthingService extends Service implements
|
||||||
* Sets {@link #mCurrentState} to newState, and calls onKilledListener once Syncthing is killed.
|
* Sets {@link #mCurrentState} to newState, and calls onKilledListener once Syncthing is killed.
|
||||||
*/
|
*/
|
||||||
private void shutdown(State newState, SyncthingRunnable.OnSyncthingKilled onKilledListener) {
|
private void shutdown(State newState, SyncthingRunnable.OnSyncthingKilled onKilledListener) {
|
||||||
|
Log.i(TAG, "Shutting down background service");
|
||||||
onApiChange(newState);
|
onApiChange(newState);
|
||||||
|
|
||||||
if (mEventProcessor != null)
|
if (mEventProcessor != null)
|
||||||
|
|
|
@ -79,6 +79,7 @@ public class ConfigXml {
|
||||||
Log.w(TAG, "Cannot read '" + mConfigFile + "'", e);
|
Log.w(TAG, "Cannot read '" + mConfigFile + "'", e);
|
||||||
throw new OpenConfigException();
|
throw new OpenConfigException();
|
||||||
}
|
}
|
||||||
|
Log.i(TAG, "Loaded Syncthing config file");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateKeysConfig(Context context) {
|
private void generateKeysConfig(Context context) {
|
||||||
|
|
|
@ -31,6 +31,7 @@ public class FolderObserver extends FileObserver {
|
||||||
public FolderObserver(OnFolderFileChangeListener listener, Folder folder)
|
public FolderObserver(OnFolderFileChangeListener listener, Folder folder)
|
||||||
throws FolderNotExistingException {
|
throws FolderNotExistingException {
|
||||||
this(listener, folder, "");
|
this(listener, folder, "");
|
||||||
|
Log.i(TAG, "Observer created for (folder " + folder.id + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FolderNotExistingException extends Exception {
|
public class FolderNotExistingException extends Exception {
|
||||||
|
@ -62,7 +63,7 @@ public class FolderObserver extends FileObserver {
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
mFolder = folder;
|
mFolder = folder;
|
||||||
mPath = path;
|
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();
|
startWatching();
|
||||||
|
|
||||||
File currentFolder = new File(folder.path, path);
|
File currentFolder = new File(folder.path, path);
|
||||||
|
|
|
@ -5,13 +5,11 @@
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/switch_logs"
|
android:id="@+id/switch_logs"
|
||||||
android:title="@string/view_android_log"
|
android:title="@string/view_android_log" />
|
||||||
app:showAsAction="ifRoom" />
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_share"
|
android:id="@+id/menu_share"
|
||||||
android:title="@string/share_title"
|
android:title="@string/share_title"
|
||||||
app:actionProviderClass="android.support.v7.widget.ShareActionProvider"
|
app:actionProviderClass="android.support.v7.widget.ShareActionProvider" />
|
||||||
app:showAsAction="ifRoom" />
|
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
|
|
Loading…
Reference in a new issue