
Lightweight logging utility offering automatic console and logcat output, file logging with level filters, optional class/method/line traces, simple v/d/i/w/e API and raw writes.
KMP Logger for Desktop and Android apps.
v, d, i, w, e).Add the dependency to your commonMain source set in build.gradle.kts:
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.alexey-odintsov:logger:0.0.1")
}
}
}Add the dependency to your app's build.gradle.kts:
dependencies {
implementation("io.github.alexey-odintsov:logger-android:0.0.1")
}Before using the logger, you should initialize it. This is typically done in your Application.onCreate() on Android or at the start of your main() function for Desktop.
Log.init(
logFileName = "path/to/logs.txt", // Optional: file path to save logs
printToConsole = true, // Optional: whether to print to console/logcat (default: false)
printTraceElements = true, // Optional: whether to include class/method/line number (default: false)
fileLogLevel = Log.Level.DEBUG // Optional: minimum level to save to file (default: DEBUG)
)You can log messages with different levels:
Log.v("Verbose message")
Log.d("Debug message")
Log.i("Info message")
Log.w("Warning message")
Log.e("Error message")KMP Logger for Desktop and Android apps.
v, d, i, w, e).Add the dependency to your commonMain source set in build.gradle.kts:
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.alexey-odintsov:logger:0.0.1")
}
}
}Add the dependency to your app's build.gradle.kts:
dependencies {
implementation("io.github.alexey-odintsov:logger-android:0.0.1")
}Before using the logger, you should initialize it. This is typically done in your Application.onCreate() on Android or at the start of your main() function for Desktop.
Log.init(
logFileName = "path/to/logs.txt", // Optional: file path to save logs
printToConsole = true, // Optional: whether to print to console/logcat (default: false)
printTraceElements = true, // Optional: whether to include class/method/line number (default: false)
fileLogLevel = Log.Level.DEBUG // Optional: minimum level to save to file (default: DEBUG)
)You can log messages with different levels:
Log.v("Verbose message")
Log.d("Debug message")
Log.i("Info message")
Log.w("Warning message")
Log.e("Error message")