Loading core/java/android/util/Log.java +22 −3 Original line number Diff line number Diff line Loading @@ -84,14 +84,14 @@ public final class Log { public static final int ASSERT = 7; /** * Exception class used to capture a stack trace in {@link #wtf()}. * Exception class used to capture a stack trace in {@link #wtf}. */ private static class TerribleFailure extends Exception { TerribleFailure(String msg, Throwable cause) { super(msg, cause); } } /** * Interface to handle terrible failures from {@link #wtf()}. * Interface to handle terrible failures from {@link #wtf}. * * @hide */ Loading Loading @@ -256,6 +256,15 @@ public final class Log { return wtf(tag, msg, null); } /** * Like {@link #wtf(String, String)}, but also writes to the log the full * call stack. * @hide */ public static int wtfStack(String tag, String msg) { return wtfStack(LOG_ID_MAIN, tag, msg); } /** * What a Terrible Failure: Report an exception that should never happen. * Similar to {@link #wtf(String, String)}, with an exception to log. Loading @@ -274,8 +283,18 @@ public final class Log { * @param tr An exception to log. May be null. */ public static int wtf(String tag, String msg, Throwable tr) { return wtf(LOG_ID_MAIN, tag, msg, tr); } static int wtfStack(int logId, String tag, String msg) { TerribleFailure here = new TerribleFailure("here", null); here.fillInStackTrace(); return wtf(logId, tag, msg, here); } static int wtf(int logId, String tag, String msg, Throwable tr) { TerribleFailure what = new TerribleFailure(msg, tr); int bytes = println_native(LOG_ID_MAIN, ASSERT, tag, msg + '\n' + getStackTraceString(tr)); int bytes = println_native(logId, ASSERT, tag, msg + '\n' + getStackTraceString(tr)); sWtfHandler.onTerribleFailure(tag, what); return bytes; } Loading core/java/android/util/Slog.java +16 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,22 @@ public final class Slog { msg + '\n' + Log.getStackTraceString(tr)); } public static int wtf(String tag, String msg) { return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null); } public static int wtfStack(String tag, String msg) { return Log.wtfStack(Log.LOG_ID_SYSTEM, tag, msg); } public static int wtf(String tag, Throwable tr) { return Log.wtf(Log.LOG_ID_SYSTEM, tag, tr.getMessage(), tr); } public static int wtf(String tag, String msg, Throwable tr) { return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, tr); } public static int println(int priority, String tag, String msg) { return Log.println_native(Log.LOG_ID_SYSTEM, priority, tag, msg); } Loading Loading
core/java/android/util/Log.java +22 −3 Original line number Diff line number Diff line Loading @@ -84,14 +84,14 @@ public final class Log { public static final int ASSERT = 7; /** * Exception class used to capture a stack trace in {@link #wtf()}. * Exception class used to capture a stack trace in {@link #wtf}. */ private static class TerribleFailure extends Exception { TerribleFailure(String msg, Throwable cause) { super(msg, cause); } } /** * Interface to handle terrible failures from {@link #wtf()}. * Interface to handle terrible failures from {@link #wtf}. * * @hide */ Loading Loading @@ -256,6 +256,15 @@ public final class Log { return wtf(tag, msg, null); } /** * Like {@link #wtf(String, String)}, but also writes to the log the full * call stack. * @hide */ public static int wtfStack(String tag, String msg) { return wtfStack(LOG_ID_MAIN, tag, msg); } /** * What a Terrible Failure: Report an exception that should never happen. * Similar to {@link #wtf(String, String)}, with an exception to log. Loading @@ -274,8 +283,18 @@ public final class Log { * @param tr An exception to log. May be null. */ public static int wtf(String tag, String msg, Throwable tr) { return wtf(LOG_ID_MAIN, tag, msg, tr); } static int wtfStack(int logId, String tag, String msg) { TerribleFailure here = new TerribleFailure("here", null); here.fillInStackTrace(); return wtf(logId, tag, msg, here); } static int wtf(int logId, String tag, String msg, Throwable tr) { TerribleFailure what = new TerribleFailure(msg, tr); int bytes = println_native(LOG_ID_MAIN, ASSERT, tag, msg + '\n' + getStackTraceString(tr)); int bytes = println_native(logId, ASSERT, tag, msg + '\n' + getStackTraceString(tr)); sWtfHandler.onTerribleFailure(tag, what); return bytes; } Loading
core/java/android/util/Slog.java +16 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,22 @@ public final class Slog { msg + '\n' + Log.getStackTraceString(tr)); } public static int wtf(String tag, String msg) { return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null); } public static int wtfStack(String tag, String msg) { return Log.wtfStack(Log.LOG_ID_SYSTEM, tag, msg); } public static int wtf(String tag, Throwable tr) { return Log.wtf(Log.LOG_ID_SYSTEM, tag, tr.getMessage(), tr); } public static int wtf(String tag, String msg, Throwable tr) { return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, tr); } public static int println(int priority, String tag, String msg) { return Log.println_native(Log.LOG_ID_SYSTEM, priority, tag, msg); } Loading