add appDb, appInfo

pull/840/head
gedoor 4 years ago
parent 3a15114e64
commit aa88cbc6b1
  1. 4
      app/src/main/java/io/legado/app/App.kt
  2. 2
      app/src/main/java/io/legado/app/constant/Const.kt
  3. 22
      app/src/main/java/io/legado/app/utils/LogUtils.kt

@ -22,10 +22,6 @@ import rxhttp.wrapper.param.RxHttp
class App : MultiDexApplication() { class App : MultiDexApplication() {
companion object {
var navigationBarHeight = 0
}
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
CrashHandler(this) CrashHandler(this)

@ -25,3 +25,5 @@ data class AppInfo(
var versionCode: Long = 0L, var versionCode: Long = 0L,
var versionName: String = "" var versionName: String = ""
) )
var navigationBarHeight = 0

@ -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")
FileHandler(logPath, 10240, 10).apply { val fileHandler = FileHandler(logPath, 10240, 10)
formatter = object : Formatter() { fileHandler.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")
}
}
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() { fun upLevel() {

Loading…
Cancel
Save