
Cross-platform logging library mimics Android's Log API, supports live log broadcasting, configurable log levels, and real-time monitoring via a client application using mDNS and WebSocket.
KMP RealTime Logger is a Kotlin Multiplatform logging library that replicates the functionality of Android's Log library for use in common code across all platforms (Native, JVM, JS, WASM, and Android).
Log.e() for detailed error logging including stack traces πAdd the following dependency to your build.gradle.kts file:
implementation("io.github.kdroidfilter:kmplog:0.6.2")KMPLog is available on Maven Central, ensuring easy integration into your projects.
import com.kdroid.kmplog.Log
Log.d("MyTag", "This is a debug message")
Log.i("MyTag", "This is an info message")
Log.e("MyTag", "This is an error message")
Log.e("MyTag", "This is an error message with exception", throwable)Log.setLogLevel(Log.INFO)Log.setDevelopmentMode(true)Logs will only be displayed when development mode is enabled, providing better control over logging during production and development phases.
To enable broadcasting mode, use the following function:
Log.enableBroadcastingMode(ip: String? = null, port: Int = DEFAULT_SERVICE_PORT)ip: Optional. Specify the IP address of the client device to receive the logs. If not provided, the library will automatically discover and connect to the client device using mDNS (Multicast DNS) services.port: Optional. Specify the port to use for broadcasting. By default, it uses the DEFAULT_SERVICE_PORT.Example:
Log.enableBroadcastingMode("192.168.1.10", 8080)This will broadcast logs to the device with IP 192.168.1.10 on port 8080.
if (Log.isLoggable("MyTag", Log.DEBUG)) {
// Perform debug logging
}To facilitate real-time log monitoring, we have also developed a client application that listens to the logs broadcasted over the local network.
The client application uses mDNS to discover broadcasting devices automatically and display the logs in real-time. Note that automatic detection using mDNS only works from an Android or JVM application.
Below are some screenshots demonstrating the functionality of the client application:
The client application is available for installation on Android, Windows and Linux. Please download it on the release section.
The client application works by creating a WebSocket server on the local network using Ktor. This server listens for incoming connections from devices broadcasting logs. The server is also published as an mDNS (Multicast DNS) service, making it discoverable by other devices on the same local network without requiring manual configuration.
The KMPLog library itself connects to this WebSocket server using Ktor's WebSocket client capabilities. By leveraging Ktor's lightweight and asynchronous nature, the setup remains efficient and allows real-time log streaming with minimal latency. This architecture enables developers to easily monitor application logs during development or debugging sessions across different platforms.
Log.v(tag: String, msg: String): Log a VERBOSE message π£οΈLog.d(tag: String, msg: String): Log a DEBUG message πLog.i(tag: String, msg: String): Log an INFO message βΉοΈLog.w(tag: String, msg: String): Log a WARN message Log.e(tag: String, msg: String, throwable: Throwable?): Log an ERROR message, optionally with a throwable for detailed error logging βLog.wtf(tag: String, msg: String): Log a WTF (What a Terrible Failure) message π±Log.println(priority: Int, tag: String, msg: String): Log a message with custom priority πLog.setDevelopmentMode(isDevelopment: Boolean): Enable or disable development mode πΌοΈLog.setLogLevel(level: Int): Set the log level π§Log.enableBroadcastingMode(ip: String? = null, port: Int = DEFAULT_SERVICE_PORT): Enable broadcasting mode to stream logs to another device on the local network π‘οΈContributions are welcome! Please feel free to submit a Pull Request. π‘
The desktop version of the client application uses the Jewel theme, which requires the JetBrains JDK to build the application. Please ensure that you have the JetBrains JDK installed and properly configured when building the desktop client.
KMPLog is released under the MIT License. See the LICENSE file for details.
KMP RealTime Logger is a Kotlin Multiplatform logging library that replicates the functionality of Android's Log library for use in common code across all platforms (Native, JVM, JS, WASM, and Android).
Log.e() for detailed error logging including stack traces πAdd the following dependency to your build.gradle.kts file:
implementation("io.github.kdroidfilter:kmplog:0.6.2")KMPLog is available on Maven Central, ensuring easy integration into your projects.
import com.kdroid.kmplog.Log
Log.d("MyTag", "This is a debug message")
Log.i("MyTag", "This is an info message")
Log.e("MyTag", "This is an error message")
Log.e("MyTag", "This is an error message with exception", throwable)Log.setLogLevel(Log.INFO)Log.setDevelopmentMode(true)Logs will only be displayed when development mode is enabled, providing better control over logging during production and development phases.
To enable broadcasting mode, use the following function:
Log.enableBroadcastingMode(ip: String? = null, port: Int = DEFAULT_SERVICE_PORT)ip: Optional. Specify the IP address of the client device to receive the logs. If not provided, the library will automatically discover and connect to the client device using mDNS (Multicast DNS) services.port: Optional. Specify the port to use for broadcasting. By default, it uses the DEFAULT_SERVICE_PORT.Example:
Log.enableBroadcastingMode("192.168.1.10", 8080)This will broadcast logs to the device with IP 192.168.1.10 on port 8080.
if (Log.isLoggable("MyTag", Log.DEBUG)) {
// Perform debug logging
}To facilitate real-time log monitoring, we have also developed a client application that listens to the logs broadcasted over the local network.
The client application uses mDNS to discover broadcasting devices automatically and display the logs in real-time. Note that automatic detection using mDNS only works from an Android or JVM application.
Below are some screenshots demonstrating the functionality of the client application:
The client application is available for installation on Android, Windows and Linux. Please download it on the release section.
The client application works by creating a WebSocket server on the local network using Ktor. This server listens for incoming connections from devices broadcasting logs. The server is also published as an mDNS (Multicast DNS) service, making it discoverable by other devices on the same local network without requiring manual configuration.
The KMPLog library itself connects to this WebSocket server using Ktor's WebSocket client capabilities. By leveraging Ktor's lightweight and asynchronous nature, the setup remains efficient and allows real-time log streaming with minimal latency. This architecture enables developers to easily monitor application logs during development or debugging sessions across different platforms.
Log.v(tag: String, msg: String): Log a VERBOSE message π£οΈLog.d(tag: String, msg: String): Log a DEBUG message πLog.i(tag: String, msg: String): Log an INFO message βΉοΈLog.w(tag: String, msg: String): Log a WARN message Log.e(tag: String, msg: String, throwable: Throwable?): Log an ERROR message, optionally with a throwable for detailed error logging βLog.wtf(tag: String, msg: String): Log a WTF (What a Terrible Failure) message π±Log.println(priority: Int, tag: String, msg: String): Log a message with custom priority πLog.setDevelopmentMode(isDevelopment: Boolean): Enable or disable development mode πΌοΈLog.setLogLevel(level: Int): Set the log level π§Log.enableBroadcastingMode(ip: String? = null, port: Int = DEFAULT_SERVICE_PORT): Enable broadcasting mode to stream logs to another device on the local network π‘οΈContributions are welcome! Please feel free to submit a Pull Request. π‘
The desktop version of the client application uses the Jewel theme, which requires the JetBrains JDK to build the application. Please ensure that you have the JetBrains JDK installed and properly configured when building the desktop client.
KMPLog is released under the MIT License. See the LICENSE file for details.