mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-24 10:51:27 +01:00
Add a log viewer to Spinner.
This is more of a proof-of-concept/demo for using a websocket with Spinner. Gives an example of how we could push live updates to the webapp. Also, the logger is actually nice. Guaranteed to never get cluttered with system logs. Looks basically identical to our other log viewers. Filtering is basic but fast. And we could build much better tooling on top of this.
This commit is contained in:
committed by
Cody Henthorne
parent
c314918c6b
commit
6a974c48ef
@@ -3,10 +3,16 @@ package org.signal.spinnertest
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.widget.Button
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.contentValuesOf
|
||||
import org.signal.core.util.ThreadUtil
|
||||
import org.signal.core.util.logging.AndroidLogger
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.spinner.Spinner
|
||||
import org.signal.spinner.SpinnerLogger
|
||||
import java.util.UUID
|
||||
import kotlin.random.Random
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -26,6 +32,25 @@ class MainActivity : AppCompatActivity() {
|
||||
mapOf("main" to Spinner.DatabaseConfig(db = { db })),
|
||||
emptyMap()
|
||||
)
|
||||
|
||||
Log.initialize(AndroidLogger(), SpinnerLogger())
|
||||
|
||||
object : Thread() {
|
||||
override fun run() {
|
||||
while (true) {
|
||||
when (Random.nextInt(0, 5)) {
|
||||
0 -> Log.v("MyTag", "Message: ${System.currentTimeMillis()}")
|
||||
1 -> Log.d("MyTag", "Message: ${System.currentTimeMillis()}")
|
||||
2 -> Log.i("MyTag", "Message: ${System.currentTimeMillis()}")
|
||||
3 -> Log.w("MyTag", "Message: ${System.currentTimeMillis()}")
|
||||
4 -> Log.e("MyTag", "Message: ${System.currentTimeMillis()}")
|
||||
}
|
||||
ThreadUtil.sleep(Random.nextLong(0, 200))
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
|
||||
findViewById<Button>(R.id.log_throwable_button).setOnClickListener { Log.e("MyTag", "Message: ${System.currentTimeMillis()}", Throwable()) }
|
||||
}
|
||||
|
||||
private fun insertMockData(db: SQLiteDatabase) {
|
||||
|
||||
@@ -27,4 +27,10 @@
|
||||
android:layout_height="match_parent"
|
||||
android:text="Then go to localhost:5000 in your browser." />
|
||||
|
||||
<Button
|
||||
android:id="@+id/log_throwable_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Log Throwable" />
|
||||
|
||||
</LinearLayout>
|
||||
Reference in New Issue
Block a user