1
0
Fork 0

Closes #1083. Don't print sensitive data to logs in the production app. (#2437)

master
Denys M 2019-05-12 08:01:41 +03:00 committed by Jeff Boek
parent 4070941657
commit 24f15c8b77
2 changed files with 46 additions and 2 deletions

View File

@ -0,0 +1,44 @@
package org.mozilla.fenix.ext
import android.util.Log
import org.mozilla.fenix.BuildConfig
/**
* Will print to `Log.d()` only when [BuildConfig.DEBUG] is enabled.
*
* Meant to be used for logs that should not be visible in the production app.
*/
@Suppress("NOTHING_TO_INLINE")
inline fun logDebug(tag: String, message: String) {
if (BuildConfig.DEBUG) Log.d(tag, message)
}
/**
* Will print to `Log.w()` only when [BuildConfig.DEBUG] is enabled.
*
* Meant to be used for logs that should not be visible in the production app.
*/
@Suppress("NOTHING_TO_INLINE")
inline fun logWarn(tag: String, message: String) {
if (BuildConfig.DEBUG) Log.w(tag, message)
}
/**
* Will print to `Log.w()` only when [BuildConfig.DEBUG] is enabled.
*
* Meant to be used for logs that should not be visible in the production app.
*/
@Suppress("NOTHING_TO_INLINE")
inline fun logWarn(tag: String, message: String, err: Throwable) {
if (BuildConfig.DEBUG) Log.w(tag, message, err)
}
/**
* Will print to `Log.e()` only when [BuildConfig.DEBUG] is enabled.
*
* Meant to be used for logs that should not be visible in the production app.
*/
@Suppress("NOTHING_TO_INLINE")
inline fun logErr(tag: String, message: String, err: Throwable) {
if (BuildConfig.DEBUG) Log.e(tag, message, err)
}

View File

@ -4,7 +4,6 @@ package org.mozilla.fenix.search.awesomebar
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import android.util.Log
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModel
@ -12,6 +11,7 @@ import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelProviders
import io.reactivex.Observable
import mozilla.components.browser.search.SearchEngine
import org.mozilla.fenix.ext.logDebug
import org.mozilla.fenix.mvi.Action
import org.mozilla.fenix.mvi.ActionBusFactory
import org.mozilla.fenix.mvi.Change
@ -77,7 +77,7 @@ class AwesomeBarViewModel(initialState: AwesomeBarState, changesObservable: Obse
companion object {
val reducer: Reducer<AwesomeBarState, AwesomeBarChange> = { state, change ->
Log.d("IN_REDUCER", change.toString())
logDebug("IN_REDUCER", change.toString())
when (change) {
is AwesomeBarChange.SearchShortcutEngineSelected ->
state.copy(suggestionEngine = change.engine, showShortcutEnginePicker = false)