mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 17:46:37 +03:00
Add delete history login and chang the date format in logs
This commit is contained in:
parent
c7263a2cb4
commit
c281aaeb01
2 changed files with 12 additions and 14 deletions
|
@ -67,7 +67,7 @@ public class LogHistoryActivity extends SherlockActivity {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
Log_OC.stopLogging();
|
||||
Log_OC.deleteHistoryLogging();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -7,12 +7,11 @@ import java.io.IOException;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
public class Log_OC {
|
||||
private static final String SIMPLE_DATE_FORMAT = "HH:mm:ss";
|
||||
private static final String SIMPLE_DATE_FORMAT = "yyyy/MM/dd HH:mm:ss";
|
||||
private static final long MAX_FILE_SIZE = 10000;
|
||||
|
||||
private static File mLogFile;
|
||||
|
@ -83,7 +82,7 @@ public class Log_OC {
|
|||
|
||||
if (isMaxFileSizeReached) {
|
||||
|
||||
// Move current log file info to another file
|
||||
// Move current log file info to another file (old logs)
|
||||
File olderFile = new File(mFolder + File.separator + mLogFileNames[1]);
|
||||
if (mLogFile.exists()) {
|
||||
mLogFile.renameTo(olderFile);
|
||||
|
@ -111,17 +110,16 @@ public class Log_OC {
|
|||
}
|
||||
|
||||
/**
|
||||
* Stop doing logging
|
||||
* Delete history logging
|
||||
*/
|
||||
public static void stopLogging() {
|
||||
if (mLogFile != null) {
|
||||
try {
|
||||
mBuf = new BufferedWriter(new FileWriter(mLogFile, false));
|
||||
mBuf.append("");
|
||||
mBuf.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
public static void deleteHistoryLogging() {
|
||||
File folderLogs = new File(mFolder + File.separator);
|
||||
if(folderLogs.isDirectory()){
|
||||
String[] myFiles = folderLogs.list();
|
||||
for (int i=0; i<myFiles.length; i++) {
|
||||
File myFile = new File(folderLogs, myFiles[i]);
|
||||
myFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue