com.android.ddmlib.Log.LogLevel Java Examples
The following examples show how to use
com.android.ddmlib.Log.LogLevel.
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: LogFilter.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
public LogFilter(String name, String filterTag, String filterProcess, LogLevel filterLevel) { this.name = name; this.filterTag = filterTag; this.filterLevel = filterLevel; this.filterProcess = filterProcess; if (filterProcess == null) { this.filterPid = -1; } else { int pid = -1; try { pid = Integer.parseInt(filterProcess); } catch (NumberFormatException e) { } this.filterPid = pid; } }
Example #2
Source File: LogFilter.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
/** * Create a new filter, which was previously stored in the given properties * list. */ public static LogFilter deserialize(Properties p, String prefix) { String name = p.getProperty(prefix + "." + SERIALIZE_NAME); String process = p.getProperty(prefix + "." + SERIALIZE_PROCESS); String tag = p.getProperty(prefix + "." + SERIALIZE_TAG); String lvlname = p.getProperty(prefix + "." + SERIALIZE_LEVEL); LogLevel level = null; if (lvlname != null) { try { level = LogLevel.valueOf(lvlname); } catch (IllegalArgumentException e) { } } if (name != null) { return new LogFilter(name, tag, process, level); } return null; }
Example #3
Source File: LogCatMessage.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Construct an immutable log message object. */ public LogCatMessage(@NonNull LogLevel logLevel, @NonNull String pid, @NonNull String tid, @NonNull String appName, @NonNull String tag, @NonNull String time, @NonNull String msg) { mLogLevel = logLevel; mPid = pid; mAppName = appName; mTag = tag; mTime = time; mMessage = msg; long tidValue; try { // Thread id's may be in hex on some platforms. // Decode and store them in radix 10. tidValue = Long.decode(tid.trim()); } catch (NumberFormatException e) { tidValue = -1; } mTid = Long.toString(tidValue); }
Example #4
Source File: LogFilterDialog.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
/** * Creates new form LogFilterDialog */ public LogFilterDialog() { super((java.awt.Frame) null, true); initComponents(); DefaultComboBoxModel<LogLevel> model = new DefaultComboBoxModel<>(); model.addElement(null); model.addElement(LogLevel.ASSERT); model.addElement(LogLevel.VERBOSE); model.addElement(LogLevel.DEBUG); model.addElement(LogLevel.INFO); model.addElement(LogLevel.WARN); model.addElement(LogLevel.ERROR); cmbLogLevel.setRenderer(new LogLevelListRenderer()); cmbLogLevel.setModel(model); getRootPane().setDefaultButton(butOk); }
Example #5
Source File: LogTableModel.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
@Override public Class<?> getColumnClass(int columnIndex) { switch (columnIndex) { case COL_MESSAGE: return String.class; case COL_PID: return Integer.class; case COL_PROCESS: return String.class; case COL_TIME: return String.class; // TODO(radim): how to sort this properly case COL_TAG: return String.class; case COL_LEVEL: return LogLevel.class; } throw new IllegalArgumentException("This column does not exist: " + columnIndex); }
Example #6
Source File: XmlTestRunListener.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Creates a report file and populates it with the report data from the completed tests. */ private void generateDocument(File reportDir, long elapsedTime) { String timestamp = getTimestamp(); OutputStream stream = null; try { stream = createOutputResultStream(reportDir); KXmlSerializer serializer = new KXmlSerializer(); serializer.setOutput(stream, SdkConstants.UTF_8); serializer.startDocument(SdkConstants.UTF_8, null); serializer.setFeature( "http://xmlpull.org/v1/doc/features.html#indent-output", true); // TODO: insert build info printTestResults(serializer, timestamp, elapsedTime); serializer.endDocument(); String msg = String.format("XML test result file generated at %s. %s" , getAbsoluteReportPath(), mRunResult.getTextSummary()); Log.logAndDisplay(LogLevel.INFO, LOG_TAG, msg); } catch (IOException e) { Log.e(LOG_TAG, "Failed to generate report data"); // TODO: consider throwing exception } finally { if (stream != null) { try { stream.close(); } catch (IOException ignored) { } } } }
Example #7
Source File: LogTopComponent.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
private void btLogLevelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btLogLevelActionPerformed LogLevel level = LogLevel.valueOf(evt.getActionCommand()); if (level != null) { rowFilter.setLogLevel(level); refreshContent(); } }
Example #8
Source File: LogEventInfo.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
public LogEventInfo(int pid, String[] pNameRef, String time, String tag, LogLevel level) { this.pid = pid; this.pNameRef = pNameRef; this.time = time; this.tag = tag; this.level = level; }
Example #9
Source File: MonitorThread.java From javaide with GNU General Public License v3.0 | 5 votes |
private void displayDebugSelectedBindError(int port) { String message = String.format( "Could not open Selected VM debug port (%1$d). Make sure you do not have another instance of DDMS or of the eclipse plugin running. If it's being used by something else, choose a new port number in the preferences.", port); Log.logAndDisplay(LogLevel.ERROR, "ddms", message); }
Example #10
Source File: LogCatFilter.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Construct a list of {@link LogCatFilter} objects by decoding the query. * @param query encoded search string. The query is simply a list of words (can be regexes) * a user would type in a search bar. These words are searched for in the text field of * each collected logcat message. To search in a different field, the word could be prefixed * with a keyword corresponding to the field name. Currently, the following keywords are * supported: "pid:", "tag:" and "text:". Invalid regexes are ignored. * @param minLevel minimum log level to match * @return list of filter settings that fully match the given query */ public static List<LogCatFilter> fromString(String query, LogLevel minLevel) { List<LogCatFilter> filterSettings = new ArrayList<LogCatFilter>(); for (String s : query.trim().split(" ")) { String tag = ""; String text = ""; String pid = ""; String app = ""; if (s.startsWith(PID_KEYWORD)) { pid = s.substring(PID_KEYWORD.length()); } else if (s.startsWith(APP_KEYWORD)) { app = s.substring(APP_KEYWORD.length()); } else if (s.startsWith(TAG_KEYWORD)) { tag = s.substring(TAG_KEYWORD.length()); } else { if (s.startsWith(TEXT_KEYWORD)) { text = s.substring(TEXT_KEYWORD.length()); } else { text = s; } } filterSettings.add(new LogCatFilter("livefilter-" + s, tag, text, pid, app, minLevel)); } return filterSettings; }
Example #11
Source File: LogReader.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
LogEventInfo parseLine(IDevice device, String line) { LOG.log(Level.FINER, line); Matcher matcher = sLogPattern.matcher(line); if (matcher.matches()) { String time = matcher.group(1); int pid = Integer.valueOf(matcher.group(2)); String[] process = getProcessName(device, pid); LogLevel level = LogLevel.getByLetterString(matcher.group(4)); String tag = matcher.group(5).trim(); return new LogEventInfo(pid, process, time, tag, level); } return null; }
Example #12
Source File: HandleTest.java From javaide with GNU General Public License v3.0 | 5 votes |
private void handleTEST(Client client, ByteBuffer data) { /* * Can't call data.array() on a read-only ByteBuffer, so we make * a copy. */ byte[] copy = new byte[data.limit()]; data.get(copy); Log.d("ddm-test", "Received:"); Log.hexDump("ddm-test", LogLevel.DEBUG, copy, 0, copy.length); }
Example #13
Source File: LogCatMessageParser.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Parse a list of strings into {@link LogCatMessage} objects. This method * maintains state from previous calls regarding the last seen header of * logcat messages. * @param lines list of raw strings obtained from logcat -v long * @param device device from which these log messages have been received * @return list of LogMessage objects parsed from the input */ @NonNull public List<LogCatMessage> processLogLines(String[] lines, IDevice device) { List<LogCatMessage> messages = new ArrayList<LogCatMessage>(lines.length); for (String line : lines) { if (line.isEmpty()) { continue; } Matcher matcher = sLogHeaderPattern.matcher(line); if (matcher.matches()) { mCurTime = matcher.group(1); mCurPid = matcher.group(2); mCurTid = matcher.group(3); mCurLogLevel = LogLevel.getByLetterString(matcher.group(4)); mCurTag = matcher.group(5).trim(); /* LogLevel doesn't support messages with severity "F". Log.wtf() is supposed * to generate "A", but generates "F". */ if (mCurLogLevel == null && matcher.group(4).equals("F")) { mCurLogLevel = LogLevel.ASSERT; } } else { String pkgName = ""; //$NON-NLS-1$ Integer pid = Ints.tryParse(mCurPid); if (pid != null && device != null) { pkgName = device.getClientName(pid); } LogCatMessage m = new LogCatMessage(mCurLogLevel, mCurPid, mCurTid, pkgName, mCurTag, mCurTime, line); messages.add(m); } } return messages; }
Example #14
Source File: LogTableModel.java From NBANDROID-V2 with Apache License 2.0 | 4 votes |
public void showError(String errorMessage) { LogEventInfo info = new LogEventInfo(0, new String[]{""}, "LogCat Error", "-----", LogLevel.ERROR); LogEvent event = new LogEvent(info, errorMessage); addNewEvent(event); }
Example #15
Source File: LogReader.java From NBANDROID-V2 with Apache License 2.0 | 4 votes |
private void errorMessage(String message) { LogEventInfo i = new LogEventInfo(0, new String[]{""}, "", "", LogLevel.ERROR); LogEvent e = new LogEvent(i, message); sendNewLogEvent(e); }
Example #16
Source File: LogReader.java From NBANDROID-V2 with Apache License 2.0 | 4 votes |
private void infoMessage(String message) { LogEventInfo i = new LogEventInfo(0, new String[]{""}, "", "", LogLevel.INFO); LogEvent e = new LogEvent(i, message); sendNewLogEvent(e); }
Example #17
Source File: LogTableCellRenderer.java From NBANDROID-V2 with Apache License 2.0 | 4 votes |
@Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { TableRowSorter rowsorter = (TableRowSorter) table.getRowSorter(); LogTableModel model = (LogTableModel) table.getModel(); LogLineRowFilter rowfilter = null; String line = htmlEscape(String.valueOf(value)); // if possible, try to translate the visual row number to the model's row number if (rowsorter != null) { row = rowsorter.convertRowIndexToModel(row); if (rowsorter.getRowFilter() instanceof LogLineRowFilter) { rowfilter = (LogLineRowFilter) rowsorter.getRowFilter(); } } // get the according event object LogEvent event = model.getValueAt(row); LogLevel level = event.getLevel(); final String htmlLeft = "<html><nobr>"; final String htmlRight = "</nobr></html>"; switch (column) { case LogTableModel.COL_TIME: { return super.getTableCellRendererComponent(table, htmlLeft + line + htmlRight, isSelected, hasFocus, row, column); } case LogTableModel.COL_TAG: case LogTableModel.COL_PROCESS: { line = rowfilter.highlight(line); break; } case LogTableModel.COL_MESSAGE: { line = rowfilter.highlight(line); int indentSize = 0; while (indentSize < line.length() && line.charAt(indentSize) == ' ') { ++indentSize; } String indent = indentSize == 0 ? "" : line.substring(0, indentSize - 1); line = indentSize == 0 ? line : line.substring(indentSize); if (event.getStackTraceElement() != null) { line = "<pre>" + indent + "<u>" + line + "</u></pre>"; } break; } } Component c = super.getTableCellRendererComponent(table, htmlLeft + line + htmlRight, isSelected, hasFocus, row, column); Color color = Color.BLACK; switch (level) { case ASSERT: color = COLOR_ASSERT; break; case DEBUG: color = COLOR_DEBUG; break; case ERROR: color = COLOR_ERROR; break; case INFO: color = COLOR_INFO; break; case WARN: color = COLOR_WARN; break; default: color = COLOR_VERBOSE; break; } c.setForeground(color); if (column == LogTableModel.COL_MESSAGE && c instanceof JLabel) { ((JLabel) c).setToolTipText(value != null ? value.toString() : ""); } return c; }
Example #18
Source File: LogReader.java From NBANDROID-V2 with Apache License 2.0 | 4 votes |
private void processLogLines(IDevice device, String[] lines) { for (String line : lines) { // ignore empty lines. if (line.length() > 0) { String time; int pid; String[] process; LogLevel level; String tag; LogEventInfo lei = parseLine(device, line); if (lei != null) { // this is a header line, parse the header and keep it around. lastLogEventInfo = lei; } else { if (lastLogEventInfo == null) { // The first line of output wasn't preceded // by a header line; make something up so // that users of mc.data don't NPE. time = "??-?? ??:??:??.???"; //$NON-NLS1$ pid = 0; process = new String[]{""}; level = LogLevel.INFO; tag = "<unknown>"; //$NON-NLS1$ lastLogEventInfo = new LogEventInfo(pid, process, time, tag, level); } // tabs seem to display as only 1 tab so we replace the leading tabs // by 4 spaces. String message = line.replaceAll("\t", " "); //$NON-NLS-1$ //$NON-NLS-2$ if (ignoredLines.contains(message)) { continue; } LogEvent event = new LogEvent(lastLogEventInfo, message); Collection<LogEvent> loggedEvents = logEventCache.get(device.getSerialNumber()); if (loggedEvents == null) { loggedEvents = new LinkedHashSet<>(); logEventCache.put(device.getSerialNumber(), loggedEvents); // notify listeners for the new device firePropertyChange(PROPERTY_DEVICE_LIST, null, getLoggedDevices()); } if (!loggedEvents.contains(event)) { loggedEvents.add(event); sendNewLogEvent(event); } } } } }
Example #19
Source File: LogEvent.java From NBANDROID-V2 with Apache License 2.0 | 4 votes |
public LogLevel getLevel() { return info.getLevel(); }
Example #20
Source File: LogEventInfo.java From NBANDROID-V2 with Apache License 2.0 | 4 votes |
public LogLevel getLevel() { return level; }
Example #21
Source File: DdmPreferences.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * Sets the minimum {@link LogLevel} to display. * <p/>This change takes effect right away. */ public static void setLogLevel(String value) { sLogLevel = LogLevel.getByString(value); Log.setLevel(sLogLevel); }
Example #22
Source File: DdmPreferences.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * Returns the minimum {@link LogLevel} being displayed. */ public static LogLevel getLogLevel() { return sLogLevel; }
Example #23
Source File: LogCatFilter.java From javaide with GNU General Public License v3.0 | 4 votes |
@NonNull public LogLevel getLogLevel() { return mLogLevel; }
Example #24
Source File: LogCatReceiverTask.java From javaide with GNU General Public License v3.0 | 4 votes |
private static LogCatMessage errorMessage(String msg) { return new LogCatMessage(LogLevel.ERROR, "", "", "", "", "", msg); }
Example #25
Source File: LogCatMessage.java From javaide with GNU General Public License v3.0 | 4 votes |
@NonNull public LogLevel getLogLevel() { return mLogLevel; }
Example #26
Source File: LogLineRowFilter.java From NBANDROID-V2 with Apache License 2.0 | 2 votes |
/** * Get the current minimum LogLevel of this filter. * * @return */ public LogLevel getLogLevel() { return level; }
Example #27
Source File: LogLineRowFilter.java From NBANDROID-V2 with Apache License 2.0 | 2 votes |
/** * Set the minimum LogLevel of messages, which should be included in this * filter. */ public void setLogLevel(LogLevel level) { this.level = level; }