pull/32/head
kunfei 5 years ago
parent 746dd05a9f
commit e862836349
  1. 32
      app/src/main/java/io/legado/app/model/webbook/Debug.kt

@ -0,0 +1,32 @@
package io.legado.app.model.webbook
import android.annotation.SuppressLint
import io.legado.app.utils.htmlFormat
import java.text.SimpleDateFormat
import java.util.*
object Debug {
var debugSource: String? = null
var callback: Callback? = null
@SuppressLint("ConstantLocale")
private val DEBUG_TIME_FORMAT = SimpleDateFormat("[mm:ss.SSS]", Locale.getDefault())
private val startTime: Long = System.currentTimeMillis()
interface Callback {
fun printLog(state: Int, msg: String)
}
fun printLog(source: String, state: Int, msg: String, print: Boolean = true, isHtml: Boolean = false) {
if (debugSource != source) return
if (!print) return
var printMsg = msg
if (isHtml) {
printMsg = printMsg.htmlFormat()
}
printMsg =
String.format("%s %s", DEBUG_TIME_FORMAT.format(Date(System.currentTimeMillis() - startTime)), printMsg)
callback?.printLog(state, printMsg)
}
}
Loading…
Cancel
Save