mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-08 00:16:09 +00:00
Create method for making available the change of the log folder
This commit is contained in:
parent
b0fe841c3e
commit
cb7b547cd7
@ -13,19 +13,23 @@ import android.util.Log;
|
|||||||
|
|
||||||
public class Log_OC {
|
public class Log_OC {
|
||||||
private static final String SIMPLE_DATE_FORMAT = "yyyy/MM/dd HH:mm:ss";
|
private static final String SIMPLE_DATE_FORMAT = "yyyy/MM/dd HH:mm:ss";
|
||||||
private static final String OWNCLOUD_DATA_FOLDER = "owncloud";
|
private static final String LOG_FOLDER_NAME = "log";
|
||||||
private static final long MAX_FILE_SIZE = 1000000; // 1MB
|
private static final long MAX_FILE_SIZE = 1000000; // 1MB
|
||||||
|
|
||||||
|
private static String mOwncloudDataFolderLog = "owncloud_log";
|
||||||
|
|
||||||
private static File mLogFile;
|
private static File mLogFile;
|
||||||
private static File mFolder;
|
private static File mFolder;
|
||||||
private static BufferedWriter mBuf;
|
private static BufferedWriter mBuf;
|
||||||
|
|
||||||
private static String[] mLogFileNames = {"currentLog.txt", "olderLog.txt"};
|
private static String[] mLogFileNames = {"currentLog.txt", "olderLog.txt"};
|
||||||
private static String mLogPath = Environment.getExternalStorageDirectory() + File.separator +
|
|
||||||
OWNCLOUD_DATA_FOLDER + File.separator + "log";
|
|
||||||
|
|
||||||
private static boolean isMaxFileSizeReached = false;
|
private static boolean isMaxFileSizeReached = false;
|
||||||
|
|
||||||
|
public static void setLogDataFolder(String logFolder){
|
||||||
|
mOwncloudDataFolderLog = logFolder;
|
||||||
|
}
|
||||||
|
|
||||||
public static void i(String TAG, String message){
|
public static void i(String TAG, String message){
|
||||||
|
|
||||||
// Write the log message to the file
|
// Write the log message to the file
|
||||||
@ -69,7 +73,9 @@ public class Log_OC {
|
|||||||
* Start doing logging
|
* Start doing logging
|
||||||
* @param logPath : path of log file
|
* @param logPath : path of log file
|
||||||
*/
|
*/
|
||||||
public static void startLogging(String logPath) {
|
public static void startLogging() {
|
||||||
|
String logPath = Environment.getExternalStorageDirectory() + File.separator +
|
||||||
|
mOwncloudDataFolderLog + File.separator + LOG_FOLDER_NAME;
|
||||||
mFolder = new File(logPath);
|
mFolder = new File(logPath);
|
||||||
mLogFile = new File(mFolder + File.separator + mLogFileNames[0]);
|
mLogFile = new File(mFolder + File.separator + mLogFileNames[0]);
|
||||||
|
|
||||||
@ -78,7 +84,7 @@ public class Log_OC {
|
|||||||
if (!mFolder.exists()) {
|
if (!mFolder.exists()) {
|
||||||
mFolder.mkdirs();
|
mFolder.mkdirs();
|
||||||
isFileCreated = true;
|
isFileCreated = true;
|
||||||
Log_OC.d("LOG_OC", "Log file created");
|
Log.d("LOG_OC", "Log file created");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -143,7 +149,9 @@ public class Log_OC {
|
|||||||
* @param text : text for adding to the log file
|
* @param text : text for adding to the log file
|
||||||
*/
|
*/
|
||||||
private static void appendLog(String text) {
|
private static void appendLog(String text) {
|
||||||
startLogging(mLogPath);
|
|
||||||
|
startLogging();
|
||||||
|
|
||||||
String timeStamp = new SimpleDateFormat(SIMPLE_DATE_FORMAT).format(Calendar.getInstance().getTime());
|
String timeStamp = new SimpleDateFormat(SIMPLE_DATE_FORMAT).format(Calendar.getInstance().getTime());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user