From b2be377c5817f6417e2b4e1fe24ff9fdb5c7df93 Mon Sep 17 00:00:00 2001 From: Arie Trouw Date: Wed, 3 Feb 2021 11:26:42 -0800 Subject: [PATCH 1/2] More Cleanup --- .../kotlin/network/xyo/helpers/Helpers.kt | 7 +----- .../kotlin/network/xyo/logging/XYLogging.kt | 24 +++++++++---------- base-android-library/version.properties | 2 +- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/base-android-library/src/main/kotlin/network/xyo/helpers/Helpers.kt b/base-android-library/src/main/kotlin/network/xyo/helpers/Helpers.kt index c5269cf..54c83cc 100644 --- a/base-android-library/src/main/kotlin/network/xyo/helpers/Helpers.kt +++ b/base-android-library/src/main/kotlin/network/xyo/helpers/Helpers.kt @@ -2,7 +2,6 @@ package network.xyo.helpers import android.os.Debug import com.jaredrummler.android.device.DeviceName -import network.xyo.base.XYBase val currentThreadName : String get() = Thread.currentThread().name @@ -13,11 +12,7 @@ val deviceName: String val hasDebugger: Boolean get() = Debug.isDebuggerConnected() -fun sourceNameFromAny(source: Any): String { - return (source as? String) ?: classNameFromObject(source) -} - -fun classNameFromObject(objectToCheck: Any): String { +internal fun classNameFromObject(objectToCheck: Any): String { val parts = objectToCheck.javaClass.kotlin.simpleName?.split('.') ?: return "Unknown" return parts[parts.lastIndex] } \ No newline at end of file diff --git a/base-android-library/src/main/kotlin/network/xyo/logging/XYLogging.kt b/base-android-library/src/main/kotlin/network/xyo/logging/XYLogging.kt index 671e7c5..b7116df 100644 --- a/base-android-library/src/main/kotlin/network/xyo/logging/XYLogging.kt +++ b/base-android-library/src/main/kotlin/network/xyo/logging/XYLogging.kt @@ -1,20 +1,20 @@ package network.xyo.logging import android.util.Log -import network.xyo.base.XYBase import network.xyo.helpers.classNameFromObject import network.xyo.helpers.currentThreadName import network.xyo.helpers.hasDebugger -import network.xyo.helpers.sourceNameFromAny /* We have everyone of these functions returning 'this' to allow for chaining */ -open class XYLogging(private val source: XYBase) { +open class XYLogging(sourceAny: Any) { + private val source = classNameFromObject(sourceAny) + fun error(message: String, reThrow: Boolean): XYLogging { - Log.e(source.className, message) + Log.e(source, message) val stackTrace = Thread.currentThread().stackTrace if (!stackTrace.isNullOrEmpty()) { - Log.e(source.className, stackTrace.contentDeepToString().replace(", ", ",\r\n")) + Log.e(source, stackTrace.contentDeepToString().replace(", ", ",\r\n")) } if (reThrow) { throw RuntimeException() @@ -29,10 +29,10 @@ open class XYLogging(private val source: XYBase) { } fun error(ex: Throwable, reThrow: Boolean): XYLogging { - Log.e(source.className, classNameFromObject(ex)) + Log.e(source, classNameFromObject(ex)) val stackTrace = ex.stackTrace if (!stackTrace.isNullOrEmpty()) { - Log.e(source.className, stackTrace.contentDeepToString().replace(", ", ",\r\n")) + Log.e(source, stackTrace.contentDeepToString().replace(", ", ",\r\n")) } if (hasDebugger) { @@ -44,31 +44,31 @@ open class XYLogging(private val source: XYBase) { } fun error(message: String): XYLogging { - Log.e(sourceNameFromAny(source), "$message:${currentThreadName}") + Log.e(source, "$message:${currentThreadName}") return this } //Normal information used for debugging. Items should be less noisy than Extreme items fun info(function: String, message: String): XYLogging { - Log.i(sourceNameFromAny(source), "$source:$function:$message [${currentThreadName}]") + Log.i(source, "$source:$function:$message [${currentThreadName}]") return this } fun info(message: String): XYLogging { - Log.i(sourceNameFromAny(source), "$message [${currentThreadName}]") + Log.i(source, "$message [${currentThreadName}]") return this } //Actions are events that are generated by the user, like pushing a button fun action(action: String): XYLogging { - Log.i(sourceNameFromAny(source), action) + Log.i(source, action) return this } //Status are Large Scale Events, Such As Startup, or Shutdown, //that may or may not be a result of a user action fun status(status: String): XYLogging { - Log.i(sourceNameFromAny(source), "App Status: $status") + Log.i(source, "App Status: $status") return this } } \ No newline at end of file diff --git a/base-android-library/version.properties b/base-android-library/version.properties index 26e2f14..4a1f7a9 100644 --- a/base-android-library/version.properties +++ b/base-android-library/version.properties @@ -1,2 +1,2 @@ -#Wed Feb 03 17:55:52 UTC 2021 +#Wed Feb 03 11:20:45 PST 2021 VERSION_PATCH=10 From 13237e1f9379e8f7d253d0da9c819c865fdab6e1 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Wed, 3 Feb 2021 19:28:33 +0000 Subject: [PATCH 2/2] version bump --- base-android-library/version.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base-android-library/version.properties b/base-android-library/version.properties index 4a1f7a9..75a3ca2 100644 --- a/base-android-library/version.properties +++ b/base-android-library/version.properties @@ -1,2 +1,2 @@ -#Wed Feb 03 11:20:45 PST 2021 -VERSION_PATCH=10 +#Wed Feb 03 19:27:56 UTC 2021 +VERSION_PATCH=11