Fixed logger on Android 4.x

This commit is contained in:
PeratX 2017-05-26 14:45:01 +08:00
parent 7e3ddf3877
commit d71bd53072
7 changed files with 12 additions and 11 deletions

View File

@ -20,6 +20,7 @@ import de.measite.minidns.util.InetAddressUtil;
import org.itxtech.daedalus.Daedalus;
import org.itxtech.daedalus.R;
import org.itxtech.daedalus.util.DnsServerHelper;
import org.itxtech.daedalus.util.Logger;
import java.io.IOException;
import java.net.InetAddress;
@ -83,7 +84,7 @@ public class DnsTestFragment extends ToolbarFragment {
}
mHandler.obtainMessage(DnsTestHandler.MSG_TEST_DONE).sendToTarget();
} catch (Exception e) {
Log.e(TAG, e.toString());
Logger.logException(e);
}
}
@ -119,7 +120,7 @@ public class DnsTestFragment extends ToolbarFragment {
} catch (Exception e) {
testText.append("\n").append(getResources().getString(R.string.test_failed)).append("\n\n");
Log.e(TAG, e.toString());
Logger.logException(e);
}
mHandler.obtainMessage(DnsTestHandler.MSG_DISPLAY_STATUS, testText.toString()).sendToTarget();

View File

@ -17,6 +17,7 @@ import android.view.ViewGroup;
import org.itxtech.daedalus.Daedalus;
import org.itxtech.daedalus.R;
import org.itxtech.daedalus.activity.ConfigActivity;
import org.itxtech.daedalus.util.Logger;
import org.itxtech.daedalus.util.Rule;
import org.itxtech.daedalus.widget.ClickPreference;
@ -143,7 +144,7 @@ public class RuleConfigFragment extends ConfigFragment {
new RuleData(ruleFilename.getText(), builder.toString())).sendToTarget();
stopThread();
} catch (Exception e) {
e.printStackTrace();
Logger.logException(e);
} finally {
stopThread();
}
@ -315,7 +316,7 @@ public class RuleConfigFragment extends ConfigFragment {
stream.write(ruleData.getData().getBytes());
stream.close();
} catch (Exception e) {
e.printStackTrace();
Logger.logException(e);
}
Snackbar.make(view, R.string.notice_downloaded, Snackbar.LENGTH_SHORT)

View File

@ -154,7 +154,7 @@ public class UdpDnsProvider extends DnsProvider {
service.providerLoopCallback();
}
} catch (Exception e) {
e.printStackTrace();
Logger.logException(e);
}
}

View File

@ -242,6 +242,7 @@ public class DaedalusVpnService extends VpnService implements Runnable {
Thread.sleep(1000);
}
}
} catch (InterruptedException ignored) {
} catch (Exception e) {
Logger.logException(e);
} finally {

View File

@ -137,7 +137,7 @@ public class Configurations {
writer.flush();
writer.close();
} catch (IOException e) {
e.printStackTrace();
Logger.logException(e);
}
}
}

View File

@ -77,7 +77,7 @@ public class Logger {
}
private static void send(String message) {
String fileDateFormat = new SimpleDateFormat("Y-M-d HH:mm:ss ").format(new Date());
String fileDateFormat = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss ").format(new Date());
builder.insert(0, "\n").insert(0, message).insert(0, fileDateFormat);
Log.d("Daedalus", message);
}

View File

@ -1,7 +1,5 @@
package org.itxtech.daedalus.util;
import android.util.Log;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@ -150,7 +148,7 @@ public class RulesResolver implements Runnable {
}
status = STATUS_LOADED;
} catch (Exception e) {
Log.e(TAG, e.toString());
Logger.logException(e);
status = STATUS_NOT_LOADED;
}
@ -166,7 +164,7 @@ public class RulesResolver implements Runnable {
Thread.sleep(100);
}
} catch (Exception e) {
Log.e(TAG, e.toString());
Logger.logException(e);
}
}
}