mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
fix: Some attempt
This commit is contained in:
parent
cea9da9c6d
commit
5fa5815541
3 changed files with 34 additions and 27 deletions
|
@ -33,6 +33,7 @@ import coil3.request.crossfade
|
|||
import coil3.util.DebugLogger
|
||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||
import com.google.firebase.ktx.Firebase
|
||||
import com.hippo.unifile.UniFile
|
||||
import eu.kanade.tachiyomi.appwidget.TachiyomiWidgetManager
|
||||
import eu.kanade.tachiyomi.core.preference.Preference
|
||||
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
||||
|
@ -55,6 +56,7 @@ import eu.kanade.tachiyomi.util.system.GLUtil
|
|||
import eu.kanade.tachiyomi.util.system.ImageUtil
|
||||
import eu.kanade.tachiyomi.util.system.launchIO
|
||||
import eu.kanade.tachiyomi.util.system.localeContext
|
||||
import eu.kanade.tachiyomi.util.system.nameWithoutExtension
|
||||
import eu.kanade.tachiyomi.util.system.notification
|
||||
import eu.kanade.tachiyomi.util.system.setToDefault
|
||||
import eu.kanade.tachiyomi.util.system.setupFileLog
|
||||
|
@ -88,14 +90,6 @@ open class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.F
|
|||
|
||||
private val disableIncognitoReceiver = DisableIncognitoReceiver()
|
||||
|
||||
private fun buildWritersToAdd(
|
||||
logPath: Path?,
|
||||
) = buildList {
|
||||
if (!BuildConfig.DEBUG) add(CrashlyticsLogWriter())
|
||||
|
||||
if (logPath != null) add(Logger.setupFileLog(logPath, BuildConfig.BUILD_TYPE))
|
||||
}
|
||||
|
||||
@SuppressLint("LaunchActivityFromNotification")
|
||||
override fun onCreate() {
|
||||
super<Application>.onCreate()
|
||||
|
@ -119,8 +113,7 @@ open class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.F
|
|||
|
||||
val scope = ProcessLifecycleOwner.get().lifecycleScope
|
||||
|
||||
val logPath = storageManager.getLogsDirectory()?.filePath?.let { path -> Path(path) }
|
||||
Logger.setToDefault(buildLogWritersToAdd(logPath))
|
||||
Logger.setToDefault(buildLogWritersToAdd(storageManager.getLogsFile()))
|
||||
|
||||
basePreferences.crashReport().changes()
|
||||
.onEach {
|
||||
|
@ -291,11 +284,18 @@ open class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.F
|
|||
}
|
||||
|
||||
fun buildLogWritersToAdd(
|
||||
logPath: Path?,
|
||||
logFile: UniFile?,
|
||||
) = buildList {
|
||||
if (!BuildConfig.DEBUG) add(CrashlyticsLogWriter())
|
||||
|
||||
// if (logPath != null) add(Logger.setupFileLog(logPath, BuildConfig.BUILD_TYPE))
|
||||
//val fileName = logFile?.nameWithoutExtension
|
||||
//val filePath = logFile?.parentFile?.filePath?.let { path -> Path(path) }
|
||||
//if (filePath != null && fileName != null) add(
|
||||
// Logger.setupFileLog(
|
||||
// logFileName = fileName,
|
||||
// logPath = filePath,
|
||||
// )
|
||||
//)
|
||||
}
|
||||
|
||||
private const val ACTION_DISABLE_INCOGNITO_MODE = "tachi.action.DISABLE_INCOGNITO_MODE"
|
||||
|
|
|
@ -4,9 +4,13 @@ import android.content.Context
|
|||
import androidx.core.net.toUri
|
||||
import co.touchlab.kermit.Logger
|
||||
import com.hippo.unifile.UniFile
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.buildLogWritersToAdd
|
||||
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
||||
import eu.kanade.tachiyomi.util.system.setToDefault
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
|
@ -46,16 +50,17 @@ class StorageManager(
|
|||
}
|
||||
parent.createDirectory(COVERS_PATH)
|
||||
parent.createDirectory(PAGES_PATH)
|
||||
parent.createDirectory(LOGS_PATH)?.also {
|
||||
try {
|
||||
Logger.setToDefault(buildLogWritersToAdd(it.filePath?.let { path -> Path(path) }))
|
||||
} catch (e: Exception) {
|
||||
// Just in case something went horribly wrong
|
||||
Logger.setToDefault(buildLogWritersToAdd(null))
|
||||
Logger.e(e) { "Something went wrong while trying to setup log file" }
|
||||
}
|
||||
}
|
||||
parent.createDirectory(LOGS_PATH)
|
||||
}
|
||||
|
||||
try {
|
||||
Logger.setToDefault(buildLogWritersToAdd(getLogsFile()))
|
||||
} catch (e: Exception) {
|
||||
// Just in case something went horribly wrong
|
||||
Logger.setToDefault(buildLogWritersToAdd(null))
|
||||
Logger.e(e) { "Something went wrong while trying to setup log file" }
|
||||
}
|
||||
|
||||
_changes.send(Unit)
|
||||
}
|
||||
.launchIn(scope)
|
||||
|
@ -93,6 +98,11 @@ class StorageManager(
|
|||
fun getLogsDirectory(): UniFile? {
|
||||
return baseDir?.createDirectory(LOGS_PATH)
|
||||
}
|
||||
|
||||
fun getLogsFile(): UniFile? {
|
||||
val date = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(Date())
|
||||
return getLogsDirectory()?.createFile("${date}-${BuildConfig.BUILD_TYPE}.log")
|
||||
}
|
||||
}
|
||||
|
||||
private const val BACKUPS_PATH = "backup"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue