Log/persist refactoring

This commit is contained in:
M66B
2021-10-22 15:04:16 +02:00
parent e4bb6e183e
commit aced841156
3 changed files with 12 additions and 19 deletions

View File

@@ -19,28 +19,12 @@ package eu.faircode.email;
Copyright 2018-2021 by Marcel Bokhorst (M66B)
*/
import android.content.Context;
public class TrafficStatsHelper {
private static Context ctx;
static void init(Context context) {
ctx = context;
}
public static void connect(String host, int port, String prefix) {
String msg = "Connected " + prefix + " " + host + ":" + port;
if (ctx == null)
Log.i(msg);
else
EntityLog.log(ctx, EntityLog.Type.Statistics, msg);
Log.persist("Connected " + prefix + " " + host + ":" + port);
}
public static void report(String host, String prefix, long sent, long received) {
String msg = "Disconnected " + prefix + " " + host + " tx=" + sent + " rx=" + received;
if (ctx == null)
Log.i(msg);
else
EntityLog.log(ctx, EntityLog.Type.Statistics, msg);
Log.persist("Disconnected " + prefix + " " + host + " tx=" + sent + " rx=" + received);
}
}