iosMain.Logger.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of logger Show documentation
Show all versions of logger Show documentation
Simple multiplatform logger
The newest version!
package opensavvy.logger
import kotlinx.cinterop.ptr
import platform.darwin.*
class IosLogger(self: Any): Logger {
override var level = LogLevel.default
private val tag = self::class.simpleName
override fun forceTrace(message: String, vararg objects: Any?) {
val string = "$tag: $message ${objects.joinToString(" ")}"
_os_log_internal(__dso_handle.ptr, OS_LOG_DEFAULT, OS_LOG_TYPE_DEFAULT, "%s", string)
}
override fun forceDebug(message: String, vararg objects: Any?) {
val string = "$tag: $message ${objects.joinToString(" ")}"
_os_log_internal(__dso_handle.ptr, OS_LOG_DEFAULT, OS_LOG_TYPE_DEBUG, "%s", string)
}
override fun forceInfo(message: String, vararg objects: Any?) {
val string = "$tag: $message ${objects.joinToString(" ")}"
_os_log_internal(__dso_handle.ptr, OS_LOG_DEFAULT, OS_LOG_TYPE_INFO, "%s", string)
}
override fun forceWarn(message: String, vararg objects: Any?) {
val string = "$tag: $message ${objects.joinToString(" ")}"
_os_log_internal(__dso_handle.ptr, OS_LOG_DEFAULT, OS_LOG_TYPE_DEFAULT, "%s", string)
}
override fun forceError(message: String, vararg objects: Any?) {
val string = "$tag: $message ${objects.joinToString(" ")}"
_os_log_internal(__dso_handle.ptr, OS_LOG_DEFAULT, OS_LOG_TYPE_ERROR, "%s", string)
}
}
actual fun loggerFor(obj: Any): Logger = IosLogger(obj)