Skip to content

Commit afc0c1a

Browse files
Update app/src/main/kotlin/com/wire/android/util/logging/LogFileWriterV2Impl.kt
Co-authored-by: Yamil Medina <[email protected]>
1 parent 745718f commit afc0c1a

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

app/src/main/kotlin/com/wire/android/util/logging/LogFileWriterV2Impl.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,17 @@ class LogFileWriterV2Impl(
141141
Runtime.getRuntime().exec("logcat -c")
142142
logcatProcess = Runtime.getRuntime().exec("logcat")
143143

144-
val reader = logcatProcess!!.inputStream.bufferedReader()
145-
146-
appLogger.i("Starting to write log files, grabbing from logcat")
147-
while (isActive) {
148-
val text = reader.readLine()
149-
if (!text.isNullOrBlank()) {
150-
val fileSize = writeLineToFile(text)
151-
emit(fileSize)
144+
logcatProcess?.inputStream?.bufferedReader().use {
145+
appLogger.i("Starting to write log files, grabbing from logcat")
146+
while (isActive) {
147+
val text = readlnOrNull()
148+
if (!text.isNullOrBlank()) {
149+
val fileSize = writeLineToFile(text)
150+
emit(fileSize)
151+
}
152152
}
153+
stopLogcatProcess()
153154
}
154-
reader.close()
155-
stopLogcatProcess()
156155
}.flowOn(Dispatchers.IO)
157156

158157
private fun stopLogcatProcess() {

0 commit comments

Comments
 (0)