From 0a403259c83b8b0f3105881898d112f5a8b43390 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 5 Feb 2021 08:21:53 +0800 Subject: [PATCH] edit LogUtils.kt --- .../main/java/io/legado/app/utils/LogUtils.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/utils/LogUtils.kt b/app/src/main/java/io/legado/app/utils/LogUtils.kt index 514c0b793..b94274a3b 100644 --- a/app/src/main/java/io/legado/app/utils/LogUtils.kt +++ b/app/src/main/java/io/legado/app/utils/LogUtils.kt @@ -32,19 +32,19 @@ object LogUtils { val root = appCtx.externalCacheDir ?: return@lazy null val logFolder = FileUtils.createFolderIfNotExist(root, "logs") val logPath = FileUtils.getPath(root = logFolder, "appLog") - val fileHandler = FileHandler(logPath, 10240, 10) - fileHandler.formatter = object : java.util.logging.Formatter() { - override fun format(record: LogRecord): String { - // 设置文件输出格式 - return (getCurrentDateStr(TIME_PATTERN) + ": " + record.message + "\n") + FileHandler(logPath, 10240, 10).apply { + formatter = object : java.util.logging.Formatter() { + override fun format(record: LogRecord): String { + // 设置文件输出格式 + return (getCurrentDateStr(TIME_PATTERN) + ": " + record.message + "\n") + } + } + level = if (appCtx.getPrefBoolean("recordLog")) { + Level.INFO + } else { + Level.OFF } } - fileHandler.level = if (appCtx.getPrefBoolean("recordLog")) { - Level.INFO - } else { - Level.OFF - } - return@lazy fileHandler } fun upLevel() {