diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-08-31 16:17:04 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-08-31 16:17:04 +0000 |
commit | c39ea3c55fac807c0b98aabdf56c70dc8a49036c (patch) | |
tree | e282668a9587cf6c1ec7b604dea860400c75c6c7 /java/com/android/dialer/persistentlog/PersistentLogger.java | |
parent | 68038172793ee0e2ab3e2e56ddfbeb82879d1f58 (diff) | |
parent | 2ca4318cc1ee57dda907ba2069bd61d162b1baef (diff) |
Merge "Update Dialer source to latest internal Google revision."
Diffstat (limited to 'java/com/android/dialer/persistentlog/PersistentLogger.java')
-rw-r--r-- | java/com/android/dialer/persistentlog/PersistentLogger.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/java/com/android/dialer/persistentlog/PersistentLogger.java b/java/com/android/dialer/persistentlog/PersistentLogger.java index cf43b8ca8..5fdefd174 100644 --- a/java/com/android/dialer/persistentlog/PersistentLogger.java +++ b/java/com/android/dialer/persistentlog/PersistentLogger.java @@ -26,6 +26,7 @@ import android.support.annotation.WorkerThread; import android.support.v4.os.UserManagerCompat; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; +import com.android.dialer.strictmode.DialerStrictMode; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -43,7 +44,7 @@ import java.util.concurrent.LinkedBlockingQueue; * com.google.android.apps.dialer.crashreporter.SilentCrashReporter} is expected to handle such * cases. * - * <p>{@link #logText(String, String)} should be used to log ad-hoc text logs. TODO: switch + * <p>{@link #logText(String, String)} should be used to log ad-hoc text logs. TODO(twyen): switch * to structured logging */ public final class PersistentLogger { @@ -110,6 +111,16 @@ public final class PersistentLogger { loggerThreadHandler.sendEmptyMessageDelayed(MESSAGE_FLUSH, FLUSH_DELAY_MILLIS); } + @VisibleForTesting + /** write raw bytes directly to the log file, likely corrupting it. */ + static void rawLogForTest(byte[] data) { + try { + fileHandler.writeRawLogsForTest(data); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + /** Dump the log as human readable string. Blocks until the dump is finished. */ @NonNull @WorkerThread @@ -167,7 +178,7 @@ public final class PersistentLogger { } private static byte[] buildTextLog(String tag, String string) { - Calendar c = Calendar.getInstance(); + Calendar c = DialerStrictMode.bypass(() -> Calendar.getInstance()); return String.format("%tm-%td %tH:%tM:%tS.%tL - %s - %s", c, c, c, c, c, c, tag, string) .getBytes(StandardCharsets.UTF_8); } |