Search in sources :

Example 1 with LineBreakBufferedWriter

use of com.android.internal.util.LineBreakBufferedWriter in project android_frameworks_base by ResurrectionRemix.

the class Log method printlns.

/**
     * Helper function for long messages. Uses the LineBreakBufferedWriter to break
     * up long messages and stacktraces along newlines, but tries to write in large
     * chunks. This is to avoid truncation.
     * @hide
     */
public static int printlns(int bufID, int priority, String tag, String msg, Throwable tr) {
    ImmediateLogWriter logWriter = new ImmediateLogWriter(bufID, priority, tag);
    // Acceptable buffer size. Get the native buffer size, subtract two zero terminators,
    // and the length of the tag.
    // Note: we implicitly accept possible truncation for Modified-UTF8 differences. It
    //       is too expensive to compute that ahead of time.
    int bufferSize = // Base.
    NoPreloadHolder.LOGGER_ENTRY_MAX_PAYLOAD - // Two terminators.
    2 - // Tag length.
    (tag != null ? tag.length() : 0) - // Some slack.
    32;
    // At least assume you can print *some* characters (tag is not too large).
    bufferSize = Math.max(bufferSize, 100);
    LineBreakBufferedWriter lbbw = new LineBreakBufferedWriter(logWriter, bufferSize);
    lbbw.println(msg);
    if (tr != null) {
        // This is to reduce the amount of log spew that apps do in the non-error
        // condition of the network being unavailable.
        Throwable t = tr;
        while (t != null) {
            if (t instanceof UnknownHostException) {
                break;
            }
            if (t instanceof DeadSystemException) {
                lbbw.println("DeadSystemException: The system died; " + "earlier logs will point to the root cause");
                break;
            }
            t = t.getCause();
        }
        if (t == null) {
            tr.printStackTrace(lbbw);
        }
    }
    lbbw.flush();
    return logWriter.getWritten();
}
Also used : DeadSystemException(android.os.DeadSystemException) UnknownHostException(java.net.UnknownHostException) LineBreakBufferedWriter(com.android.internal.util.LineBreakBufferedWriter)

Example 2 with LineBreakBufferedWriter

use of com.android.internal.util.LineBreakBufferedWriter in project android_frameworks_base by AOSPA.

the class Log method printlns.

/**
     * Helper function for long messages. Uses the LineBreakBufferedWriter to break
     * up long messages and stacktraces along newlines, but tries to write in large
     * chunks. This is to avoid truncation.
     * @hide
     */
public static int printlns(int bufID, int priority, String tag, String msg, Throwable tr) {
    ImmediateLogWriter logWriter = new ImmediateLogWriter(bufID, priority, tag);
    // Acceptable buffer size. Get the native buffer size, subtract two zero terminators,
    // and the length of the tag.
    // Note: we implicitly accept possible truncation for Modified-UTF8 differences. It
    //       is too expensive to compute that ahead of time.
    int bufferSize = // Base.
    NoPreloadHolder.LOGGER_ENTRY_MAX_PAYLOAD - // Two terminators.
    2 - // Tag length.
    (tag != null ? tag.length() : 0) - // Some slack.
    32;
    // At least assume you can print *some* characters (tag is not too large).
    bufferSize = Math.max(bufferSize, 100);
    LineBreakBufferedWriter lbbw = new LineBreakBufferedWriter(logWriter, bufferSize);
    lbbw.println(msg);
    if (tr != null) {
        // This is to reduce the amount of log spew that apps do in the non-error
        // condition of the network being unavailable.
        Throwable t = tr;
        while (t != null) {
            if (t instanceof UnknownHostException) {
                break;
            }
            if (t instanceof DeadSystemException) {
                lbbw.println("DeadSystemException: The system died; " + "earlier logs will point to the root cause");
                break;
            }
            t = t.getCause();
        }
        if (t == null) {
            tr.printStackTrace(lbbw);
        }
    }
    lbbw.flush();
    return logWriter.getWritten();
}
Also used : DeadSystemException(android.os.DeadSystemException) UnknownHostException(java.net.UnknownHostException) LineBreakBufferedWriter(com.android.internal.util.LineBreakBufferedWriter)

Example 3 with LineBreakBufferedWriter

use of com.android.internal.util.LineBreakBufferedWriter in project platform_frameworks_base by android.

the class Log method printlns.

/**
     * Helper function for long messages. Uses the LineBreakBufferedWriter to break
     * up long messages and stacktraces along newlines, but tries to write in large
     * chunks. This is to avoid truncation.
     * @hide
     */
