Auxio/app/src/main/java/org/oxycblt/auxio/LogUtils.kt
OxygenCobalt 6fa698d7eb
Prevent search box from scrolling the toolbar
Prevent the search TextView from being able to scroll the toolbar when there are no results.
2021-02-15 15:07:39 -07:00

35 lines
905 B
Kotlin

package org.oxycblt.auxio
import android.util.Log
// Shortcut functions for logging.
// Yes, I know timber exists but this does what I need.
/**
* Shortcut method for logging a non-string [obj] to debug. Should only be used for debug preferably.
*/
fun Any.logD(obj: Any) {
logD(obj.toString())
}
/**
* Shortcut method for logging [msg] to the debug console., handles debug builds and anonymous objects
*/
fun Any.logD(msg: String) {
if (BuildConfig.DEBUG) {
Log.d(getName(), msg)
}
}
/**
* Shortcut method for logging [msg] as an error to the console. Handles anonymous objects
*/
fun Any.logE(msg: String) {
Log.e(getName(), msg)
}
/**
* Get a non-nullable name, used so that logs will always show up in the console.
* @return The name of the object, otherwise "Anonymous Object"
*/
private fun Any.getName(): String = this::class.simpleName ?: "Anonymous Object"