mirror of
https://github.com/mamoe/mirai.git
synced 2025-04-25 21:23:55 +08:00
Fix loggers
This commit is contained in:
parent
5485ffe801
commit
9631a2de1f
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils
@ -13,8 +13,8 @@ import java.io.File
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
private val currentDay = Calendar.getInstance()[Calendar.DAY_OF_MONTH]
|
||||
private val currentDate = SimpleDateFormat("yyyy-MM-dd").format(Date())
|
||||
private val currentDay get() = Calendar.getInstance()[Calendar.DAY_OF_MONTH]
|
||||
private val currentDate get() = SimpleDateFormat("yyyy-MM-dd").format(Date())
|
||||
|
||||
/**
|
||||
* 将日志写入('append')到特定文件.
|
||||
@ -22,7 +22,7 @@ private val currentDate = SimpleDateFormat("yyyy-MM-dd").format(Date())
|
||||
* @see PlatformLogger 查看格式信息
|
||||
*/
|
||||
class SingleFileLogger @JvmOverloads constructor(identity: String, file: File = File("$identity-$currentDate.log")) :
|
||||
PlatformLogger(identity, { file.appendText(it) }, false) {
|
||||
PlatformLogger(identity, { file.appendText(it + "\n") }, false) {
|
||||
|
||||
init {
|
||||
file.createNewFile()
|
||||
|
@ -45,6 +45,9 @@ import java.util.*
|
||||
*/
|
||||
actual open class PlatformLogger @JvmOverloads constructor(
|
||||
override val identity: String? = "Mirai",
|
||||
/**
|
||||
* 日志输出. 不会自动添加换行
|
||||
*/
|
||||
open val output: (String) -> Unit,
|
||||
val isColored: Boolean = true
|
||||
) : MiraiLoggerPlatformBase() {
|
||||
|
Loading…
Reference in New Issue
Block a user