mirai-core / net.mamoe.mirai.utils / PlatformLogger

PlatformLogger

open class PlatformLogger : MiraiLoggerPlatformBase

当前平台的默认的日志记录器. 在 JVM 控制台 端的实现为 printlnAndroid 端的实现为 android.util.Log

不应该直接构造这个类的实例. 请使用 DefaultLogger, 或使用默认的顶层日志记录 MiraiLogger.Companion

Constructors

<init>

当前平台的默认的日志记录器. 在 JVM 控制台 端的实现为 printlnAndroid 端的实现为 android.util.Log

PlatformLogger(identity: String? = "Mirai")

JVM 控制台日志实现

PlatformLogger(identity: String? = "Mirai", output: (String) -> Unit)

Properties

identity

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

open val identity: String?

output

open val output: (String) -> Unit

Functions

debug0

open fun debug0(message: String?): Unit
open fun debug0(message: String?, e: Throwable?): Unit

error0

open fun error0(message: String?): Unit
open fun error0(message: String?, e: Throwable?): Unit

info0

open fun info0(message: String?): Unit
open fun info0(message: String?, e: Throwable?): Unit

verbose0

open fun verbose0(message: String?): Unit
open fun verbose0(message: String?, e: Throwable?): Unit

warning0

open fun warning0(message: String?): Unit
open fun warning0(message: String?, e: Throwable?): Unit

Extension Functions

debug

fun MiraiLogger.debug(lazyMessage: () -> String?): Unit
fun MiraiLogger.debug(lazyMessage: () -> String?, e: Throwable?): Unit

error

fun MiraiLogger.error(lazyMessage: () -> String?): Unit
fun MiraiLogger.error(lazyMessage: () -> String?, e: Throwable?): Unit

info

fun MiraiLogger.info(lazyMessage: () -> String?): Unit
fun MiraiLogger.info(lazyMessage: () -> String?, e: Throwable?): Unit

verbose

fun MiraiLogger.verbose(lazyMessage: () -> String): Unit
fun MiraiLogger.verbose(lazyMessage: () -> String, e: Throwable?): Unit

warning

fun MiraiLogger.warning(lazyMessage: () -> String?): Unit
fun MiraiLogger.warning(lazyMessage: () -> String?, e: Throwable?): Unit

withSwitch

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

fun MiraiLogger.withSwitch(default: Boolean = true): MiraiLoggerWithSwitch

Inheritors

SilentLogger

不做任何事情的 logger, keep silent.

object SilentLogger : PlatformLogger