
Lightweight, extensible logging with automatic tag detection, smart test-mode colored output, trainer-based destinations (file, crash reporting, console), per-trainer volume and runtime control.
barK: A simple, extensible logging library for Kotlin Multiplatform with automatic tag detection and support for test runs
- NOTICE: barK has officially moved into Maven Central!
+ Starting with v0.1.0, barK has migrated out of Jitpack, and is now hosted in Maven Central.
+ If you're using a version of barK v0.0.x, feel free to drop the Jitpack repository if you're not using it elsewhere.barK solves common logging pain points with a memorable, themed API and powerful automation:
Born from real SDK development needs - when you need different logging behavior for Android runs vs. test runs, barK has you covered.
Medium:
Add barK to your Kotlin Multiplatform project via Maven Central:
Kotlin DSL:
// build.gradle.kts
repositories {
mavenCentral()
}
kotlin {
sourceSets {
commonMain.dependencies {
implementation("com.ivangarzab:bark:<version>")
}
}
}Groovy:
// build.gradle
repositories {
mavenCentral()
}
kotlin {
sourceSets {
commonMain {
dependencies {
implementation 'com.ivangarzab:bark:<version>'
}
}
}
}class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// Train barK with Android logging
if (BuildConfig.DEBUG) {
Bark.train(AndroidLogTrainer())
}
// Optionally add test trainer (auto-activates during tests)
Bark.train(ColoredUnitTestTrainer())
}
}class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Automatic tag detection - shows [MainActivity] in logs
Bark.d("App started successfully")
Bark.i("User logged in: ${user.name}")
Bark.e("Network error", exception)
}
}That's it! barK automatically:
import shared // Your KMP shared module nameFor a cleaner Swift API, copy ios/BarkExtensions.swift into your iOS app target. This transforms:
Bark.shared.d(message: "Hello") // Without extensions
Bark.d("Hello") // With extensions β¨@main
struct MyApp: App {
init() {
// Enable auto-tag detection (optional, has performance cost)
BarkConfig.shared.autoTagDisabled = false
// Train barK with iOS logging
#if DEBUG
Bark.train(trainer: NSLogTrainer())
Bark.train(trainer: ColoredUnitTestTrainer())
#else
Bark.train(trainer: NSLogTrainer(volume: .warning))
#endif
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}class UserRepository {
func saveUser(user: User) {
// Automatic tag detection - shows [UserRepository] in logs
Bark.d("Saving user: \(user.name)")
Bark.i("User saved successfully")
}
}That's it! barK automatically:
iOS-Specific Notes:
BarkConfig.shared.autoTagDisabled = false
No more manual TAG constants! barK automatically detects the calling class:
class UserRepository {
fun saveUser(user: User) {
Bark.i("Saving user: ${user.name}") // Tag: [UserRepository]
}
}
class MainActivity : AppCompatActivity() {
fun onCreate() {
Bark.d("Activity created") // Tag: [MainActivity]
}
}Different output for different environments:
// In your app: Shows in system logs (Logcat/NSLog)
Bark.d("User action performed")
// In unit tests: Shows colored in console
@Test
fun testUserAction() {
Bark.d("Testing user action") // Colored console output!
}Works on both Android and iOS with automatic detection of JUnit, XCTest, and other testing frameworks.
Easy to extend and customize:
// Basic setup
Bark.train(AndroidLogTrainer())
// Multiple outputs
Bark.train(AndroidLogTrainer()) // System Logcat
Bark.train(ColoredUnitTestTrainer()) // Colored console output
Bark.train(FileTrainer("app.log")) // File logging
Bark.train(CrashReportingTrainer()) // Custom trainers
// Custom volume control per trainer
Bark.train(AndroidLogTrainer(volume = Level.DEBUG)) // All levels
Bark.train(FileTrainer(volume = Level.ERROR)) // Errors onlyPlatform Parity:
AndroidLogTrainer, AndroidTestLogTrainer, UnitTestTrainer, ColoredUnitTestTrainer
NSLogTrainer, UnitTestTrainer, ColoredUnitTestTrainer
Check out the included sample apps to see barK in action:
Android:
./gradlew :sample-android:installDebugiOS:
Open sample-ios/barK-sample/barK-sample.xcodeproj in Xcode and run.
Both samples demonstrate:
barK is built for Kotlin Multiplatform from the ground up with full platform parity:
// β
Kotlin Multiplatform - Shared API
// β
Android - Logcat, test detection, colored console
// β
iOS - NSLog, XCTest detection, colored console (Terminal/CI)Common API, platform-specific implementations:
| Feature | barK | Android Log |
|---|---|---|
| Manual TAG constants | β | β |
| Test environment handling | β | β |
| Multiple outputs | β | β |
| Runtime control | β | β |
| Kotlin Multiplatform | β | β |
| Feature | barK | Timber |
|---|---|---|
| Auto-tag detection | β | β |
| Test environment detection | β | β |
| Kotlin Multiplatform | β | β |
| Multiple trainers | β | β |
| Runtime muzzling | β | β |
We welcome contributions! Please see our Contributing Guide for details.
Copyright 2025 Ivan Garza
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Made with π€ for the Kotlin community
barK: Because every log deserves a good home ππ
barK: A simple, extensible logging library for Kotlin Multiplatform with automatic tag detection and support for test runs
- NOTICE: barK has officially moved into Maven Central!
+ Starting with v0.1.0, barK has migrated out of Jitpack, and is now hosted in Maven Central.
+ If you're using a version of barK v0.0.x, feel free to drop the Jitpack repository if you're not using it elsewhere.barK solves common logging pain points with a memorable, themed API and powerful automation:
Born from real SDK development needs - when you need different logging behavior for Android runs vs. test runs, barK has you covered.
Medium:
Add barK to your Kotlin Multiplatform project via Maven Central:
Kotlin DSL:
// build.gradle.kts
repositories {
mavenCentral()
}
kotlin {
sourceSets {
commonMain.dependencies {
implementation("com.ivangarzab:bark:<version>")
}
}
}Groovy:
// build.gradle
repositories {
mavenCentral()
}
kotlin {
sourceSets {
commonMain {
dependencies {
implementation 'com.ivangarzab:bark:<version>'
}
}
}
}class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// Train barK with Android logging
if (BuildConfig.DEBUG) {
Bark.train(AndroidLogTrainer())
}
// Optionally add test trainer (auto-activates during tests)
Bark.train(ColoredUnitTestTrainer())
}
}class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Automatic tag detection - shows [MainActivity] in logs
Bark.d("App started successfully")
Bark.i("User logged in: ${user.name}")
Bark.e("Network error", exception)
}
}That's it! barK automatically:
import shared // Your KMP shared module nameFor a cleaner Swift API, copy ios/BarkExtensions.swift into your iOS app target. This transforms:
Bark.shared.d(message: "Hello") // Without extensions
Bark.d("Hello") // With extensions β¨@main
struct MyApp: App {
init() {
// Enable auto-tag detection (optional, has performance cost)
BarkConfig.shared.autoTagDisabled = false
// Train barK with iOS logging
#if DEBUG
Bark.train(trainer: NSLogTrainer())
Bark.train(trainer: ColoredUnitTestTrainer())
#else
Bark.train(trainer: NSLogTrainer(volume: .warning))
#endif
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}class UserRepository {
func saveUser(user: User) {
// Automatic tag detection - shows [UserRepository] in logs
Bark.d("Saving user: \(user.name)")
Bark.i("User saved successfully")
}
}That's it! barK automatically:
iOS-Specific Notes:
BarkConfig.shared.autoTagDisabled = false
No more manual TAG constants! barK automatically detects the calling class:
class UserRepository {
fun saveUser(user: User) {
Bark.i("Saving user: ${user.name}") // Tag: [UserRepository]
}
}
class MainActivity : AppCompatActivity() {
fun onCreate() {
Bark.d("Activity created") // Tag: [MainActivity]
}
}Different output for different environments:
// In your app: Shows in system logs (Logcat/NSLog)
Bark.d("User action performed")
// In unit tests: Shows colored in console
@Test
fun testUserAction() {
Bark.d("Testing user action") // Colored console output!
}Works on both Android and iOS with automatic detection of JUnit, XCTest, and other testing frameworks.
Easy to extend and customize:
// Basic setup
Bark.train(AndroidLogTrainer())
// Multiple outputs
Bark.train(AndroidLogTrainer()) // System Logcat
Bark.train(ColoredUnitTestTrainer()) // Colored console output
Bark.train(FileTrainer("app.log")) // File logging
Bark.train(CrashReportingTrainer()) // Custom trainers
// Custom volume control per trainer
Bark.train(AndroidLogTrainer(volume = Level.DEBUG)) // All levels
Bark.train(FileTrainer(volume = Level.ERROR)) // Errors onlyPlatform Parity:
AndroidLogTrainer, AndroidTestLogTrainer, UnitTestTrainer, ColoredUnitTestTrainer
NSLogTrainer, UnitTestTrainer, ColoredUnitTestTrainer
Check out the included sample apps to see barK in action:
Android:
./gradlew :sample-android:installDebugiOS:
Open sample-ios/barK-sample/barK-sample.xcodeproj in Xcode and run.
Both samples demonstrate:
barK is built for Kotlin Multiplatform from the ground up with full platform parity:
// β
Kotlin Multiplatform - Shared API
// β
Android - Logcat, test detection, colored console
// β
iOS - NSLog, XCTest detection, colored console (Terminal/CI)Common API, platform-specific implementations:
| Feature | barK | Android Log |
|---|---|---|
| Manual TAG constants | β | β |
| Test environment handling | β | β |
| Multiple outputs | β | β |
| Runtime control | β | β |
| Kotlin Multiplatform | β | β |
| Feature | barK | Timber |
|---|---|---|
| Auto-tag detection | β | β |
| Test environment detection | β | β |
| Kotlin Multiplatform | β | β |
| Multiple trainers | β | β |
| Runtime muzzling | β | β |
We welcome contributions! Please see our Contributing Guide for details.
Copyright 2025 Ivan Garza
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Made with π€ for the Kotlin community
barK: Because every log deserves a good home ππ