OVERVIEW & NOTIFICATION logging cleanup

This commit is contained in:
Milos Kozak 2018-07-27 14:01:56 +02:00
parent 6a058f5036
commit 9141e0f66d
9 changed files with 167 additions and 157 deletions

View file

@ -37,6 +37,8 @@ public class Config {
public static final boolean logEvents = false;
public static final boolean logQueue = true;
public static final boolean logBgSource = true;
public static final boolean logOverview = true;
public static final boolean logNotification = true;
// DanaR specific
public static final boolean logDanaBTComm = true;

View file

@ -73,4 +73,6 @@ public class Constants {
public static final String EVENTS = "EVENTS";
public static final String QUEUE = "QUEUE";
public static final String BGSOURCE = "BGSOURCE";
public static final String OVERVIEW = "OVERVIEW";
public static final String NOTIFICATION = "NOTIFICATION";
}

View file

@ -126,7 +126,7 @@ import info.nightscout.utils.ToastUtils;
import static info.nightscout.utils.DateUtil.now;
public class OverviewFragment extends Fragment implements View.OnClickListener, View.OnLongClickListener {
private static Logger log = LoggerFactory.getLogger(OverviewFragment.class);
private static Logger log = LoggerFactory.getLogger(Constants.OVERVIEW);
TextView timeView;
TextView bgView;
@ -201,7 +201,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try {
//check screen width
final DisplayMetrics dm = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
@ -332,12 +331,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
setupChartMenu(view);
return view;
} catch (Exception e) {
FabricPrivacy.logException(e);
log.debug("Runtime Exception", e);
}
return null;
}
private void setupChartMenu(View view) {
@ -833,6 +826,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> {
synchronized (builder) {
if (accepted) {
if (Config.logOverview)
log.debug("guarding: already accepted");
return;
}
@ -1038,6 +1032,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
@SuppressLint("SetTextI18n")
public void updateGUI(final String from) {
if (Config.logOverview)
log.debug("updateGUI entered from: " + from);
final Date updateGUIStart = new Date();
@ -1433,6 +1428,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
final long now = System.currentTimeMillis();
// ------------------ 1st graph
if (Config.logOverview)
Profiler.log(log, from + " - 1st graph - START", updateGUIStart);
final GraphData graphData = new GraphData(bgGraph, IobCobCalculatorPlugin.getPlugin());
@ -1465,6 +1461,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
graphData.addNowLine(now);
// ------------------ 2nd graph
if (Config.logOverview)
Profiler.log(log, from + " - 2nd graph - START", updateGUIStart);
final GraphData secondGraphData = new GraphData(iobGraph, IobCobCalculatorPlugin.getPlugin());
@ -1519,11 +1516,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// finally enforce drawing of graphs
graphData.performUpdate();
secondGraphData.performUpdate();
if (Config.logOverview)
Profiler.log(log, from + " - onDataChanged", updateGUIStart);
});
}
}).start();
if (Config.logOverview)
Profiler.log(log, from, updateGUIStart);
}

View file

