PlatformLogger

Log 日志实现

See also

使用单一文件记录日志

在一个目录中按日期存放文件记录日志, 自动清理过期日志

当前平台的默认的日志记录器.

  • JVM 控制台 端的实现为 println

  • Android 端的实现为 android.util.Log

单条日志格式 (正则) 为:

^([\w-]*\s[\w:]*)\s(\w)\/(.*?):\s(.+)$

其中 group 分别为: 日期与时间, 严重程度, identity, 消息内容.

示例:

2020-05-21 19:51:09 V/Bot 123456789: Send: OidbSvc.0x88d_7

日期时间格式为 yyyy-MM-dd HH:mm:ss,

严重程度为 V, I, W, E. 分别对应 verbose, info, warning, error

See also

Inheritors

JVM 控制台日志实现

单条日志格式 (正则) 为:

^([\w-]*\s[\w:]*)\s(\w)\/(.*?):\s(.+)$

其中 group 分别为: 日期与时间, 严重程度, identity, 消息内容.

示例:

2020-05-21 19:51:09 V/Bot 123456789: Send: OidbSvc.0x88d_7

日期时间格式为 yyyy-MM-dd HH:mm:ss,

严重程度为 V, I, W, E. 分别对应 verbose, info, warning, error

Parameters

isColored

是否添加 ANSI 颜色

See also

使用单一文件记录日志

在一个目录中按日期存放文件记录日志, 自动清理过期日志

Inheritors

Constructors

Link copied to clipboard
actual constructor(identity: String?)
expect constructor(identity: String? = "Mirai")
constructor(identity: String?, output: (String) -> Unit = ::println)
constructor(identity: String? = "Mirai", output: (String) -> Unit, isColored: Boolean = true)
actual constructor(identity: String?)

Functions

Link copied to clipboard
open fun call(priority: SimpleLogger.LogPriority, message: String? = null, e: Throwable? = null)

根据优先级调用对应函数

open fun call(priority: SimpleLogger.LogPriority, message: String? = null, e: Throwable? = null)

根据优先级调用对应函数

open fun call(priority: SimpleLogger.LogPriority, message: String? = null, e: Throwable? = null)

根据优先级调用对应函数

Link copied to clipboard
open fun debug(e: Throwable?)
override fun debug(message: String?, e: Throwable?)

override fun debug(message: String?)

记录一个 调试 级别的日志.

open fun debug(e: Throwable?)
override fun debug(message: String?, e: Throwable?)

override fun debug(message: String?)

记录一个 调试 级别的日志.

open fun debug(e: Throwable?)
override fun debug(message: String?, e: Throwable?)

override fun debug(message: String?)

记录一个 调试 级别的日志.

Link copied to clipboard
inline fun MiraiLogger.debug(message: () -> String?)
inline fun MiraiLogger.debug(message: () -> String?, e: Throwable?)
Link copied to clipboard
open override fun debug0(message: String?)
open override fun debug0(message: String?, e: Throwable?)
open override fun debug0(message: String?)
open override fun debug0(message: String?, e: Throwable?)
Link copied to clipboard
open fun error(e: Throwable?)
override fun error(message: String?, e: Throwable?)

override fun error(message: String?)

记录一个 错误 级别的日志.

open fun error(e: Throwable?)
override fun error(message: String?, e: Throwable?)

override fun error(message: String?)

记录一个 错误 级别的日志.

open fun error(e: Throwable?)
override fun error(message: String?, e: Throwable?)

override fun error(message: String?)

记录一个 错误 级别的日志.

Link copied to clipboard
inline fun MiraiLogger.error(message: () -> String?)
inline fun MiraiLogger.error(message: () -> String?, e: Throwable?)
Link copied to clipboard
open override fun error0(message: String?)
open override fun error0(message: String?, e: Throwable?)
open override fun error0(message: String?)
open override fun error0(message: String?, e: Throwable?)
Link copied to clipboard
open fun info(e: Throwable?)
override fun info(message: String?, e: Throwable?)

override fun info(message: String?)

记录一个 信息 级别的日志.

open fun info(e: Throwable?)
override fun info(message: String?, e: Throwable?)

override fun info(message: String?)

记录一个 信息 级别的日志.

open fun info(e: Throwable?)
override fun info(message: String?, e: Throwable?)

override fun info(message: String?)

记录一个 信息 级别的日志.

Link copied to clipboard
inline fun MiraiLogger.info(message: () -> String?)
inline fun MiraiLogger.info(message: () -> String?, e: Throwable?)
Link copied to clipboard
open override fun info0(message: String?)
open override fun info0(message: String?, e: Throwable?)
open override fun info0(message: String?)
open override fun info0(message: String?, e: Throwable?)
Link copied to clipboard
open fun verbose(e: Throwable?)
override fun verbose(message: String?, e: Throwable?)

override fun verbose(message: String?)

记录一个 verbose 级别的日志. 无关紧要的, 经常大量输出的日志应使用它.

open fun verbose(e: Throwable?)
override fun verbose(message: String?, e: Throwable?)

override fun verbose(message: String?)

记录一个 verbose 级别的日志. 无关紧要的, 经常大量输出的日志应使用它.

open fun verbose(e: Throwable?)
override fun verbose(message: String?, e: Throwable?)

override fun verbose(message: String?)

记录一个 verbose 级别的日志. 无关紧要的, 经常大量输出的日志应使用它.

Link copied to clipboard
inline fun MiraiLogger.verbose(message: () -> String)
inline fun MiraiLogger.verbose(message: () -> String, e: Throwable?)
Link copied to clipboard
open override fun verbose0(message: String?)
open override fun verbose0(message: String?, e: Throwable?)
open override fun verbose0(message: String?)
open override fun verbose0(message: String?, e: Throwable?)
Link copied to clipboard
open fun warning(e: Throwable?)
override fun warning(message: String?, e: Throwable?)

override fun warning(message: String?)

记录一个 警告 级别的日志.

open fun warning(e: Throwable?)
override fun warning(message: String?, e: Throwable?)

override fun warning(message: String?)

记录一个 警告 级别的日志.

open fun warning(e: Throwable?)
override fun warning(message: String?, e: Throwable?)

override fun warning(message: String?)

记录一个 警告 级别的日志.

Link copied to clipboard
inline fun MiraiLogger.warning(message: () -> String?)
inline fun MiraiLogger.warning(message: () -> String?, e: Throwable?)
Link copied to clipboard
open override fun warning0(message: String?)
open override fun warning0(message: String?, e: Throwable?)
open override fun warning0(message: String?)
open override fun warning0(message: String?, e: Throwable?)
Link copied to clipboard

给这个 logger 添加一个开关, 用于控制是否记录 log

Properties

Link copied to clipboard
open override val identity: String?

日志的标记. 在 Mirai 中, identity 可为

abstract val identity: String?

日志的标记. 在 Mirai 中, identity 可为

open override val identity: String?

日志的标记. 在 Mirai 中, identity 可为

Link copied to clipboard
val isColored: Boolean = true
Link copied to clipboard

当 DEBUG 级别的日志启用时返回 true

当 DEBUG 级别的日志启用时返回 true

当 DEBUG 级别的日志启用时返回 true

Link copied to clipboard
open override val isEnabled: Boolean

获取 MiraiLogger 是否已开启

open override val isEnabled: Boolean

获取 MiraiLogger 是否已开启

open override val isEnabled: Boolean

获取 MiraiLogger 是否已开启

Link copied to clipboard

当 ERROR 级别的日志启用时返回 true

当 ERROR 级别的日志启用时返回 true

当 ERROR 级别的日志启用时返回 true

Link copied to clipboard

当 INFO 级别的日志启用时返回 true

当 INFO 级别的日志启用时返回 true

当 INFO 级别的日志启用时返回 true

Link copied to clipboard

当 VERBOSE 级别的日志启用时返回 true.

当 VERBOSE 级别的日志启用时返回 true.

当 VERBOSE 级别的日志启用时返回 true.

Link copied to clipboard

当 WARNING 级别的日志启用时返回 true

当 WARNING 级别的日志启用时返回 true

当 WARNING 级别的日志启用时返回 true

Link copied to clipboard
open val output: (String) -> Unit

日志输出. 不会自动添加换行