com.android.ddmlib.logcat.LogCatMessage Java Examples
The following examples show how to use
com.android.ddmlib.logcat.LogCatMessage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LogView.java From logviewer with Apache License 2.0 | 6 votes |
/** * Check whether the log level of the given message is acceptable */ private boolean canAcceptLevel(LogCatMessage line) { switch (line.getHeader().getLogLevel()) { case ASSERT: return aCheckBox.isSelected(); case DEBUG: return dCheckBox.isSelected(); case ERROR: return eCheckBox.isSelected(); case INFO: return iCheckBox.isSelected(); case VERBOSE: return vCheckBox.isSelected(); case WARN: return wCheckBox.isSelected(); } return true; }
Example #2
Source File: LogLineUpdater.java From logviewer with Apache License 2.0 | 6 votes |
public static String parseLogLine(String logLine, String fileName, LogProcess logProcess) { LogCatMessage message = null; try { message = AndroidLogcatFormatter.tryParseMessage(logLine); } catch (Exception ex) { } if (message == null) { String updatedLogLine = mapLogLines(logLine, fileName, logProcess); if (updatedLogLine != null) { logLine = updatedLogLine; } } else { logProcess.setProcessID(message.getPid()); String appName = message.getAppName(); if (appName == null || appName.isEmpty() || appName.equals("?")) { appName = message.getTag(); if (appName == null || appName.isEmpty() || appName.equals("?")) { appName = "TAG"; } } logProcess.setProcessName(appName); } return logLine; }
Example #3
Source File: FrameworkEventManager.java From FuzzDroid with Apache License 2.0 | 6 votes |
public void startLogcatCrashViewer() { try { device.executeShellCommand("logcat -c", new GenericReceiver(), 10000, TimeUnit.MILLISECONDS); } catch (Exception e) { e.printStackTrace(); } LogCatReceiverTask lcrt = new LogCatReceiverTask(device); lcrt.addLogCatListener(new LogCatListener() { @Override public void log(List<LogCatMessage> msgList) { for(LogCatMessage lcmsg : msgList) { String msg = lcmsg.getMessage(); if(/*msg.contains("Shutting down VM") ||*/ msg.contains("VFY:") ) LoggerHelper.logEvent(MyLevel.VMCRASH, String.format("############### VM CRASHED ###############\n%s", lcmsg.toString())); } } }); Thread logcatViewerThread = new Thread(lcrt); logcatViewerThread.start(); }
Example #4
Source File: LongMessageFormatter.java From logviewer with Apache License 2.0 | 6 votes |
@Nullable @Override public LogCatMessage tryParse(@NotNull String message) { Matcher matcher = HEADER_MESSAGE.matcher(message); if (!matcher.matches()) { return null; } LogLevel priority = LogLevel.getByLetterString(matcher.group(5)); assert priority != null; int processId = Integer.parseInt(matcher.group(2)); int threadId = Integer.parseInt(matcher.group(3)); String tag = matcher.group(6); LogCatTimestamp timestamp = LogCatTimestamp.fromString(matcher.group(1)); @SuppressWarnings("deprecation") LogCatHeader header = new LogCatHeader(priority, processId, threadId, /* package= */ matcher.group(4), tag, timestamp); return new LogCatMessage(header, /* message= */ matcher.group(7)); }
Example #5
Source File: AndroidLogcatFormatter.java From logviewer with Apache License 2.0 | 6 votes |
/** * Returns the result of {@link #parseMessage(String)} or {@code null} if the format of the input * text doesn't match. */ @Nullable public static LogCatMessage tryParseMessage(@NotNull String msg) { final Matcher matcher = MESSAGE_WITH_HEADER.matcher(msg); if (!matcher.matches()) { return null; } @SuppressWarnings("ConstantConditions") // matcher.matches verifies all groups below are non-null LogCatHeader header = new LogCatHeader( Log.LogLevel.getByLetter(matcher.group(5).charAt(0)), Integer.parseInt(matcher.group(2)), Integer.parseInt(matcher.group(3)), matcher.group(4), matcher.group(6), LogCatTimestamp.fromString(matcher.group(1))); String message = matcher.group(7); return new LogCatMessage(header, message); }
Example #6
Source File: LongEpochMessageFormatter.java From logviewer with Apache License 2.0 | 6 votes |
@Nullable public LogCatMessage tryParse(@NotNull String message) { //Matcher matcher = this.myPreferences.SHOW_AS_SECONDS_SINCE_EPOCH ? EPOCH_TIME_HEADER_MESSAGE.matcher(message) : DATE_TIME_HEADER_MESSAGE.matcher(message); Matcher matcher = DATE_TIME_HEADER_MESSAGE.matcher(message); if (!matcher.matches()) { return null; } else { Log.LogLevel priority = Log.LogLevel.getByLetterString(matcher.group(5)); assert priority != null; int processId = Integer.parseInt(matcher.group(2)); int threadId = Integer.parseInt(matcher.group(3)); String tag = matcher.group(6); Instant timestampInstant; // if (this.myPreferences.SHOW_AS_SECONDS_SINCE_EPOCH) { // timestampInstant = (Instant)LogCatLongEpochMessageParser.EPOCH_TIME_FORMATTER.parse(matcher.group(1), Instant::from); // } else { LocalDateTime timestampDateTime = LocalDateTime.parse(matcher.group(1), DATE_TIME_FORMATTER); timestampInstant = timestampDateTime.toInstant(this.myTimeZone.getRules().getOffset(timestampDateTime)); // } LogCatHeader header = new LogCatHeader(priority, processId, threadId, matcher.group(4), tag, timestampInstant); return new LogCatMessage(header, matcher.group(7)); } }
Example #7
Source File: AndroidLogcatFormatter.java From logviewer with Apache License 2.0 | 5 votes |
@Override public String formatMessage(String msg) { String continuation = tryParseContinuation(msg); if (continuation != null) { return CONTINUATION_INDENT + continuation; } else { LogCatMessage message = tryParseMessage(msg); if (message != null) { return formatMessage(myPreferences.LOGCAT_FORMAT_STRING, msg); } } return msg; // Unknown message format, return as is }
Example #8
Source File: AndroidLogcatFormatter.java From logviewer with Apache License 2.0 | 5 votes |
/** * Parse a message that was encoded using {@link #formatMessageFull(LogCatHeader, String)} */ @NotNull public static LogCatMessage parseMessage(@NotNull String msg) { LogCatMessage result = tryParseMessage(msg); if (result == null) { throw new IllegalArgumentException("Invalid message doesn't match expected logcat pattern: " + msg); } return result; }
Example #9
Source File: AndroidLogcatFormatter.java From logviewer with Apache License 2.0 | 5 votes |
/** * Helper method useful for previewing what final output will look like given a custom formatter. */ @NotNull static String formatMessage(@NotNull String format, @NotNull String msg) { if (format.isEmpty()) { return msg; } LogCatMessage message = parseMessage(msg); return formatMessage(format, message.getHeader(), message.getMessage()); }
Example #10
Source File: LogView.java From logviewer with Apache License 2.0 | 5 votes |
/** * Check whether the process of the given message is acceptable */ private boolean canAcceptProcess(LogCatMessage line) { if (processFilter.isEmpty()) { return true; } boolean accept = true; if (logSourceManager.isDeviceSourceSelected()) { String appName = line.getAppName(); if (appName != null) { accept = canAcceptProcessName(line.getAppName()); if (!accept && appName.indexOf('.') == -1) { accept = canAcceptProcessName(line.getTag()); } } if (accept && line.getPid() != 0) { accept = canAcceptPid(line.getPid()); } } else { if (line.getTag() != null) { accept = canAcceptProcessName(line.getTag()); } if (accept && line.getPid() != 0) { accept = canAcceptPid(line.getPid()); } } return accept; }
Example #11
Source File: LogView.java From logviewer with Apache License 2.0 | 5 votes |
@NotNull @Override public MyProcessingResult processLine(String line) { LogCatMessage message = null; String continuation = null; boolean validContinuation = false; try { message = AndroidLogcatFormatter.tryParseMessage(line); continuation = message == null ? AndroidLogcatFormatter.tryParseContinuation(line) : null; validContinuation = continuation != null && this.myPrevHeader != null; } catch (Exception ignored) { } if (message == null && !validContinuation) { return new MyProcessingResult(ProcessOutputTypes.STDOUT, canAcceptMessage(line), null); } else { if (message != null) { this.myPrevHeader = message.getHeader(); this.myCustomApplicable = this.isMessageApplicable(message); this.myMessageSoFar.setLength(0); } boolean isApplicable = this.myCustomApplicable; if (!isApplicable) { this.myMessageSoFar.append(line); this.myMessageSoFar.append('\n'); } Key key = AndroidLogcatUtils.getProcessOutputType(this.myPrevHeader.getLogLevel()); MyProcessingResult result = new MyProcessingResult(key, isApplicable, this.myMessageSoFar.toString()); if (isApplicable) { this.myMessageSoFar.setLength(0); } return result; } }
Example #12
Source File: DeviceLogDataProvider.java From logviewer with Apache License 2.0 | 5 votes |
@Override public void onLogLineReceived(@NotNull LogCatMessage line) { try { LogProcess logProcess = new LogProcess(); logProcess.setProcessID(line.getPid()); String appName = line.getAppName(); if (appName == null || appName.isEmpty() || appName.equals("?")) { appName = line.getTag(); if (appName == null || appName.isEmpty() || appName.equals("?")) { appName = "TAG"; } } logProcess.setProcessName(appName); String message = null; if (!line.getHeader().equals(myActiveHeader)) { myActiveHeader = line.getHeader(); message = AndroidLogcatFormatter.formatMessageFull(myActiveHeader, line.getMessage()); } else { message = AndroidLogcatFormatter.formatContinuation(line.getMessage()); } if (message != null) { notifyLog(message, logProcess); } } catch (Exception ex) { logListener.debug(ex.getMessage()); } }
Example #13
Source File: LogView.java From logviewer with Apache License 2.0 | 4 votes |
/** * Check whether the given line can be shown based on current filters */ private boolean canAccept(LogCatMessage line) { return canAcceptLevel(line) && canAcceptProcess(line) && canAcceptMessage(line); }
Example #14
Source File: LogView.java From logviewer with Apache License 2.0 | 4 votes |
/** * Check whether the message of the given message is acceptable */ private boolean canAcceptMessage(LogCatMessage line) { return (addFilters.isEmpty() || isInFilter(line, addFilters)) && (removeFilters.isEmpty() || !isInFilter(line, removeFilters)); }
Example #15
Source File: LogView.java From logviewer with Apache License 2.0 | 4 votes |
/** * Check whether given message matches with any filter in the given set */ private boolean isInFilter(LogCatMessage line, Set<String> filter) { return isInFilter(line.getMessage(), filter) || isInFilter(line.getTag(), filter) || isInFilter(line.getAppName(), filter) || isInFilter("" + line.getPid(), filter); }
Example #16
Source File: LogView.java From logviewer with Apache License 2.0 | 4 votes |
private boolean isMessageApplicable(LogCatMessage message) { return canAccept(message); }
Example #17
Source File: MessageFormatter.java From logviewer with Apache License 2.0 | 4 votes |
@Nullable LogCatMessage tryParse(@NotNull String var1);