All Downloads are FREE. Search and download functionalities are using the official Maven repository.

iosMain.Logger.kt Maven / Gradle / Ivy

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)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy