Auxio/app/src/main/java/org/oxycblt/auxio/LogUtils.kt
OxygenCobalt 7458588913 Move playback save button to SettingsListFragment
Move the ability to save the current playback state into a dedicated preference in SettingsListFragment.
2020-12-13 16:01:40 -07:00

30 lines
769 B
Kotlin

package org.oxycblt.auxio
import android.util.Log
// Shortcut functions for logging.
// Yes, I know timber exists but it does too much.
/**
* Shortcut method for logging a debug statement, handles debug builds and anonymous objects
* @param msg The message to log
*/
fun Any.logD(msg: String) {
if (BuildConfig.DEBUG) {
Log.d(getName(), msg)
}
}
/**
* Shortcut method for logging an error. Handles anonymous objects
* @param msg The message to log
*/
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"