@ -7,6 +7,7 @@ import org.json.JSONException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile;
@ -24,7 +25,7 @@ import info.nightscout.utils.SP;
* Created by mike on 05.08.2016.
*/
public class OverviewPlugin extends PluginBase {
private static Logger log = LoggerFactory.getLogger(OverviewPlugin.class);
private static Logger log = LoggerFactory.getLogger(Constants.OVERVIEW);
private static OverviewPlugin overviewPlugin = new OverviewPlugin();

View file

@ -7,7 +7,6 @@ import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.events.Event;
public class EventOverviewBolusProgress extends Event {
private static Logger log = LoggerFactory.getLogger(EventOverviewBolusProgress.class);
public String status = "";
public Treatment t = null;
public int percent = 0;

View file

@ -18,6 +18,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
@ -50,7 +51,7 @@ import info.nightscout.utils.Round;
*/
public class GraphData {
private static Logger log = LoggerFactory.getLogger(GraphData.class);
private static Logger log = LoggerFactory.getLogger(Constants.OVERVIEW);
private GraphView graph;
public double maxY = Double.MIN_VALUE;
@ -74,6 +75,7 @@ public class GraphData {
List<DataPointWithLabelInterface> bgListArray = new ArrayList<>();
if (bgReadingsArray == null || bgReadingsArray.size() == 0) {
if (Config.logOverview)
log.debug("No BG data.");
return;
}

View file

@ -20,8 +20,6 @@ import info.nightscout.utils.SP;
*/
public class Notification {
private static Logger log = LoggerFactory.getLogger(Notification.class);
public static final int URGENT = 0;
public static final int NORMAL = 1;
public static final int LOW = 2;

View file

@ -15,6 +15,8 @@ import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.Objects;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastAckAlarm;
@ -24,7 +26,7 @@ import info.nightscout.utils.DateUtil;
import info.nightscout.utils.SP;
public class NotificationRecyclerViewAdapter extends RecyclerView.Adapter<NotificationRecyclerViewAdapter.NotificationsViewHolder> {
private static Logger log = LoggerFactory.getLogger(NotificationRecyclerViewAdapter.class);
private static Logger log = LoggerFactory.getLogger(Constants.NOTIFICATION);
private List<Notification> notificationsList;
@ -96,10 +98,12 @@ public class NotificationRecyclerViewAdapter extends RecyclerView.Adapter<Notifi
BroadcastAckAlarm.handleClearAlarm(notification.nsAlarm, MainApp.instance().getApplicationContext(), 60 * 60 * 1000L);
}
// Adding current time to snooze if we got staleData
if (Config.logNotification)
log.debug("Notification text is: " + notification.text);
if (notification.text.equals(MainApp.gs(R.string.nsalarm_staledata))) {
NotificationStore nstore = OverviewPlugin.getPlugin().notificationStore;
long msToSnooze = SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L;
if (Config.logNotification)
log.debug("snooze nsalarm_staledatavalue in minutes is " + SP.getInt("nsalarm_staledatavalue", 15) + "\n in ms is: " + msToSnooze + " currentTimeMillis is: " + System.currentTimeMillis());
nstore.snoozeTo(System.currentTimeMillis() + (SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L));
}

View file

@ -22,6 +22,7 @@ import java.util.Comparator;
import java.util.List;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.AlarmSoundService;
@ -33,11 +34,10 @@ import info.nightscout.utils.SP;
public class NotificationStore {
public static final String CHANNEL_ID = "AndroidAPS-Overview";
private static final String CHANNEL_ID = "AndroidAPS-Overview";
private static Logger log = LoggerFactory.getLogger(NotificationStore.class);
public List<Notification> store = new ArrayList<Notification>();
public long snoozedUntil = 0L;
private static Logger log = LoggerFactory.getLogger(Constants.NOTIFICATION);
public List<Notification> store = new ArrayList<>();
private boolean usesChannels;
public NotificationStore() {
@ -52,7 +52,8 @@ public class NotificationStore {
}
public synchronized boolean add(Notification n) {
log.info("Notification received: " + n.text);
if (Config.logNotification)
log.debug("Notification received: " + n.text);
for (Notification storeNotification : store) {
if (storeNotification.id == n.id) {
storeNotification.date = n.date;
@ -107,6 +108,7 @@ public class NotificationStore {
}
public void snoozeTo(long timeToSnooze) {
if (Config.logNotification)
log.debug("Snoozing alarm until: " + timeToSnooze);
SP.putLong("snoozedTo", timeToSnooze);
}
@ -116,6 +118,7 @@ public class NotificationStore {
Notification notification = new Notification(Notification.NSALARM, MainApp.gs(R.string.nsalarm_staledata), Notification.URGENT);
SP.putLong("snoozedTo", System.currentTimeMillis());
add(notification);
if (Config.logNotification)
log.debug("Snoozed to current time and added back notification!");
}
}
@ -125,7 +128,7 @@ public class NotificationStore {
NotificationManager mgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Bitmap largeIcon = BitmapFactory.decodeResource(context.getResources(), R.mipmap.blueowl);
int smallIcon = R.drawable.ic_notification;
if (Config.NSCLIENT || Config.G5UPLOADER){
if (Config.NSCLIENT || Config.G5UPLOADER) {
largeIcon = BitmapFactory.decodeResource(MainApp.instance().getResources(), R.mipmap.yellowowl);
smallIcon = R.drawable.nsclient_smallicon;
}