Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LogBuffer output to device logs screen #974

Merged
merged 2 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
([#960](https://github.com/Automattic/pocket-casts-android/pull/960)).
* Fixed crash on grouping by season
([#962](https://github.com/Automattic/pocket-casts-android/pull/962)).
* Fixed bug that prevented full logs from being displayed within the app
([#974](https://github.com/Automattic/pocket-casts-android/pull/974)).
* Updates
* Link users to support forum from within the app
([#950](https://github.com/Automattic/pocket-casts-android/pull/950)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import android.content.Context
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import au.com.shiftyjelly.pocketcasts.repositories.support.Support
import au.com.shiftyjelly.pocketcasts.utils.log.LogBuffer
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import java.io.ByteArrayOutputStream
import javax.inject.Inject
import au.com.shiftyjelly.pocketcasts.localization.R as LR

Expand All @@ -27,7 +29,12 @@ class LogsViewModel @Inject constructor(

init {
viewModelScope.launch(Dispatchers.IO) {
val logs = support.getUserDebug(false)
val logs = buildString {
append(support.getUserDebug(false))
val outputStream = ByteArrayOutputStream()
LogBuffer.output(outputStream)
append(outputStream.toString())
}
_state.update { it.copy(logs = logs) }
}
}
Expand Down