mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-31 19:40:24 +08:00
Ensure thread safe
This commit is contained in:
parent
4a488f3416
commit
ef2d22c956
@ -10,7 +10,6 @@
|
|||||||
package net.mamoe.mirai.internal.utils
|
package net.mamoe.mirai.internal.utils
|
||||||
|
|
||||||
import net.mamoe.mirai.utils.*
|
import net.mamoe.mirai.utils.*
|
||||||
import java.text.DateFormat
|
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@ -102,7 +101,9 @@ internal open class StdoutLogger constructor(
|
|||||||
else debug(message.toString())
|
else debug(message.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open val timeFormat: DateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
protected open val timeFormat: SimpleDateFormat by threadLocal {
|
||||||
|
SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
||||||
|
}
|
||||||
|
|
||||||
private val currentTimeFormatted get() = timeFormat.format(Date())
|
private val currentTimeFormatted get() = timeFormat.format(Date())
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@ package net.mamoe.mirai.utils
|
|||||||
|
|
||||||
import java.text.DateFormat
|
import java.text.DateFormat
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
import java.time.format.DateTimeFormatter
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -106,9 +108,12 @@ public actual open class PlatformLogger constructor( // same as StdoutLogger bu
|
|||||||
else debug(message.toString())
|
else debug(message.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open val timeFormat: DateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
@Deprecated("Use formatter instead.", level = DeprecationLevel.HIDDEN)
|
||||||
|
protected open val timeFormat: DateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.SIMPLIFIED_CHINESE)
|
||||||
|
|
||||||
private val currentTimeFormatted get() = timeFormat.format(Date())
|
protected open val formatter: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||||
|
|
||||||
|
private val currentTimeFormatted get() = formatter.format(LocalDateTime.now())
|
||||||
|
|
||||||
@MiraiExperimentalApi("This is subject to change.")
|
@MiraiExperimentalApi("This is subject to change.")
|
||||||
protected enum class Color(private val format: String) {
|
protected enum class Color(private val format: String) {
|
||||||
|
Loading…
Reference in New Issue
Block a user