Add helpers method to SharedLog
Bug: 294326360
Test: atest FrameworksNetTests
Change-Id: Ib8ba3e9a556a70de28813465396c6609b7c22333
diff --git a/staticlibs/device/com/android/net/module/util/SharedLog.java b/staticlibs/device/com/android/net/module/util/SharedLog.java
index 17b061e..6b12c80 100644
--- a/staticlibs/device/com/android/net/module/util/SharedLog.java
+++ b/staticlibs/device/com/android/net/module/util/SharedLog.java
@@ -46,6 +46,8 @@
ERROR,
MARK,
WARN,
+ VERBOSE,
+ TERRIBLE,
}
private final LocalLog mLocalLog;
@@ -159,6 +161,41 @@
Log.w(mTag, record(Category.WARN, msg));
}
+ /**
+ * Log a verbose message.
+ *
+ * <p>The log entry will be also added to the system log.
+ */
+ public void v(String msg) {
+ Log.v(mTag, record(Category.VERBOSE, msg));
+ }
+
+ /**
+ * Log a terrible failure message.
+ *
+ * <p>The log entry will be also added to the system log and will trigger system reporting
+ * for terrible failures.
+ */
+ public void wtf(String msg) {
+ Log.wtf(mTag, record(Category.TERRIBLE, msg));
+ }
+
+ /**
+ * Log a terrible failure due to an exception, with the exception stacktrace if provided.
+ *
+ * <p>The error and exception message appear in the shared log, but the stacktrace is only
+ * logged in general log output (logcat). The log entry will be also added to the system log
+ * and will trigger system reporting for terrible failures.
+ */
+ public void wtf(@NonNull String msg, @Nullable Throwable exception) {
+ if (exception == null) {
+ e(msg);
+ return;
+ }
+ Log.wtf(mTag, record(Category.TERRIBLE, msg + ": " + exception.getMessage()), exception);
+ }
+
+
//////
// Methods that only log an entry (and do NOT emit to the system log).
//////