Android Open Source - AndroidAppLog Async Appender






From Project

Back to project page AndroidAppLog.

License

The source code is released under:

Apache License

If you think the Android project AndroidAppLog listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package me.allenz.androidapplog;
//from  w  w w .  ja  v a  2s  .  c  om
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

import android.os.Process;

public abstract class AsyncAppender extends AbstractAppender {

    protected static final int DEFAULT_LOG_EVENT_QUEUE_SIZE = 100;

    protected Thread workThread;

    protected BlockingQueue<LogEvent> logEventQueue;

    public AsyncAppender(){
        workThread = new WorkThread();
        logEventQueue = new ArrayBlockingQueue<LogEvent>(
            DEFAULT_LOG_EVENT_QUEUE_SIZE);
    }

    @Override
    protected boolean doStart() {
        workThread.start();
        return true;
    }

    @Override
    protected boolean doStop() {
        workThread.interrupt();
        return true;
    }

    @Override
    protected void doAppend(final LogEvent event) {
        try {
            logEventQueue.put(event);
        } catch (final InterruptedException e) {
        }
    }

    protected abstract void handleEventQueue() throws InterruptedException;

    protected class WorkThread extends Thread {

        @Override
        public void run() {
            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
            while (!isInterrupted()) {
                try {
                    handleEventQueue();
                } catch (final InterruptedException e) {
                    if (!isStarted()) {
                        return;
                    }
                }
            }
        }

    }

}




Java Source Code List

me.allenz.androidapplog.AbstractAppender.java
me.allenz.androidapplog.AbstractLogger.java
me.allenz.androidapplog.AppenderSupportLogger.java
me.allenz.androidapplog.Appender.java
me.allenz.androidapplog.AsyncAppender.java
me.allenz.androidapplog.Configure.java
me.allenz.androidapplog.InternalLogger.java
me.allenz.androidapplog.LogCatAppender.java
me.allenz.androidapplog.LogEvent.java
me.allenz.androidapplog.LogLevel.java
me.allenz.androidapplog.LogTextView.java
me.allenz.androidapplog.LoggerConfig.java
me.allenz.androidapplog.LoggerFactory.java
me.allenz.androidapplog.Logger.java
me.allenz.androidapplog.PropertiesParser.java
me.allenz.androidapplog.ReflectUtils.java
me.allenz.androidapplog.Repository.java
me.allenz.androidapplog.RollingFileAppender.java
me.allenz.androidapplog.TextViewAppender.java
me.allenz.androidapplog.UncaughtExceptionLogger.java