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 the CallWebView logs to our logging stack #3637

Merged
merged 2 commits into from
Oct 10, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
package io.element.android.features.call.impl.ui

import android.annotation.SuppressLint
import android.util.Log
import android.view.ViewGroup
import android.webkit.ConsoleMessage
import android.webkit.PermissionRequest
import android.webkit.WebChromeClient
import android.webkit.WebView
Expand Down Expand Up @@ -43,6 +45,7 @@
import io.element.android.libraries.designsystem.theme.components.Text
import io.element.android.libraries.designsystem.theme.components.TopAppBar
import io.element.android.libraries.ui.strings.CommonStrings
import timber.log.Timber

typealias RequestPermissionCallback = (Array<String>) -> Unit

Expand Down Expand Up @@ -189,6 +192,25 @@
override fun onPermissionRequest(request: PermissionRequest) {
onPermissionsRequested(request)
}

override fun onConsoleMessage(consoleMessage: ConsoleMessage): Boolean {
val priority = when (consoleMessage.messageLevel()) {
ConsoleMessage.MessageLevel.ERROR -> Log.ERROR
ConsoleMessage.MessageLevel.WARNING -> Log.WARN
else -> Log.DEBUG

Check warning on line 200 in features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenView.kt

View check run for this annotation

Codecov / codecov/patch

features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenView.kt#L198-L200

Added lines #L198 - L200 were not covered by tests
}
Timber.tag("WebView").log(
priority = priority,
message = buildString {
append(consoleMessage.sourceId())
append(":")
append(consoleMessage.lineNumber())
append(" ")
append(consoleMessage.message())
},

Check warning on line 210 in features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenView.kt

View check run for this annotation

Codecov / codecov/patch

features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenView.kt#L202-L210

Added lines #L202 - L210 were not covered by tests
)
return true

Check warning on line 212 in features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenView.kt

View check run for this annotation

Codecov / codecov/patch

features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenView.kt#L212

Added line #L212 was not covered by tests
}
}
}

Expand Down
Loading