// Path: smssync/src/main/java/org/addhen/smssync/data/util/Logger.java
// public class Logger {
// 
//     public static final boolean LOGGING_MODE = BuildConfig.DEBUG;
// 
//     public Logger() {
// 
//     }
// 
//     public static void log(String tag, String message) {
//         if (LOGGING_MODE) {
//             Timber.tag(tag).i(message);
//         }
//     }
// 
//     public static void log(String tag, String format, Object... args) {
//         if (LOGGING_MODE) {
//             Timber.tag(tag).i(String.format(format, args));
//         }
//     }
// 
//     public static void log(String tag, String message, Exception ex) {
//         if (LOGGING_MODE) {
//             Timber.tag(tag).e(ex, message);
//         }
//     }
// }


import org.addhen.smssync.data.PrefsFactory;
import org.addhen.smssync.data.entity.Log;
import org.addhen.smssync.data.exception.LogNotFoundException;
import org.addhen.smssync.data.util.Logger;
import android.content.Context;
import android.os.Environment;
import android.text.format.DateFormat;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.LineNumberReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import rx.Observable;
    private String mName;

    PrefsFactory mPrefsFactory;

    @Inject
    public FileManager(Context context, PrefsFactory prefsFactory) {
        this(LOG_NAME);
        mPrefsFactory = prefsFactory;
    }

    public FileManager(String name) {
        mName = name;
        mDateFormat = "dd-MM kk:mm";
        if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
            final File logFile = getFile(name);
            if (logFile.isFile() && logFile.exists()) {
                rotate(logFile);
            }

            try {
                mWriter = new PrintWriter(new FileWriter(logFile, true));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }

    private void rotate(final File logFile) {
        if (logFile.length() > MAX_SIZE) {
// Path: smssync/src/main/java/org/addhen/smssync/data/util/Logger.java
// public class Logger {
// 
//     public static final boolean LOGGING_MODE = BuildConfig.DEBUG;
// 
//     public Logger() {
// 
//     }
// 
//     public static void log(String tag, String message) {
//         if (LOGGING_MODE) {
//             Timber.tag(tag).i(message);
//         }
//     }
// 
//     public static void log(String tag, String format, Object... args) {
//         if (LOGGING_MODE) {
//             Timber.tag(tag).i(String.format(format, args));
//         }
//     }
// 
//     public static void log(String tag, String message, Exception ex) {
//         if (LOGGING_MODE) {
//             Timber.tag(tag).e(ex, message);
//         }
//     }
// }


// Path: smssync/src/main/java/org/addhen/smssync/data/cache/FileManager.java
import org.addhen.smssync.data.PrefsFactory;
import org.addhen.smssync.data.entity.Log;
import org.addhen.smssync.data.exception.LogNotFoundException;
import org.addhen.smssync.data.util.Logger;
import android.content.Context;
import android.os.Environment;
import android.text.format.DateFormat;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.LineNumberReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import rx.Observable;

    private String mName;

    PrefsFactory mPrefsFactory;

    @Inject
    public FileManager(Context context, PrefsFactory prefsFactory) {
        this(LOG_NAME);
        mPrefsFactory = prefsFactory;
    }

    public FileManager(String name) {
        mName = name;
        mDateFormat = "dd-MM kk:mm";
        if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
            final File logFile = getFile(name);
            if (logFile.isFile() && logFile.exists()) {
                rotate(logFile);
            }

            try {
                mWriter = new PrintWriter(new FileWriter(logFile, true));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }

    private void rotate(final File logFile) {
        if (logFile.length() > MAX_SIZE) {
            Logger.log(TAG, "rotating logfile " + logFile);