
A lightweight, production-ready logging library for Kotlin Multiplatform.
Glint Logger provides a distinct, highly readable visual output style by wrapping your logs in beautifully formatted text blocks. It seamlessly routes logs to the native logging systems of each platform while maintaining a consistent and clean aesthetic.
Success level (in addition to standard V, D, I, W, E) to clearly highlight successful operations.android.util.Log (Logcat).NSLog.LogWriter implementations to send logs to external services (like Crashlytics, Sentry, or a file).| Platform | Support |
|---|---|
| Android | ✅ |
| iOS | ✅ |
| JVM / Desktop | ✅ |
| Linux (x64) | ✅ |
Add the dependency to your commonMain source set in build.gradle.kts:
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.ahmed-madhoun1:glint:1.0.1")
}
}
}Note: Ensure you have
mavenCentral()in your repositories block.
Import the Logger and start using it anywhere in your common Kotlin code!
import io.github.ahmedmadhoun.glint.Logger
import io.github.ahmedmadhoun.glint.Severity
// Optional: Set minimum severity level (Default is Verbose)
Logger.minSeverity = Severity.Verbose
// Simple logging
Logger.v("Auth", "App is starting up")
Logger.d("Auth", "Initializing system")
Logger.i("Auth", "Loading user data")
Logger.w("Auth", "Network connection is slow")
Logger.e("Auth", "Failed to load profile", Exception("Timeout"))
// Use the unique 'Success' level!
Logger.s("Auth", "User signed in successfully!")Create a TaggedLogger to simplify logging within a class:
val authLogger = Logger.withTag("AuthViewModel")
authLogger.d("Fetching tokens...")
authLogger.s("Tokens refreshed successfully!")Want to send logs to a server or a file? Implement LogWriter and add it to the Logger:
import io.github.ahmedmadhoun.glint.LogWriter
import io.github.ahmedmadhoun.glint.Severity
class MyCustomWriter : LogWriter {
override fun log(severity: Severity, tag: String, message: String, throwable: Throwable?) {
// Send to your analytics or file system
if (severity == Severity.Error) {
// e.g., Crashlytics.logException(throwable)
}
}
}
Logger.addWriter(MyCustomWriter())Tip: By default, Glint Logger includes the platform-specific log writer (e.g., Logcat for Android, NSLog for iOS). If you want to disable the default writer and only use your custom writers, you can clear the existing writers first:
// Remove the default platform log writer
Logger.clearWriters()
// Add your custom writers
Logger.addWriter(MyCustomWriter())| Level | Method | Label | Use Case |
|---|---|---|---|
| Verbose | Logger.v() |
[VERBOSE] |
Fine-grained tracing information. |
| Debug | Logger.d() |
[DEBUG] |
Useful information for developers. |
| Info | Logger.i() |
[INFO] |
General application flow events. |
| Success | Logger.s() |
[SUCCESS] |
Positive outcomes (API success, DB saved). |
| Warning | Logger.w() |
[WARNING] |
Unexpected behavior that isn't an error. |
| Error | Logger.e() |
[ERROR] |
Critical issues and exceptions. |
Here is how your logs will look in the console.
------------------------------------------------------------
| [DEBUG] * Tag: Auth
| Initializing system
------------------------------------------------------------
------------------------------------------------------------
| [SUCCESS] * Tag: Auth
| User signed in successfully!
------------------------------------------------------------
------------------------------------------------------------
| [ERROR] * Tag: Auth
| Failed to load profile
|
| java.lang.Exception: Timeout exception
| at com.example.app.AuthViewModel.loadProfile(AuthViewModel.kt:42)
------------------------------------------------------------
Contributions are welcome! Feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.
If you find this library useful, please give it a ⭐ on GitHub! It helps more developers discover the project.
A lightweight, production-ready logging library for Kotlin Multiplatform.
Glint Logger provides a distinct, highly readable visual output style by wrapping your logs in beautifully formatted text blocks. It seamlessly routes logs to the native logging systems of each platform while maintaining a consistent and clean aesthetic.
Success level (in addition to standard V, D, I, W, E) to clearly highlight successful operations.android.util.Log (Logcat).NSLog.LogWriter implementations to send logs to external services (like Crashlytics, Sentry, or a file).| Platform | Support |
|---|---|
| Android | ✅ |
| iOS | ✅ |
| JVM / Desktop | ✅ |
| Linux (x64) | ✅ |
Add the dependency to your commonMain source set in build.gradle.kts:
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.ahmed-madhoun1:glint:1.0.1")
}
}
}Note: Ensure you have
mavenCentral()in your repositories block.
Import the Logger and start using it anywhere in your common Kotlin code!
import io.github.ahmedmadhoun.glint.Logger
import io.github.ahmedmadhoun.glint.Severity
// Optional: Set minimum severity level (Default is Verbose)
Logger.minSeverity = Severity.Verbose
// Simple logging
Logger.v("Auth", "App is starting up")
Logger.d("Auth", "Initializing system")
Logger.i("Auth", "Loading user data")
Logger.w("Auth", "Network connection is slow")
Logger.e("Auth", "Failed to load profile", Exception("Timeout"))
// Use the unique 'Success' level!
Logger.s("Auth", "User signed in successfully!")Create a TaggedLogger to simplify logging within a class:
val authLogger = Logger.withTag("AuthViewModel")
authLogger.d("Fetching tokens...")
authLogger.s("Tokens refreshed successfully!")Want to send logs to a server or a file? Implement LogWriter and add it to the Logger:
import io.github.ahmedmadhoun.glint.LogWriter
import io.github.ahmedmadhoun.glint.Severity
class MyCustomWriter : LogWriter {
override fun log(severity: Severity, tag: String, message: String, throwable: Throwable?) {
// Send to your analytics or file system
if (severity == Severity.Error) {
// e.g., Crashlytics.logException(throwable)
}
}
}
Logger.addWriter(MyCustomWriter())Tip: By default, Glint Logger includes the platform-specific log writer (e.g., Logcat for Android, NSLog for iOS). If you want to disable the default writer and only use your custom writers, you can clear the existing writers first:
// Remove the default platform log writer
Logger.clearWriters()
// Add your custom writers
Logger.addWriter(MyCustomWriter())| Level | Method | Label | Use Case |
|---|---|---|---|
| Verbose | Logger.v() |
[VERBOSE] |
Fine-grained tracing information. |
| Debug | Logger.d() |
[DEBUG] |
Useful information for developers. |
| Info | Logger.i() |
[INFO] |
General application flow events. |
| Success | Logger.s() |
[SUCCESS] |
Positive outcomes (API success, DB saved). |
| Warning | Logger.w() |
[WARNING] |
Unexpected behavior that isn't an error. |
| Error | Logger.e() |
[ERROR] |
Critical issues and exceptions. |
Here is how your logs will look in the console.
------------------------------------------------------------
| [DEBUG] * Tag: Auth
| Initializing system
------------------------------------------------------------
------------------------------------------------------------
| [SUCCESS] * Tag: Auth
| User signed in successfully!
------------------------------------------------------------
------------------------------------------------------------
| [ERROR] * Tag: Auth
| Failed to load profile
|
| java.lang.Exception: Timeout exception
| at com.example.app.AuthViewModel.loadProfile(AuthViewModel.kt:42)
------------------------------------------------------------
Contributions are welcome! Feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.
If you find this library useful, please give it a ⭐ on GitHub! It helps more developers discover the project.