edit LogUtils.kt

pull/840/head
gedoor 4 years ago
parent 39db2376bd
commit 0a403259c8
  1. 8
      app/src/main/java/io/legado/app/utils/LogUtils.kt

@ -32,19 +32,19 @@ object LogUtils {
val root = appCtx.externalCacheDir ?: return@lazy null val root = appCtx.externalCacheDir ?: return@lazy null
val logFolder = FileUtils.createFolderIfNotExist(root, "logs") val logFolder = FileUtils.createFolderIfNotExist(root, "logs")
val logPath = FileUtils.getPath(root = logFolder, "appLog") val logPath = FileUtils.getPath(root = logFolder, "appLog")
val fileHandler = FileHandler(logPath, 10240, 10) FileHandler(logPath, 10240, 10).apply {
fileHandler.formatter = object : java.util.logging.Formatter() { formatter = object : java.util.logging.Formatter() {
override fun format(record: LogRecord): String { override fun format(record: LogRecord): String {
// 设置文件输出格式 // 设置文件输出格式
return (getCurrentDateStr(TIME_PATTERN) + ": " + record.message + "\n") return (getCurrentDateStr(TIME_PATTERN) + ": " + record.message + "\n")
} }
} }
fileHandler.level = if (appCtx.getPrefBoolean("recordLog")) { level = if (appCtx.getPrefBoolean("recordLog")) {
Level.INFO Level.INFO
} else { } else {
Level.OFF Level.OFF
} }
return@lazy fileHandler }
} }
fun upLevel() { fun upLevel() {

Loading…
Cancel
Save