Skip to content

Commit

Permalink
Handle 'UnparseableLine' in 'bufferedTransform'
Browse files Browse the repository at this point in the history
  • Loading branch information
NorseDreki committed Jan 24, 2024
1 parent a8c55b8 commit aff95e1
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions src/commonMain/kotlin/dogcat/LogLines.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,39 @@ class LogLines(
.map {
lineParser.parse(it)
}
.filterIsInstance<Brief>()
//.filterIsInstance<Brief>()
.bufferedTransform(
{ buffer, item ->
when {
buffer.isNotEmpty() -> {
val previous = buffer[0]
when (item) {
is Brief -> {
when {
item.tag.contains(previous.tag) -> false
else -> true
buffer.isNotEmpty() -> {
val previous = buffer[0]
when {
//previous == null -> false
(previous as? Brief)?.tag?.contains(item.tag) ?: false -> false
//item.tag.contains((previous as? Brief).tag) -> false
else -> true
}
}
else -> false
}
}
is Unparseable -> false // Pass through Unparseable items
else -> false
}
},
{ buffer, item ->
if (buffer.isEmpty()) {
item
} else {
Brief(item.level, "", item.owner, item.message)
when (item) {
is Brief -> {
if (buffer.isEmpty()) {
item
} else {
Brief(item.level, "", item.owner, item.message)
}
}
is Unparseable -> item // Pass through Unparseable items
else -> item
}
}
)
Expand Down

0 comments on commit aff95e1

Please sign in to comment.