Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.util.Log;

import com.owncloud.android.lib.BuildConfig;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
Expand All @@ -13,15 +15,18 @@
public class Log_OC {
private static final String SIMPLE_DATE_FORMAT = "yyyy/MM/dd HH:mm:ss";
private static final String LOG_FOLDER_NAME = "log";
private static final long MAX_FILE_SIZE = 1000000; // 1MB
private static final long MAX_FILE_SIZE = 2000000; // 2MB

private static String mOwncloudDataFolderLog = "owncloud_log";

private static File mLogFile;
private static File mFolder;
private static BufferedWriter mBuf;

private static String[] mLogFileNames = {"currentLog.txt", "olderLog.txt"};
private static String[] mLogFileNames = {
"currentLog" + BuildConfig.BUILD_TYPE + ".txt",
"olderLog" + BuildConfig.BUILD_TYPE + ".txt"
};

private static boolean isMaxFileSizeReached = false;
private static boolean isEnabled = false;
Expand All @@ -32,37 +37,37 @@ public static void setLogDataFolder(String logFolder) {

public static void i(String TAG, String message) {
Log.i(TAG, message);
appendLog(TAG + " : " + message);
appendLog("I: " + TAG + " : " + message);
}

public static void d(String TAG, String message) {
Log.d(TAG, message);
appendLog(TAG + " : " + message);
appendLog("D: " + TAG + " : " + message);
}

public static void d(String TAG, String message, Exception e) {
Log.d(TAG, message, e);
appendLog(TAG + " : " + message + " Exception : " + e.getStackTrace());
appendLog("D: " + TAG + " : " + message + " Exception : " + e.getStackTrace());
}

public static void e(String TAG, String message) {
Log.e(TAG, message);
appendLog(TAG + " : " + message);
appendLog("E: " + TAG + " : " + message);
}

public static void e(String TAG, String message, Throwable e) {
Log.e(TAG, message, e);
appendLog(TAG + " : " + message + " Exception : " + e.getStackTrace());
appendLog("E: " + TAG + " : " + message + " Exception : " + e.getStackTrace());
}

public static void v(String TAG, String message) {
Log.v(TAG, message);
appendLog(TAG + " : " + message);
appendLog("V: " + TAG + " : " + message);
}

public static void w(String TAG, String message) {
Log.w(TAG, message);
appendLog(TAG + " : " + message);
appendLog("W: " + TAG + " : " + message);
}

/**
Expand All @@ -71,8 +76,7 @@ public static void w(String TAG, String message) {
* @param storagePath : directory for keeping logs
*/
synchronized public static void startLogging(String storagePath) {
String logPath = storagePath + File.separator +
mOwncloudDataFolderLog + File.separator + LOG_FOLDER_NAME;
String logPath = storagePath + File.separator + mOwncloudDataFolderLog + File.separator + LOG_FOLDER_NAME;
mFolder = new File(logPath);
mLogFile = new File(mFolder + File.separator + mLogFileNames[0]);

Expand Down