AndroidLogcatFormatter extends DefaultLogFormatter { @NotNull LogCatMessage parseMessage(@NotNull String message) { LogCatMessage result = tryParseMessage(message); if (result == null) { throw new IllegalArgumentException("Invalid message doesn't match expected logcat pattern: " + message); } return result; } AndroidLogcatFormatter(@NotNull ZoneId timeZone, @NotNull AndroidLogcatPreferences preferences); @NotNull static String formatContinuation(@NotNull String message); @NotNull static String createCustomFormat(boolean showTime, boolean showPid, boolean showPackage, boolean showTag); @NotNull String formatMessage(@NotNull String format, @NotNull LogCatHeader header, @NotNull String message); @Nullable static String tryParseContinuation(@NotNull String msg); @Override String formatPrefix(String prefix); @NotNull @Override String formatMessage(@NotNull String message); static final CharSequence CONTINUATION_INDENT; }
@Test public void parseMessageForTagAndLogLevel() { String message = "2018-02-12 17:04:44.005 1282-12/com.google.android.apps" + ".maps:GoogleLocationService D/dalvikvm: Debugger has detached; object " + "registry had 1 entries"; LogCatHeader header = myFormatter.parseMessage(message).getHeader(); assertEquals(LogLevel.DEBUG, header.getLogLevel()); assertEquals("dalvikvm", header.getTag()); }