public static int printlns(int bufID, int priority, String tag, String msg, Throwable tr) {
    ImmediateLogWriter logWriter = new ImmediateLogWriter(bufID, priority, tag);
    // Acceptable buffer size. Get the native buffer size, subtract two zero terminators,
    // and the length of the tag.
    // Note: we implicitly accept possible truncation for Modified-UTF8 differences. It
    //       is too expensive to compute that ahead of time.
    int bufferSize = // Base.
    NoPreloadHolder.LOGGER_ENTRY_MAX_PAYLOAD - // Two terminators.
    2 - // Tag length.
    (tag != null ? tag.length() : 0) - // Some slack.
    32;
    // At least assume you can print *some* characters (tag is not too large).
    bufferSize = Math.max(bufferSize, 100);
    LineBreakBufferedWriter lbbw = new LineBreakBufferedWriter(logWriter, bufferSize);
    lbbw.println(msg);
    if (tr != null) {
        // This is to reduce the amount of log spew that apps do in the non-error
        // condition of the network being unavailable.
        Throwable t = tr;
        while (t != null) {
            if (t instanceof UnknownHostException) {
                break;
            }
            if (t instanceof DeadSystemException) {
                lbbw.println("DeadSystemException: The system died; " + "earlier logs will point to the root cause");
                break;
            }
            t = t.getCause();
        }
        if (t == null) {
            tr.printStackTrace(lbbw);
        }
    }
    lbbw.flush();
    return logWriter.getWritten();
}
Also used : DeadSystemException(android.os.DeadSystemException) UnknownHostException(java.net.UnknownHostException) LineBreakBufferedWriter(com.android.internal.util.LineBreakBufferedWriter)

Example 4 with LineBreakBufferedWriter

use of com.android.internal.util.LineBreakBufferedWriter in project android_frameworks_base by crdroidandroid.

the class Log method printlns.

/**
     * Helper function for long messages. Uses the LineBreakBufferedWriter to break
     * up long messages and stacktraces along newlines, but tries to write in large
     * chunks. This is to avoid truncation.
     * @hide
     */
public static int printlns(int bufID, int priority, String tag, String msg, Throwable tr) {
    ImmediateLogWriter logWriter = new ImmediateLogWriter(bufID, priority, tag);
    // Acceptable buffer size. Get the native buffer size, subtract two zero terminators,
    // and the length of the tag.
    // Note: we implicitly accept possible truncation for Modified-UTF8 differences. It
    //       is too expensive to compute that ahead of time.
    int bufferSize = // Base.
    NoPreloadHolder.LOGGER_ENTRY_MAX_PAYLOAD - // Two terminators.
    2 - // Tag length.
    (tag != null ? tag.length() : 0) - // Some slack.
    32;
    // At least assume you can print *some* characters (tag is not too large).
    bufferSize = Math.max(bufferSize, 100);
    LineBreakBufferedWriter lbbw = new LineBreakBufferedWriter(logWriter, bufferSize);
    lbbw.println(msg);
    if (tr != null) {
        // This is to reduce the amount of log spew that apps do in the non-error
        // condition of the network being unavailable.
        Throwable t = tr;
        while (t != null) {
            if (t instanceof UnknownHostException) {
                break;
            }
            if (t instanceof DeadSystemException) {
                lbbw.println("DeadSystemException: The system died; " + "earlier logs will point to the root cause");
                break;
            }
            t = t.getCause();
        }
        if (t == null) {
            tr.printStackTrace(lbbw);
        }
    }
    lbbw.flush();
    return logWriter.getWritten();
}
Also used : DeadSystemException(android.os.DeadSystemException) UnknownHostException(java.net.UnknownHostException) LineBreakBufferedWriter(com.android.internal.util.LineBreakBufferedWriter)

Example 5 with LineBreakBufferedWriter

use of com.android.internal.util.LineBreakBufferedWriter in project android_frameworks_base by DirtyUnicorns.

the class Log method printlns.

/**
     * Helper function for long messages. Uses the LineBreakBufferedWriter to break
     * up long messages and stacktraces along newlines, but tries to write in large
     * chunks. This is to avoid truncation.
     * @hide
     */
public static int printlns(int bufID, int priority, String tag, String msg, Throwable tr) {
    ImmediateLogWriter logWriter = new ImmediateLogWriter(bufID, priority, tag);
    // Acceptable buffer size. Get the native buffer size, subtract two zero terminators,
    // and the length of the tag.
    // Note: we implicitly accept possible truncation for Modified-UTF8 differences. It
    //       is too expensive to compute that ahead of time.
    int bufferSize = // Base.
    NoPreloadHolder.LOGGER_ENTRY_MAX_PAYLOAD - // Two terminators.
    2 - // Tag length.
    (tag != null ? tag.length() : 0) - // Some slack.
    32;
    // At least assume you can print *some* characters (tag is not too large).
    bufferSize = Math.max(bufferSize, 100);
    LineBreakBufferedWriter lbbw = new LineBreakBufferedWriter(logWriter, bufferSize);
    lbbw.println(msg);
    if (tr != null) {
        // This is to reduce the amount of log spew that apps do in the non-error
        // condition of the network being unavailable.
        Throwable t = tr;
        while (t != null) {
            if (t instanceof UnknownHostException) {
                break;
            }
            if (t instanceof DeadSystemException) {
                lbbw.println("DeadSystemException: The system died; " + "earlier logs will point to the root cause");
                break;
            }
            t = t.getCause();
        }
        if (t == null) {
            tr.printStackTrace(lbbw);
        }
    }
    lbbw.flush();
    return logWriter.getWritten();
}
Also used : DeadSystemException(android.os.DeadSystemException) UnknownHostException(java.net.UnknownHostException) LineBreakBufferedWriter(com.android.internal.util.LineBreakBufferedWriter)

Aggregations

DeadSystemException (android.os.DeadSystemException)5 LineBreakBufferedWriter (com.android.internal.util.LineBreakBufferedWriter)5 UnknownHostException (java.net.UnknownHostException)5