Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ obj

# Gradle
.gradle
.kotlin
jniLibs
build
local.properties
reports
/gradle/gradle-daemon-jvm.properties
19 changes: 16 additions & 3 deletions timber/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ apply plugin: 'org.jetbrains.dokka' // Must be applied here for publish plugin.
apply plugin: 'com.gradleup.tapmoc'

kotlin {
applyDefaultHierarchyTemplate()
androidLibrary {
namespace = 'timber.log'
compileSdk = libs.versions.compileSdk.get().toInteger()
minSdk = libs.versions.minSdk.get().toInteger()

withHostTest {}
withJava()

optimization {
// "it" --> https://issuetracker.google.com/issues/445115242
it.consumerKeepRules.file('consumer-keep-rules.pro')
Expand All @@ -22,17 +26,26 @@ kotlin {
}
}

jvm()

sourceSets {
commonMain {
dependencies {
implementation libs.annotations
}
}
jvmAndroidMain { dependsOn(commonMain) }
androidMain { dependsOn(jvmAndroidMain) }
jvmMain { dependsOn(jvmAndroidMain) }
commonTest {
dependencies {
implementation libs.annotations
implementation libs.junit
implementation libs.assertk
}
}
androidHostTest {
dependencies {
implementation libs.junit
implementation libs.robolectric
}
}
Expand All @@ -51,8 +64,8 @@ tapmoc {

tasks.named('check') { check ->
check.dependsOn(
// TODO: https://youtrack.jetbrains.com/issue/KT-78525
tasks.named('checkLegacyAbi'),
// TODO: https://youtrack.jetbrains.com/issue/KT-78525
tasks.named('checkLegacyAbi'),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TimberTest {

Timber.d("Test")

assertLog().hasDebugMessage("TimberTest:48", "Test").hasNoMoreMessages()
assertLog().hasDebugMessage("TimberTest:52", "Test").hasNoMoreMessages()
}

@Test
Expand Down
25 changes: 25 additions & 0 deletions timber/src/androidMain/kotlin/timber/log/Platform.android.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package timber.log

import android.os.Build
import android.util.Log

internal actual fun writeLog(priority: Int, tag: String?, message: String) {
when (priority) {
Priority.ASSERT -> Log.wtf(tag, message)
else -> Log.println(priority, tag, message)
}
}

internal actual fun maxLogLength(): Int = MAX_LOG_LENGTH

internal actual fun maxTagLength(): Int {
// Tag length limit was removed in API 26.
return if (Build.VERSION.SDK_INT >= 26) {
Int.MAX_VALUE
} else {
MAX_TAG_LENGTH
}
}

private const val MAX_LOG_LENGTH = 4000
private const val MAX_TAG_LENGTH = 23
Loading