Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
Add LoggingConfig option to enable/disable logs.
Browse files Browse the repository at this point in the history
Add logs for unknown tag found while parsing.
  • Loading branch information
jmartinesp committed Jul 17, 2024
1 parent 19aa262 commit 219dc93
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.element.android.wysiwyg

import android.text.Editable
import android.text.TextWatcher
import io.element.android.wysiwyg.utils.LoggingConfig
import timber.log.Timber
import java.util.concurrent.atomic.AtomicBoolean

Expand All @@ -14,8 +15,6 @@ internal class EditorTextWatcher: TextWatcher {

val isInEditorChange get() = updateIsFromEditor.get()

var enableDebugLogs = false

private var beforeText: CharSequence? = null

/**
Expand Down Expand Up @@ -53,7 +52,7 @@ internal class EditorTextWatcher: TextWatcher {
}

override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
if (enableDebugLogs) {
if (LoggingConfig.enableDebugLogs) {
Timber.v("beforeTextChanged | text: \"$s\", start: $start, count: $count, after: $after")
}
if (!updateIsFromEditor.get()) {
Expand All @@ -62,7 +61,7 @@ internal class EditorTextWatcher: TextWatcher {
}

override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
if (enableDebugLogs) {
if (LoggingConfig.enableDebugLogs) {
Timber.v("onTextChanged | text: \"$s\", start: $start, before: $before, count: $count")
}
if (!updateIsFromEditor.get()) {
Expand All @@ -72,7 +71,7 @@ internal class EditorTextWatcher: TextWatcher {
}

override fun afterTextChanged(s: Editable?) {
if (enableDebugLogs) {
if (LoggingConfig.enableDebugLogs) {
Timber.v("afterTextChanged")
}
if (!updateIsFromEditor.get()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import io.element.android.wysiwyg.view.spans.UnorderedListSpan
import org.jsoup.Jsoup
import org.jsoup.nodes.Element
import org.jsoup.nodes.TextNode
import timber.log.Timber
import kotlin.math.roundToInt

/**
Expand Down Expand Up @@ -80,6 +81,9 @@ internal class HtmlToSpansParser(
"blockquote" -> parseQuote(element)
"p" -> parseParagraph(element)
"br" -> parseLineBreak(element)
else -> if (LoggingConfig.enableDebugLogs) {
Timber.d("Unsupported tag: ${element.tagName()}")
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.element.android.wysiwyg.utils

import io.element.android.wysiwyg.BuildConfig

object LoggingConfig {
var enableDebugLogs = BuildConfig.DEBUG
}

0 comments on commit 219dc93

Please sign in to comment.