Improves log class for JVM
This commit is contained in:
@@ -20,16 +20,24 @@
|
||||
*/
|
||||
package com.vitorpamplona.quartz.utils
|
||||
|
||||
import java.time.LocalTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
actual object Log {
|
||||
// Define a formatter for the desired output format (e.g., HH:mm:ss)
|
||||
val formatter: DateTimeFormatter? = DateTimeFormatter.ofPattern("HH:mm:ss.SSS")
|
||||
|
||||
fun time() = LocalTime.now().format(formatter)
|
||||
|
||||
actual fun w(
|
||||
tag: String,
|
||||
message: String,
|
||||
throwable: Throwable?,
|
||||
) {
|
||||
if (throwable != null) {
|
||||
println("WARN: [$tag] $message. Throwable: ${throwable.message}")
|
||||
println("${time()} WARN : [$tag] $message. Throwable: ${throwable.message}")
|
||||
} else {
|
||||
println("WARN: [$tag] $message")
|
||||
println("${time()} WARN : [$tag] $message")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,9 +47,9 @@ actual object Log {
|
||||
throwable: Throwable?,
|
||||
) {
|
||||
if (throwable != null) {
|
||||
println("ERROR: [$tag] $message. Throwable: ${throwable.message}")
|
||||
println("${time()} ERROR: [$tag] $message. Throwable: ${throwable.message}")
|
||||
} else {
|
||||
println("ERROR: [$tag] $message")
|
||||
println("${time()} ERROR: [$tag] $message")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,13 +57,13 @@ actual object Log {
|
||||
tag: String,
|
||||
message: String,
|
||||
) {
|
||||
println("DEBUG: [$tag] $message")
|
||||
println("${time()} DEBUG: [$tag] $message")
|
||||
}
|
||||
|
||||
actual fun i(
|
||||
tag: String,
|
||||
message: String,
|
||||
) {
|
||||
println("INFO: [$tag] $message")
|
||||
println("${time()} INFO : [$tag] $message")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user