kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
in support of #212 log messages before analytics enabled
rodzic
2dd2a9ddbb
commit
43999e3d72
|
@ -27,20 +27,27 @@ class MeshUtilApplication : GeeksvilleApplication() {
|
|||
val pref = AppPrefs(this)
|
||||
crashlytics.setUserId(pref.getInstallId()) // be able to group all bugs per anonymous user
|
||||
|
||||
// We always send our log messages to the crashlytics lib, but they only get sent to the server if we report an exception
|
||||
// This makes log messages work properly if someone turns on analytics just before they click report bug.
|
||||
// send all log messages through crashyltics, so if we do crash we'll have those in the report
|
||||
val standardLogger = Logging.printlog
|
||||
Logging.printlog = { level, tag, message ->
|
||||
crashlytics.log("$tag: $message")
|
||||
standardLogger(level, tag, message)
|
||||
}
|
||||
|
||||
fun sendCrashReports() {
|
||||
if(isAnalyticsAllowed)
|
||||
crashlytics.sendUnsentReports()
|
||||
}
|
||||
|
||||
// Send any old reports if user approves
|
||||
sendCrashReports()
|
||||
|
||||
// Attach to our exception wrapper
|
||||
Exceptions.reporter = { exception, _, _ ->
|
||||
crashlytics.recordException(exception)
|
||||
crashlytics.sendUnsentReports()
|
||||
}
|
||||
|
||||
if (isAnalyticsAllowed) {
|
||||
val standardLogger = Logging.printlog
|
||||
|
||||
// send all log messages through crashyltics, so if we do crash we'll have those in the report
|
||||
Logging.printlog = { level, tag, message ->
|
||||
crashlytics.log("$tag: $message")
|
||||
standardLogger(level, tag, message)
|
||||
}
|
||||
sendCrashReports() // Send the new report
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import androidx.work.OneTimeWorkRequestBuilder
|
|||
import androidx.work.WorkManager
|
||||
import androidx.work.Worker
|
||||
import androidx.work.WorkerParameters
|
||||
import com.geeksville.andlib.BuildConfig
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
|
@ -65,6 +66,6 @@ fun MeshService.Companion.startService(context: Context) {
|
|||
// Before binding we want to explicitly create - so the service stays alive forever (so it can keep
|
||||
// listening for the bluetooth packets arriving from the radio. And when they arrive forward them
|
||||
// to Signal or whatever.
|
||||
info("Trying to start service")
|
||||
info("Trying to start service debug=${BuildConfig.DEBUG}")
|
||||
requireNotNull(context.startMeshService()) { "Failed to start service" }
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue