mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 02:17:41 +00:00 
			
		
		
		
	compact logfile
time and text in same line, no empty lines
This commit is contained in:
		
							parent
							
								
									1aae034b70
								
							
						
					
					
						commit
						7954bdbcdd
					
				| @ -8,6 +8,7 @@ import java.io.FileWriter; | |||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||||
| import java.util.Calendar; | import java.util.Calendar; | ||||||
|  | import java.util.Locale; | ||||||
| 
 | 
 | ||||||
| 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"; | ||||||
| @ -114,7 +115,6 @@ public class Log_OC { | |||||||
|             mFolder = null; |             mFolder = null; | ||||||
|             mBuf = null; |             mBuf = null; | ||||||
|             isMaxFileSizeReached = false; |             isMaxFileSizeReached = false; | ||||||
|             isEnabled = false; |  | ||||||
| 
 | 
 | ||||||
|         } catch (IOException e) { |         } catch (IOException e) { | ||||||
|             // Because we are stopping logging, we only log to Android console. |             // Because we are stopping logging, we only log to Android console. | ||||||
| @ -134,8 +134,8 @@ public class Log_OC { | |||||||
|         File folderLogs = new File(mFolder + File.separator); |         File folderLogs = new File(mFolder + File.separator); | ||||||
|         if(folderLogs.isDirectory()){ |         if(folderLogs.isDirectory()){ | ||||||
|             String[] myFiles = folderLogs.list(); |             String[] myFiles = folderLogs.list(); | ||||||
|             for (int i=0; i<myFiles.length; i++) { |             for (String myFile1 : myFiles) { | ||||||
|                 File myFile = new File(folderLogs, myFiles[i]); |                 File myFile = new File(folderLogs, myFile1); | ||||||
|                 myFile.delete(); |                 myFile.delete(); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| @ -174,15 +174,12 @@ public class Log_OC { | |||||||
|                 isMaxFileSizeReached = false; |                 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 { | 	        try { | ||||||
| 	            mBuf = new BufferedWriter(new FileWriter(mLogFile, true)); | 	            mBuf = new BufferedWriter(new FileWriter(mLogFile, true)); | ||||||
| 	            mBuf.newLine(); | 	            mBuf.newLine(); | ||||||
| 	            mBuf.write(timeStamp); | 	            mBuf.write(timeStamp+" "+text); | ||||||
| 	            mBuf.newLine(); |  | ||||||
| 	            mBuf.write(text); |  | ||||||
| 	            mBuf.newLine(); |  | ||||||
| 	        } catch (IOException e) { | 	        } catch (IOException e) { | ||||||
| 	            e.printStackTrace(); | 	            e.printStackTrace(); | ||||||
| 	        } finally { | 	        } finally { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user