mirror of
https://github.com/InsanusMokrassar/KSLog.git
synced 2024-12-21 21:47:13 +00:00
add trace level
This commit is contained in:
parent
34a7c9624d
commit
7a8bd035f5
@ -2,6 +2,8 @@
|
||||
|
||||
## 1.2.5
|
||||
|
||||
* Add `trace` logging level
|
||||
|
||||
## 1.2.4
|
||||
|
||||
**This update contains migration onto gradle 8+ (for both wrapper and android plugin). Use it with caution**
|
||||
|
@ -1,9 +1,9 @@
|
||||
[versions]
|
||||
|
||||
kotlin = "1.9.20"
|
||||
kotlin-gradle-plugin = "8.1.2"
|
||||
kotlin-gradle-plugin = "8.1.4"
|
||||
|
||||
versions = "0.49.0"
|
||||
versions = "0.50.0"
|
||||
|
||||
dokka = "1.9.10"
|
||||
|
||||
|
@ -6,6 +6,7 @@ import android.util.Log
|
||||
internal actual val defaultLogging: (level: LogLevel, tag: String, message: Any, throwable: Throwable?) -> Unit = { l, t, m, e ->
|
||||
val messageString = m.toString()
|
||||
when(l) {
|
||||
LogLevel.TRACE -> Log.d(t, messageString, e)
|
||||
LogLevel.DEBUG -> Log.d(t, messageString, e)
|
||||
LogLevel.VERBOSE -> Log.v(t, messageString, e)
|
||||
LogLevel.INFO -> Log.i(t, messageString, e)
|
||||
|
@ -15,6 +15,19 @@ inline fun KSLog.log(level: LogLevel, tag: String, message: Any, e: Throwable?)
|
||||
inline fun KSLog.log(level: LogLevel, tag: String, message: Any) = performLog(level, tag, message, null)
|
||||
|
||||
|
||||
inline fun KSLog.trace(e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.TRACE, null, e, messageBuilder)
|
||||
inline fun KSLog.trace(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.TRACE, tag, e, messageBuilder)
|
||||
inline fun KSLog.trace(tag: String, noinline messageBuilder: () -> Any) = trace(tag, null, messageBuilder)
|
||||
suspend inline fun KSLog.traceS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.TRACE, null, e, messageBuilder)
|
||||
suspend inline fun KSLog.traceS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.TRACE, tag, e, messageBuilder)
|
||||
suspend inline fun KSLog.traceS(tag: String, noinline messageBuilder: suspend () -> Any) = traceS(tag, null, messageBuilder)
|
||||
inline fun KSLog.trace(message: Any, e: Throwable?) = log(LogLevel.TRACE, message, e)
|
||||
inline fun KSLog.trace(message: String, e: Throwable) = trace(message as Any, e)
|
||||
inline fun KSLog.trace(message: Any) = trace(message, null)
|
||||
inline fun KSLog.trace(tag: String, message: Any, e: Throwable?) = log(LogLevel.TRACE, tag, message, e)
|
||||
inline fun KSLog.trace(tag: String, message: Any) = trace(tag, message, null)
|
||||
|
||||
|
||||
inline fun KSLog.debug(e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.DEBUG, null, e, messageBuilder)
|
||||
inline fun KSLog.debug(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.DEBUG, tag, e, messageBuilder)
|
||||
inline fun KSLog.debug(tag: String, noinline messageBuilder: () -> Any) = debug(tag, null, messageBuilder)
|
||||
@ -108,6 +121,19 @@ inline fun KSLog.l(level: LogLevel, tag: String, message: Any, e: Throwable?) =
|
||||
inline fun KSLog.l(level: LogLevel, tag: String, message: Any) = log(level, tag, message, null)
|
||||
|
||||
|
||||
inline fun KSLog.t(e: Throwable? = null, noinline messageBuilder: () -> Any) = trace(e, messageBuilder)
|
||||
inline fun KSLog.t(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = trace(tag, e, messageBuilder)
|
||||
inline fun KSLog.t(tag: String, noinline messageBuilder: () -> Any) = t(tag, null, messageBuilder)
|
||||
suspend inline fun KSLog.tS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = traceS(e, messageBuilder)
|
||||
suspend inline fun KSLog.tS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = traceS(tag, e, messageBuilder)
|
||||
suspend inline fun KSLog.tS(tag: String, noinline messageBuilder: suspend () -> Any) = tS(tag, null, messageBuilder)
|
||||
inline fun KSLog.t(message: Any, e: Throwable?) = trace(message, e)
|
||||
inline fun KSLog.t(message: String, e: Throwable) = t(message as Any, e)
|
||||
inline fun KSLog.t(message: Any) = t(message, null)
|
||||
inline fun KSLog.t(tag: String, message: Any, e: Throwable?) = trace(tag, message, e)
|
||||
inline fun KSLog.t(tag: String, message: Any) = t(tag, message, null)
|
||||
|
||||
|
||||
inline fun KSLog.d(e: Throwable? = null, noinline messageBuilder: () -> Any) = debug(e, messageBuilder)
|
||||
inline fun KSLog.d(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = debug(tag, e, messageBuilder)
|
||||
inline fun KSLog.d(tag: String, noinline messageBuilder: () -> Any) = d(tag, null, messageBuilder)
|
||||
|
@ -5,6 +5,7 @@ import dev.inmo.kslog.common.utils.plus
|
||||
|
||||
|
||||
enum class LogLevel {
|
||||
TRACE,
|
||||
DEBUG,
|
||||
VERBOSE,
|
||||
INFO,
|
||||
|
@ -5,6 +5,7 @@ internal actual val defaultLogging: (level: LogLevel, tag: String, message: Any,
|
||||
arrayOf(m, e)
|
||||
} ?: arrayOf(m)
|
||||
when (l) {
|
||||
LogLevel.TRACE,
|
||||
LogLevel.DEBUG -> console.log(*args)
|
||||
LogLevel.VERBOSE,
|
||||
LogLevel.INFO -> console.info(*args)
|
||||
|
@ -11,6 +11,7 @@ private fun Logger.doLog(
|
||||
l: LogLevel, t: String, m: String, e: Throwable?
|
||||
) = log(
|
||||
when(l) {
|
||||
LogLevel.TRACE -> Level.ALL
|
||||
LogLevel.DEBUG -> Level.FINEST
|
||||
LogLevel.VERBOSE -> Level.FINE
|
||||
LogLevel.INFO -> Level.INFO
|
||||
|
Loading…
Reference in New Issue
Block a user