Commit 71a37357 authored by akwizgran's avatar akwizgran

Log more information about deep sleep.

parent 3c3ad79e
......@@ -22,7 +22,7 @@ class SleepMonitor implements Runnable {
* If the difference between uptime and real time changes by more than this amount, assume deep
* sleep has occurred.
*/
private static final int MIN_SLEEP_DURATION_MS = 1000;
private static final int MIN_SLEEP_DURATION_MS = 100;
private final Logger log;
private final ScheduledExecutorService executorService;
......@@ -43,10 +43,20 @@ class SleepMonitor implements Runnable {
@Override
public void run() {
long lastRealtime = realtime;
long sleepDuration = getSleepDuration();
if (sleepDuration > MIN_SLEEP_DURATION_MS) {
String start = getTime(System.currentTimeMillis() - sleepDuration);
log.log("System slept for " + sleepDuration + " ms (since " + start + ")");
long elapsed = realtime - lastRealtime;
long now = System.currentTimeMillis();
String earliestStart = getTime(now - elapsed);
String earliestEnd = getTime(now - elapsed + sleepDuration);
String latestStart = getTime(now - sleepDuration);
String latestEnd = getTime(now);
log.log("System slept for " + sleepDuration
+ " ms since last check " + elapsed
+ " ms ago (earliest " + earliestStart + " - "
+ earliestEnd + ", latest " + latestStart + " - "
+ latestEnd + ")");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment