package com.ihewro.focus.helper;

import android.os.Looper;
import android.util.Printer;

/**
 * <pre>
 *     author : hewro
 *     e-mail : [email protected]
 *     time   : 2019/06/23
 *     desc   :
 *     version: 1.0
 * </pre>
 */
public class BlockDetectByPrinter {

    public static void start() {

        Looper.getMainLooper().setMessageLogging(new Printer() {

            private static final String START = ">>>>> Dispatching";
            private static final String END = "<<<<< Finished";

            @Override
            public void println(String x) {
                if (x.startsWith(START)) {
                    LogMonitor.getInstance().startMonitor();
                }
                if (x.startsWith(END)) {
                    LogMonitor.getInstance().removeMonitor();
                }
            }
        });

    }
}