Skip to content

Commit fd20eb8

Browse files
committed
Revert "optional thread check in Filelogger"
This reverts commit e6ff06d.
1 parent 56dd2f2 commit fd20eb8

1 file changed

Lines changed: 5 additions & 15 deletions

File tree

LogcatCoreLib/src/main/java/info/hannes/timber/FileLoggingTree.kt

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package info.hannes.timber
22

33
import android.annotation.SuppressLint
44
import android.content.Context
5-
import android.os.Handler
65
import android.util.Log
76
import androidx.lifecycle.MutableLiveData
87
import java.io.File
@@ -45,12 +44,12 @@ open class FileLoggingTree(externalCacheDir: File, context: Context? = null, fil
4544
else -> "$priority"
4645
}
4746

47+
val writer = FileWriter(file, true)
4848
val textLine = "$priorityText $logTimeStamp$tag$message\n"
49-
50-
if (!threadCheck && Thread.currentThread().name == "main")
51-
doFileLogging(textLine)
52-
else
53-
Handler().post { doFileLogging(textLine) }
49+
writer.append(textLine)
50+
writer.flush()
51+
writer.close()
52+
lastLogEntry.value = textLine
5453
} catch (e: Exception) {
5554
// Log to prevent an endless loop
5655
if (!logImpossible) {
@@ -63,20 +62,11 @@ open class FileLoggingTree(externalCacheDir: File, context: Context? = null, fil
6362
super.log(priority, tag, message, t)
6463
}
6564

66-
private fun doFileLogging(textLine: String) {
67-
val writer = FileWriter(file, true)
68-
writer.append(textLine)
69-
writer.flush()
70-
writer.close()
71-
lastLogEntry.value = textLine
72-
}
73-
7465
fun getFileName(): String = file.absolutePath
7566

7667
companion object {
7768
private val LOG_TAG = FileLoggingTree::class.java.simpleName
7869
private var logImpossible = false
79-
var threadCheck = false
8070
val lastLogEntry: MutableLiveData<String> = MutableLiveData<String>()
8171
}
8272
}

0 commit comments

Comments
 (0)