From cf2a7fcd0880a8d276970124cdb5d5845d5631fe Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 4 Jul 2017 16:08:03 -0700 Subject: Separate core components in its own module --- core/src/main/kotlin/ca/allanwang/kau/logging/KL.kt | 6 ++++++ .../kotlin/ca/allanwang/kau/logging/TimberLogger.kt | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 core/src/main/kotlin/ca/allanwang/kau/logging/KL.kt create mode 100644 core/src/main/kotlin/ca/allanwang/kau/logging/TimberLogger.kt (limited to 'core/src/main/kotlin/ca/allanwang/kau/logging') diff --git a/core/src/main/kotlin/ca/allanwang/kau/logging/KL.kt b/core/src/main/kotlin/ca/allanwang/kau/logging/KL.kt new file mode 100644 index 0000000..4fa3360 --- /dev/null +++ b/core/src/main/kotlin/ca/allanwang/kau/logging/KL.kt @@ -0,0 +1,6 @@ +package ca.allanwang.kau.logging + +/** + * Created by Allan Wang on 2017-06-19. + */ +object KL : TimberLogger("KAU") \ No newline at end of file diff --git a/core/src/main/kotlin/ca/allanwang/kau/logging/TimberLogger.kt b/core/src/main/kotlin/ca/allanwang/kau/logging/TimberLogger.kt new file mode 100644 index 0000000..5969fd5 --- /dev/null +++ b/core/src/main/kotlin/ca/allanwang/kau/logging/TimberLogger.kt @@ -0,0 +1,19 @@ +package ca.allanwang.kau.logging + +import timber.log.Timber + + +/** + * Created by Allan Wang on 2017-05-28. + * + * Timber extension that will embed the tag as part of the message for each log item + */ +open class TimberLogger(tag: String) { + internal val TAG = "$tag: %s" + fun e(s: String) = Timber.e(TAG, s) + fun e(t: Throwable, s: String = "error") = Timber.e(t, TAG, s) + fun d(s: String) = Timber.d(TAG, s) + fun i(s: String) = Timber.i(TAG, s) + fun v(s: String) = Timber.v(TAG, s) + fun eThrow(s: String) = e(Throwable(s)) +} \ No newline at end of file -- cgit v1.2.3