@@ -22,7 +22,7 @@ import com.elvishew.xlog.LogLevel
2222import com.elvishew.xlog.XLog
2323import com.elvishew.xlog.printer.AndroidPrinter
2424import com.elvishew.xlog.printer.file.FilePrinter
25- import com.elvishew.xlog.printer.file.clean.FileLastModifiedCleanStrategy
25+ import com.elvishew.xlog.printer.file.naming.DateFileNameGenerator
2626import com.fredhappyface.ewesticker.utilities.StickerImporter
2727import com.fredhappyface.ewesticker.utilities.Toaster
2828import com.google.android.material.progressindicator.LinearProgressIndicator
@@ -31,7 +31,10 @@ import kotlinx.coroutines.Dispatchers
3131import kotlinx.coroutines.launch
3232import kotlinx.coroutines.withContext
3333import java.io.File
34+ import java.text.SimpleDateFormat
35+ import java.util.Locale
3436import java.util.Calendar
37+ import java.util.Date
3538
3639/* * MainActivity class inherits from the AppCompatActivity class - provides the settings view */
3740class MainActivity : AppCompatActivity () {
@@ -56,7 +59,9 @@ class MainActivity : AppCompatActivity() {
5659 AndroidPrinter (true ) // Printer that print the log using android.util.Log
5760 val filePrinter = FilePrinter .Builder (
5861 File (filesDir, " logs" ).path
59- ).cleanStrategy(FileLastModifiedCleanStrategy (86_400_000 )).build() // 1day
62+ ).fileNameGenerator(DateFileNameGenerator ()).build()
63+
64+
6065 XLog .init (logConfig, androidPrinter, filePrinter)
6166
6267 XLog .i(" =" .repeat(80 ))
@@ -106,6 +111,7 @@ class MainActivity : AppCompatActivity() {
106111
107112 }
108113
114+
109115 /* *
110116 * Handles ACTION_OPEN_DOCUMENT_TREE result and adds stickerDirPath, lastUpdateDate to
111117 * this.sharedPreferences and resets recentCache, compatCache
@@ -138,7 +144,10 @@ class MainActivity : AppCompatActivity() {
138144 registerForActivityResult(ActivityResultContracts .StartActivityForResult ()) { result ->
139145 if (result.resultCode == RESULT_OK ) {
140146 result.data?.data?.also { uri ->
141- val file = File (filesDir, " logs/log" )
147+ val dateFormatter = SimpleDateFormat (" yyyy-MM-dd" , Locale .US )
148+ val currentDate = Date ()
149+ val logFileName = dateFormatter.format(currentDate)
150+ val file = File (filesDir, " logs/$logFileName " )
142151 if (file.exists()) {
143152 contentResolver.openOutputStream(uri)?.use { outputStream ->
144153 file.inputStream().use { inputStream ->
0 commit comments