Skip to content

Commit

Permalink
Improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutomic committed Oct 6, 2017
1 parent 1fd8621 commit d58a3c9
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private String getLog(final boolean syncthingLog) {
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ protected void connect(int requestMethod, Uri uri, @Nullable String requestBody,
}, 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
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;

Expand All @@ -16,6 +18,7 @@
*/
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.
Expand All @@ -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();
}
Expand All @@ -39,6 +43,13 @@ private void performRequest() {

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);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void onEvent(Event event) {
// Ignored.
break;
default:
Log.i(TAG, "Unhandled event " + event.type);
Log.v(TAG, "Unhandled event " + event.type);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public void run() {
niceSyncthing();

ret = process.waitFor();
Log.i(TAG, "Syncthing exited with code " + ret);
mSyncthing.set(null);
lInfo.join();
lWarn.join();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ public void onDestroy() {
* 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ private void readConfig() {
Log.w(TAG, "Cannot read '" + mConfigFile + "'", e);
throw new OpenConfigException();
}
Log.i(TAG, "Loaded Syncthing config file");
}

private void generateKeysConfig(Context context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public interface OnFolderFileChangeListener {
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 {
Expand Down Expand Up @@ -62,7 +63,7 @@ private FolderObserver(OnFolderFileChangeListener listener, Folder folder, Strin
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);
Expand Down
6 changes: 2 additions & 4 deletions src/main/res/menu/log_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit d58a3c9

Please sign in to comment.