mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 02:34:39 +00:00
fix: Log file is not being created
This commit is contained in:
parent
b1766ebb94
commit
53ea5bafee
3 changed files with 43 additions and 36 deletions
|
@ -2,13 +2,30 @@ package eu.kanade.tachiyomi.util.system
|
|||
|
||||
import co.touchlab.kermit.LogWriter
|
||||
import co.touchlab.kermit.Logger
|
||||
import co.touchlab.kermit.io.RollingFileLogWriter
|
||||
import co.touchlab.kermit.io.RollingFileLogWriterConfig
|
||||
import co.touchlab.kermit.platformLogWriter
|
||||
import kotlinx.datetime.Clock
|
||||
import kotlinx.datetime.TimeZone
|
||||
import kotlinx.datetime.todayIn
|
||||
import kotlinx.io.files.Path
|
||||
|
||||
fun Logger.w(e: Throwable) = w(e) { "Something is not right..." }
|
||||
fun Logger.e(e: Throwable) = e(e) { "Something went wrong!" }
|
||||
|
||||
fun Logger.setToDefault(
|
||||
writersToAdd: List<LogWriter>,
|
||||
) {
|
||||
Logger.setLogWriters(listOf(platformLogWriter()) + writersToAdd)
|
||||
Logger.setTag("Yokai")
|
||||
}
|
||||
|
||||
fun Logger.setupFileLog(logPath: Path, buildType: String? = null): LogWriter {
|
||||
val date = Clock.System.todayIn(TimeZone.currentSystemDefault())
|
||||
return RollingFileLogWriter(
|
||||
config = RollingFileLogWriterConfig(
|
||||
logFileName = date.toString() + if (buildType != null) "-$buildType-" else "" + ".log",
|
||||
logFilePath = logPath,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue