Commit ca60f7f3 authored by dsq's avatar dsq

修改日志打印文本

parent fdc2313b
...@@ -8,6 +8,7 @@ import androidx.compose.ui.Alignment ...@@ -8,6 +8,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.dong.demo013.pirntRandomHiLog
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive import kotlinx.coroutines.isActive
import kotlin.time.TimeSource import kotlin.time.TimeSource
...@@ -16,7 +17,7 @@ import kotlin.time.TimeSource ...@@ -16,7 +17,7 @@ import kotlin.time.TimeSource
@Composable @Composable
internal fun HighLogDemo() { internal fun HighLogDemo() {
// 日志参数状态 // 日志参数状态
var logSpeed by remember { mutableStateOf("100") } var logSpeed by remember { mutableStateOf("1000") }
var logCount by remember { mutableStateOf(0) } var logCount by remember { mutableStateOf(0) }
var isGenerating by remember { mutableStateOf(false) } var isGenerating by remember { mutableStateOf(false) }
...@@ -31,7 +32,7 @@ internal fun HighLogDemo() { ...@@ -31,7 +32,7 @@ internal fun HighLogDemo() {
if (isTimerRunning) { if (isTimerRunning) {
startTimeMark = timeSource.markNow() startTimeMark = timeSource.markNow()
while (isActive && isTimerRunning) { while (isActive && isTimerRunning) {
delay(100) // 每 100ms 更新一次显示 delay(1000) // 每 1000ms 更新一次显示
displayTime = startTimeMark.elapsedNow().inWholeSeconds displayTime = startTimeMark.elapsedNow().inWholeSeconds
} }
} else { } else {
...@@ -43,10 +44,11 @@ internal fun HighLogDemo() { ...@@ -43,10 +44,11 @@ internal fun HighLogDemo() {
// 日志生成协程 // 日志生成协程
LaunchedEffect(isGenerating, logSpeed) { LaunchedEffect(isGenerating, logSpeed) {
if (isGenerating) { if (isGenerating) {
val speed = logSpeed.toIntOrNull() ?: 100 val speed = logSpeed.toIntOrNull() ?: 1000
while (isActive && isGenerating) { while (isActive && isGenerating) {
delay(speed.toLong()) delay(speed.toLong())
logCount++ logCount++
pirntRandomHiLog()
} }
} }
} }
......
...@@ -14,7 +14,7 @@ fun hiLogPrintMsg(type: UInt, level: UInt, domain: UInt, tag: String, message: S ...@@ -14,7 +14,7 @@ fun hiLogPrintMsg(type: UInt, level: UInt, domain: UInt, tag: String, message: S
} }
actual fun pirntSingleHiLog(){ actual fun pirntSingleHiLog(){
hiLogPrintMsg(0u, 6u, 4660u, "TestTag", "单次日志打印"); hiLogPrintMsg(0u, 6u, 4660u, "TestTag", "单次日志打印-高亮");
} }
...@@ -45,5 +45,5 @@ actual fun pirntAllLevelHiLog(){ ...@@ -45,5 +45,5 @@ actual fun pirntAllLevelHiLog(){
actual fun pirntRandomHiLog(){ actual fun pirntRandomHiLog(){
hiLogPrintMsg(0u, 6u, 4660u, "TestTag", "随机日志打印"); hiLogPrintMsg(0u, 6u, 4660u, "TestTag", "持续日志打印-高亮");
} }
...@@ -13,7 +13,7 @@ fun hiLogPrintMsg(type: UInt, level: UInt, domain: UInt, tag: String, message: S ...@@ -13,7 +13,7 @@ fun hiLogPrintMsg(type: UInt, level: UInt, domain: UInt, tag: String, message: S
} }
actual fun pirntSingleHiLog(){ actual fun pirntSingleHiLog(){
hiLogPrintMsg(0u, 6u, 4660u, "TestTag", "单次日志打印"); hiLogPrintMsg(0u, 6u, 4660u, "TestTag", "单次日志打印-高亮");
} }
...@@ -44,5 +44,5 @@ actual fun pirntAllLevelHiLog(){ ...@@ -44,5 +44,5 @@ actual fun pirntAllLevelHiLog(){
actual fun pirntRandomHiLog(){ actual fun pirntRandomHiLog(){
hiLogPrintMsg(0u, 6u, 4660u, "TestTag", "随机日志打印"); hiLogPrintMsg(0u, 6u, 4660u, "TestTag", "持续日志打印-高亮");
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment