// Path: example/src/main/java/com/github/captain_miao/android/bluetoothletutorial/constant/BleLogLevel.java
// public class BleLogLevel {
// 
//     public static final int VERBOSE = Log.VERBOSE;
//     public static final int DEBUG   = Log.DEBUG;
//     public static final int INFO    = Log.INFO;
//     public static final int WARN    = Log.WARN;
//     public static final int ERROR   = Log.ERROR;
//     public static final int ASSERT  = Log.ASSERT;
// }


import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.query.Select;
import com.github.captain_miao.android.bluetoothletutorial.constant.BleLogLevel;
package com.github.captain_miao.android.bluetoothletutorial.model;


/**
 * @author Yan Lu
 * @since 2016-08-28
 */
public class BleLogInfo extends Model {

    @Column(unique = true, onUniqueConflict = Column.ConflictAction.REPLACE)
    public long logTime;

    @Column()
    public String log;

    @Column()
    public int logLevel;


    public BleLogInfo() {
    }

    public BleLogInfo(String log, int logLevel) {
        this.logTime = System.currentTimeMillis();
        this.log = log == null ? "" : log;
        this.logLevel = logLevel;
    }

    public BleLogInfo(long logTime, String log, int logLevel) {
        this.logTime = logTime;
        this.log = log;
        this.logLevel = logLevel;
    }

    public static BleLogInfo getLogs(long beginTime, long endTime) {
        BleLogInfo logs = new Select()
                .from(BleLogInfo.class)
                .where("logTime >=?", beginTime)
                .and("logTime <=?", endTime)
                .executeSingle();

        if(logs == null) {
// Path: example/src/main/java/com/github/captain_miao/android/bluetoothletutorial/constant/BleLogLevel.java
// public class BleLogLevel {
// 
//     public static final int VERBOSE = Log.VERBOSE;
//     public static final int DEBUG   = Log.DEBUG;
//     public static final int INFO    = Log.INFO;
//     public static final int WARN    = Log.WARN;
//     public static final int ERROR   = Log.ERROR;
//     public static final int ASSERT  = Log.ASSERT;
// }


// Path: example/src/main/java/com/github/captain_miao/android/bluetoothletutorial/model/BleLogInfo.java
import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.query.Select;
import com.github.captain_miao.android.bluetoothletutorial.constant.BleLogLevel;

package com.github.captain_miao.android.bluetoothletutorial.model;


/**
 * @author Yan Lu
 * @since 2016-08-28
 */
public class BleLogInfo extends Model {

    @Column(unique = true, onUniqueConflict = Column.ConflictAction.REPLACE)
    public long logTime;

    @Column()
    public String log;

    @Column()
    public int logLevel;


    public BleLogInfo() {
    }

    public BleLogInfo(String log, int logLevel) {
        this.logTime = System.currentTimeMillis();
        this.log = log == null ? "" : log;
        this.logLevel = logLevel;
    }

    public BleLogInfo(long logTime, String log, int logLevel) {
        this.logTime = logTime;
        this.log = log;
        this.logLevel = logLevel;
    }

    public static BleLogInfo getLogs(long beginTime, long endTime) {
        BleLogInfo logs = new Select()
                .from(BleLogInfo.class)
                .where("logTime >=?", beginTime)
                .and("logTime <=?", endTime)
                .executeSingle();

        if(logs == null) {
            logs = new BleLogInfo("", BleLogLevel.VERBOSE);