Use ISO 8601 format for LocalLog local timestamps
Change to using ISO 8601 duration formatting for LocalLog local timestamps, which makes it consistent with other time / time zone detection dumpsys for easier comparison. LocalLog is used by NetworkStack code as a standalone library, so therefore has to depend on public SDK APIs, hence the use of Duration. The local timestamp logging mode is only currently used for time / time zone detection, which is low-frequency logging. Bug: 204855374 Test: atest core/tests/coretests/src/android/util/LocalLogTest.java Change-Id: Idce0d39c59670facdf48deca852b862ff0d71991
This commit is contained in:
@@ -22,6 +22,7 @@ import android.os.SystemClock;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayDeque;
|
||||
@@ -63,7 +64,8 @@ public final class LocalLog {
|
||||
if (mUseLocalTimestamps) {
|
||||
logLine = LocalDateTime.now() + " - " + msg;
|
||||
} else {
|
||||
logLine = SystemClock.elapsedRealtime() + " / " + Instant.now() + " - " + msg;
|
||||
logLine = Duration.ofMillis(SystemClock.elapsedRealtime())
|
||||
+ " / " + Instant.now() + " - " + msg;
|
||||
}
|
||||
append(logLine);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user