Java Code Examples for com.android.ddmlib.Log#e()

The following examples show how to use com.android.ddmlib.Log#e() . 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: XmlTestRunListener.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 2
Source File: InstrumentationResultParser.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the stack trace of the current failed test, from the provided testInfo.
 */
private String getTrace(TestResult testInfo) {
    if (testInfo.mStackTrace != null) {
        return testInfo.mStackTrace;
    } else {
        Log.e(LOG_TAG, "Could not find stack trace for failed test ");
        return new Throwable("Unknown failure").toString();
    }
}
 
Example 3
Source File: EventLogParser.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
private EventValueDescription[] processDescription(String description) {
    String[] descriptions = description.split("\\s*,\\s*"); //$NON-NLS-1$

    ArrayList<EventValueDescription> list = new ArrayList<EventValueDescription>();

    for (String desc : descriptions) {
        Matcher m = PATTERN_DESCRIPTION.matcher(desc);
        if (m.matches()) {
            try {
                String name = m.group(1);

                String typeString = m.group(2);
                int typeValue = Integer.parseInt(typeString);
                EventValueType eventValueType = EventValueType.getEventValueType(typeValue);
                if (eventValueType == null) {
                    // just ignore this description if the value is not recognized.
                    // TODO: log the error.
                }

                typeString = m.group(3);
                if (typeString != null && !typeString.isEmpty()) {
                    //skip the |
                    typeString = typeString.substring(1);

                    typeValue = Integer.parseInt(typeString);
                    ValueType valueType = ValueType.getValueType(typeValue);

                    list.add(new EventValueDescription(name, eventValueType, valueType));
                } else {
                    list.add(new EventValueDescription(name, eventValueType));
                }
            } catch (NumberFormatException nfe) {
                // just ignore this description if one number is malformed.
                // TODO: log the error.
            } catch (InvalidValueTypeException e) {
                // just ignore this description if data type and data unit don't match
                // TODO: log the error.
            }
        } else {
            Log.e("EventLogParser",  //$NON-NLS-1$
                String.format("Can't parse %1$s", description));  //$NON-NLS-1$
        }
    }

    if (list.isEmpty()) {
        return null;
    }

    return list.toArray(new EventValueDescription[list.size()]);

}
 
Example 4
Source File: EventLogParser.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Recursively convert binary log data to printable form.
 *
 * This needs to be recursive because you can have lists of lists.
 *
 * If we run out of room, we stop processing immediately.  It's important
 * for us to check for space on every output element to avoid producing
 * garbled output.
 *
 * Returns the amount read on success, -1 on failure.
 */
private static int parseBinaryEvent(byte[] eventData, int dataOffset, ArrayList<Object> list) {

    if (eventData.length - dataOffset < 1)
        return -1;

    int offset = dataOffset;

    int type = eventData[offset++];

    //fprintf(stderr, "--- type=%d (rem len=%d)\n", type, eventDataLen);

    switch (type) {
    case EVENT_TYPE_INT: { /* 32-bit signed int */
            int ival;

            if (eventData.length - offset < 4)
                return -1;
            ival = ArrayHelper.swap32bitFromArray(eventData, offset);
            offset += 4;

            list.add(ival);
        }
        break;
    case EVENT_TYPE_LONG: { /* 64-bit signed long */
            long lval;

            if (eventData.length - offset < 8)
                return -1;
            lval = ArrayHelper.swap64bitFromArray(eventData, offset);
            offset += 8;

            list.add(lval);
        }
        break;
    case EVENT_TYPE_STRING: { /* UTF-8 chars, not NULL-terminated */
            int strLen;

            if (eventData.length - offset < 4)
                return -1;
            strLen = ArrayHelper.swap32bitFromArray(eventData, offset);
            offset += 4;

            if (eventData.length - offset < strLen)
                return -1;

            // get the string
            String str = new String(eventData, offset, strLen, Charsets.UTF_8);
            list.add(str);
            offset += strLen;
            break;
        }
    case EVENT_TYPE_LIST: { /* N items, all different types */

            if (eventData.length - offset < 1)
                return -1;

            int count = eventData[offset++];

            // make a new temp list
            ArrayList<Object> subList = new ArrayList<Object>();
            for (int i = 0; i < count; i++) {
                int result = parseBinaryEvent(eventData, offset, subList);
                if (result == -1) {
                    return result;
                }

                offset += result;
            }

            list.add(subList.toArray());
        }
        break;
    default:
        Log.e("EventLogParser",  //$NON-NLS-1$
                String.format("Unknown binary event type %1$d", type));  //$NON-NLS-1$
        return -1;
    }

    return offset - dataOffset;
}