mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-04 19:10:47 -05:00
app-ng: improve Magisk log parsing and UI
Magisk daemon internal logs skip the TAG field, outputting directly after the priority level. Update MagiskLogParser to treat logcat tags as part of the message and strip leading delimiters for internal logs. Also adjust the Magisk log card UI layout to format PID/TID clearly and remove the duplicate key generation in LazyColumn that caused crashes. Assisted-by: Gemini 3.7 Flash
This commit is contained in:
@@ -355,7 +355,6 @@ private fun MagiskLogTab(
|
||||
) {
|
||||
items(
|
||||
items = entries,
|
||||
key = { "${it.timestamp}_${it.pid}_${it.tid}_${it.message.hashCode()}" },
|
||||
contentType = { "MagiskLogCard" }
|
||||
) { entry ->
|
||||
MagiskLogCard(entry = entry)
|
||||
@@ -389,18 +388,23 @@ private fun MagiskLogCard(
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
modifier = Modifier.weight(1f)
|
||||
) {
|
||||
LogLevelBadge(level = entry.level)
|
||||
Text(
|
||||
text = entry.tag,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
if (entry.pid != 0) {
|
||||
val pidTidText = if (entry.tid != 0 && entry.tid != entry.pid) {
|
||||
"PID: ${entry.pid} TID: ${entry.tid}"
|
||||
} else {
|
||||
"PID: ${entry.pid}"
|
||||
}
|
||||
Text(
|
||||
text = pidTidText,
|
||||
fontSize = 11.sp,
|
||||
fontFamily = FontFamily.Monospace,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 1,
|
||||
)
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text(
|
||||
text = entry.timestamp,
|
||||
fontSize = 11.sp,
|
||||
@@ -409,7 +413,7 @@ private fun MagiskLogCard(
|
||||
maxLines = 1,
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.height(6.dp))
|
||||
Spacer(Modifier.height(8.dp))
|
||||
}
|
||||
|
||||
Text(
|
||||
|
||||
@@ -5,7 +5,6 @@ data class MagiskLogEntry(
|
||||
val pid: Int = 0,
|
||||
val tid: Int = 0,
|
||||
val level: Char = 'I',
|
||||
val tag: String = "",
|
||||
val message: String = "",
|
||||
val isParsed: Boolean = false,
|
||||
)
|
||||
@@ -13,8 +12,9 @@ data class MagiskLogEntry(
|
||||
object MagiskLogParser {
|
||||
|
||||
// Logcat format: "MM-DD HH:MM:SS.mmm PID TID LEVEL TAG : message"
|
||||
private val logcatRegex = Regex(
|
||||
"""(\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\.\d{3})\s+(\d+)\s+(\d+)\s+([VDIWEF])\s+(.+?)\s*:\s+(.*)"""
|
||||
// Magisk log format: "MM-DD HH:MM:SS.mmm PID TID LEVEL : message"
|
||||
private val logRegex = Regex(
|
||||
"""(\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\.\d{3})\s+(\d+)\s+(\d+)\s+([VDIWEF])\s+(?::\s*)?(.*)"""
|
||||
)
|
||||
|
||||
fun parse(raw: String): List<MagiskLogEntry> {
|
||||
@@ -26,7 +26,7 @@ object MagiskLogParser {
|
||||
for (line in lines) {
|
||||
if (line.isBlank()) continue
|
||||
|
||||
val match = logcatRegex.find(line)
|
||||
val match = logRegex.find(line)
|
||||
if (match != null) {
|
||||
result.add(
|
||||
MagiskLogEntry(
|
||||
@@ -34,8 +34,7 @@ object MagiskLogParser {
|
||||
pid = match.groupValues[2].toIntOrNull() ?: 0,
|
||||
tid = match.groupValues[3].toIntOrNull() ?: 0,
|
||||
level = match.groupValues[4].firstOrNull() ?: 'I',
|
||||
tag = match.groupValues[5].trim(),
|
||||
message = match.groupValues[6],
|
||||
message = match.groupValues[5],
|
||||
isParsed = true,
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user