FileDocCategorySizeDatePackage
LogWriter.javaAPI DocAndroid 5.1 API2429Thu Mar 12 22:22:10 GMT 2015android.util

LogWriter

public class LogWriter extends Writer
hide

Fields Summary
private final int
mPriority
private final String
mTag
private final int
mBuffer
private StringBuilder
mBuilder
Constructors Summary
public LogWriter(int priority, String tag)
Create a new Writer that sends to the log with the given priority and tag.

param
priority The desired log priority: {@link android.util.Log#VERBOSE Log.VERBOSE}, {@link android.util.Log#DEBUG Log.DEBUG}, {@link android.util.Log#INFO Log.INFO}, {@link android.util.Log#WARN Log.WARN}, or {@link android.util.Log#ERROR Log.ERROR}.
param
tag A string tag to associate with each printed log statement.


                                                          
         
        mPriority = priority;
        mTag = tag;
        mBuffer = Log.LOG_ID_MAIN;
    
public LogWriter(int priority, String tag, int buffer)

hide
Same as above, but buffer is one of the LOG_ID_ constants from android.util.Log.

        mPriority = priority;
        mTag = tag;
        mBuffer = buffer;
    
Methods Summary
public voidclose()

        flushBuilder();
    
public voidflush()

        flushBuilder();
    
private voidflushBuilder()

        if (mBuilder.length() > 0) {
            Log.println_native(mBuffer, mPriority, mTag, mBuilder.toString());
            mBuilder.delete(0, mBuilder.length());
        }
    
public voidwrite(char[] buf, int offset, int count)

        for(int i = 0; i < count; i++) {
            char c = buf[offset + i];
            if ( c == '\n") {
                flushBuilder();
            }
            else {
                mBuilder.append(c);
            }
        }