Smoothie
10/03/2025, 8:50 AM__LINE__
__FILE__
__function__
There is a lot of compile time information that could me handy for debug/logging in Kotlin so some intrinsic function for these would be nice.
For the current class i can do a simple extension prop :
val Any.TAG get() = this::class.simpleName
But didn't found alternative for otherChrimaeon
10/03/2025, 9:03 AMSmoothie
10/03/2025, 9:32 AMephemient
10/03/2025, 9:40 AMSmoothie
10/03/2025, 9:46 AMabstract fun log(
level: LogLevel,
tag: String?,
message: String,
throwable: Throwable?,
lineNumber: Int?,
fileName: String?,
methodName: String?,
typeName: String?
)
@JvmOverloads
inline fun logv(tag: String? = null, message: String, throwable: Throwable? = null) = log(LogLevel.VERBOSE, tag, message, throwable, __LINE__, __FILE__, __MEMBER__, __TYPE__)
@JvmOverloads
inline fun logd(tag: String? = null, message: String, throwable: Throwable? = null) = log(LogLevel.DEBUG, tag, message, throwable, __LINE__, __FILE__, __MEMBER__, __TYPE__)
@JvmOverloads
inline fun logi(tag: String? = null, message: String, throwable: Throwable? = null) = log(<http://LogLevel.INFO|LogLevel.INFO>, tag, message, throwable, __LINE__, __FILE__, __MEMBER__, __TYPE__)
@JvmOverloads
inline fun logw(tag: String? = null, message: String, throwable: Throwable? = null) = log(LogLevel.WARNING, tag, message, throwable, __LINE__, __FILE__, __MEMBER__, __TYPE__)
@JvmOverloads
inline fun loge(tag: String? = null, message: String, throwable: Throwable? = null) = log(LogLevel.ERROR, tag, message, throwable, __LINE__, __FILE__, __MEMBER__, __TYPE__)
@JvmOverloads
inline fun logwtf(tag: String? = null, message: String, throwable: Throwable? = null) = log(LogLevel.CRITICAL, tag, message, throwable, __LINE__, __FILE__, __MEMBER__, __TYPE__)
Smoothie
10/03/2025, 9:46 AMSmoothie
10/03/2025, 9:50 AMINFO(__LINE__, __FILE__, ...)
Smoothie
10/03/2025, 9:51 AMephemient
10/03/2025, 1:50 PM