mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Switched from SimpleDateFormat to java.time
This commit is contained in:
parent
e19201de33
commit
14f298bff8
1 changed files with 4 additions and 4 deletions
|
@ -3,8 +3,8 @@ package com.beust.kobalt.misc
|
||||||
import com.beust.kobalt.AsciiArt
|
import com.beust.kobalt.AsciiArt
|
||||||
import com.beust.kobalt.KobaltException
|
import com.beust.kobalt.KobaltException
|
||||||
import com.beust.kobalt.api.Kobalt
|
import com.beust.kobalt.api.Kobalt
|
||||||
import java.text.SimpleDateFormat
|
import java.time.LocalDateTime
|
||||||
import java.util.*
|
import java.time.format.DateTimeFormatter
|
||||||
|
|
||||||
fun Any.log(level: Int, text: CharSequence, newLine : Boolean = true) {
|
fun Any.log(level: Int, text: CharSequence, newLine : Boolean = true) {
|
||||||
if (level <= KobaltLogger.LOG_LEVEL) {
|
if (level <= KobaltLogger.LOG_LEVEL) {
|
||||||
|
@ -48,11 +48,11 @@ object KobaltLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Logger(val dev: Boolean) {
|
class Logger(val dev: Boolean) {
|
||||||
val FORMAT = SimpleDateFormat("HH:mm:ss.SSS")
|
val FORMAT = DateTimeFormatter.ofPattern("HH:mm:ss.SSS")
|
||||||
|
|
||||||
private fun getPattern(shortTag: String, shortMessage: CharSequence, longMessage: CharSequence, tag: String) =
|
private fun getPattern(shortTag: String, shortMessage: CharSequence, longMessage: CharSequence, tag: String) =
|
||||||
if (dev) {
|
if (dev) {
|
||||||
val ts = FORMAT.format(Date())
|
val ts = LocalDateTime.now().format(FORMAT)
|
||||||
"$shortTag/$ts [" + Thread.currentThread().name + "] $tag - $shortMessage"
|
"$shortTag/$ts [" + Thread.currentThread().name + "] $tag - $shortMessage"
|
||||||
} else {
|
} else {
|
||||||
longMessage
|
longMessage
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue