mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 02:17:41 +00:00 
			
		
		
		
	
						commit
						5f579fbb24
					
				| @ -8,6 +8,7 @@ import java.io.FileWriter; | ||||
| import java.io.IOException; | ||||
| import java.text.SimpleDateFormat; | ||||
| import java.util.Calendar; | ||||
| import java.util.Locale; | ||||
| 
 | ||||
| public class Log_OC { | ||||
|     private static final String SIMPLE_DATE_FORMAT = "yyyy/MM/dd HH:mm:ss"; | ||||
| @ -38,10 +39,12 @@ public class Log_OC { | ||||
|         Log.d(TAG, message); | ||||
|         appendLog(TAG + " : " + message); | ||||
|     } | ||||
| 
 | ||||
|     public static void d(String TAG, String message, Exception e) { | ||||
|         Log.d(TAG, message, e); | ||||
|         appendLog(TAG + " : " + message + " Exception : " + e.getStackTrace()); | ||||
|     } | ||||
| 
 | ||||
|     public static void e(String TAG, String message) { | ||||
|         Log.e(TAG, message); | ||||
|         appendLog(TAG + " : " + message); | ||||
| @ -64,6 +67,7 @@ public class Log_OC { | ||||
| 
 | ||||
|     /** | ||||
|      * Start doing logging | ||||
|      * | ||||
|      * @param storagePath : directory for keeping logs | ||||
|      */ | ||||
|     synchronized public static void startLogging(String storagePath) { | ||||
| @ -106,15 +110,15 @@ public class Log_OC { | ||||
| 
 | ||||
|     synchronized public static void stopLogging() { | ||||
|         try { | ||||
| 			if (mBuf != null) | ||||
|             if (mBuf != null) { | ||||
|                 mBuf.close(); | ||||
|             } | ||||
|             isEnabled = false; | ||||
| 
 | ||||
|             mLogFile = null; | ||||
|             mFolder = null; | ||||
|             mBuf = null; | ||||
|             isMaxFileSizeReached = false; | ||||
|             isEnabled = false; | ||||
| 
 | ||||
|         } catch (IOException e) { | ||||
|             // Because we are stopping logging, we only log to Android console. | ||||
| @ -134,9 +138,9 @@ public class Log_OC { | ||||
|         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(); | ||||
|             for (String fileName : myFiles) { | ||||
|                 File fileInFolder = new File(folderLogs, fileName); | ||||
|                 Log_OC.d("delete file", fileInFolder.getAbsoluteFile() + " " + fileInFolder.delete()); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @ -155,6 +159,7 @@ public class Log_OC { | ||||
| 
 | ||||
|     /** | ||||
|      * Append to the log file the info passed | ||||
|      * | ||||
|      * @param text : text for adding to the log file | ||||
|      */ | ||||
|     synchronized private static void appendLog(String text) { | ||||
| @ -174,15 +179,12 @@ public class Log_OC { | ||||
|                 isMaxFileSizeReached = false; | ||||
|             } | ||||
| 
 | ||||
| 	        String timeStamp = new SimpleDateFormat(SIMPLE_DATE_FORMAT).format(Calendar.getInstance().getTime()); | ||||
|             String timeStamp = new SimpleDateFormat(SIMPLE_DATE_FORMAT, Locale.ENGLISH).format(Calendar.getInstance().getTime()); | ||||
| 
 | ||||
|             try { | ||||
|                 mBuf = new BufferedWriter(new FileWriter(mLogFile, true)); | ||||
|                 mBuf.newLine(); | ||||
| 	            mBuf.write(timeStamp); | ||||
| 	            mBuf.newLine(); | ||||
| 	            mBuf.write(text); | ||||
| 	            mBuf.newLine(); | ||||
|                 mBuf.write(timeStamp + " " + text); | ||||
|             } catch (IOException e) { | ||||
|                 e.printStackTrace(); | ||||
|             } finally { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user