diff --git a/app/src/main/kotlin/io/treehouses/remote/utils/LogUtils.kt b/app/src/main/kotlin/io/treehouses/remote/utils/LogUtils.kt index 18a8cd0ea..6b3c0252b 100644 --- a/app/src/main/kotlin/io/treehouses/remote/utils/LogUtils.kt +++ b/app/src/main/kotlin/io/treehouses/remote/utils/LogUtils.kt @@ -6,21 +6,19 @@ import io.treehouses.remote.BuildConfig object LogUtils { fun mOffline() { - if (BuildConfig.DEBUG) Log.e("STATUS", "OFFLINE") + logE("STATUS", "OFFLINE") } fun mIdle() { - if (BuildConfig.DEBUG) Log.e("STATUS", "IDLE") + logE("STATUS", "IDLE") } fun mConnect() { - if (BuildConfig.DEBUG) Log.e("STATUS", "CONNECTED") + logE("STATUS", "CONNECTED") } fun log(message: String?) { - if (BuildConfig.DEBUG) { - Log.d("TREEHOUSES ", message!!) - } + logD("TREEHOUSES", message!!) } fun writeMsg(msg: Message) { @@ -39,9 +37,14 @@ fun Any.logE(msg: String, e: Throwable? = null) { private fun logD(tag: String, msg: String) { - if (BuildConfig.DEBUG) Log.d(tag, msg) + log("d", tag, msg) } private fun logE(tag: String, msg: String) { - if (BuildConfig.DEBUG) Log.e(tag, msg) + log("e", tag, msg) +} + +private fun log(type: String, tag: String, msg: String) { + if (BuildConfig.DEBUG) + Log::class.java.getMethod(type, String::class.java, String::class.java).invoke(null, tag, msg) } \ No newline at end of file