mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-30 10:50:18 +08:00
Add migration helper for MiraiLogger
This commit is contained in:
parent
20bc17ee43
commit
9c22de03e0
@ -17,29 +17,41 @@ import net.mamoe.mirai.Bot
|
|||||||
import kotlin.contracts.InvocationKind.AT_MOST_ONCE
|
import kotlin.contracts.InvocationKind.AT_MOST_ONCE
|
||||||
import kotlin.contracts.contract
|
import kotlin.contracts.contract
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||||
|
@Deprecated(
|
||||||
|
"Use MiraiLogger.create",
|
||||||
|
level = DeprecationLevel.ERROR,
|
||||||
|
replaceWith = ReplaceWith(
|
||||||
|
"{ identity: String? -> MiraiLogger.create(identity) }",
|
||||||
|
"net.mamoe.mirai.utils.MiraiLogger"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
@PlannedRemoval("2.0-M2")
|
||||||
|
public var DefaultLogger: (identity: String?) -> MiraiLogger
|
||||||
|
@Deprecated(
|
||||||
|
"Create lambda by yourself.",
|
||||||
|
ReplaceWith("{ identity: String? -> MiraiLogger.create(identity) }", "net.mamoe.mirai.utils.MiraiLogger"),
|
||||||
|
level = DeprecationLevel.ERROR,
|
||||||
|
)
|
||||||
|
get() = { MiraiLogger.create(it) }
|
||||||
|
@Deprecated(
|
||||||
|
"Use MiraiLogger.setDefaultLoggerCreator",
|
||||||
|
replaceWith = ReplaceWith("MiraiLogger.setDefaultLoggerCreator(value)", "net.mamoe.mirai.utils.MiraiLogger"),
|
||||||
|
level = DeprecationLevel.ERROR,
|
||||||
|
)
|
||||||
|
set(value) = MiraiLogger.setDefaultLoggerCreator(value)
|
||||||
|
|
||||||
/**
|
|
||||||
* 用于创建默认的日志记录器. 在一些需要使用日志的 Mirai 的组件, 如 [Bot], 都会通过这个函数构造日志记录器.
|
@PlannedRemoval("2.0-M2")
|
||||||
*
|
@Suppress("DEPRECATION", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "NOTHING_TO_INLINE", "FunctionName")
|
||||||
* 可直接修改这个变量的值来重定向日志输出.
|
|
||||||
*
|
|
||||||
* **注意:** 请务必将所有的输出定向到日志记录系统, 否则在某些情况下 (如 web 控制台中) 将无法接收到输出
|
|
||||||
*
|
|
||||||
* **注意:** 请为日志做好分类, 即不同的模块使用不同的 [MiraiLogger].
|
|
||||||
* 如, [Bot] 中使用 `identity` 为 "Bot(qqId)" 的 [MiraiLogger]
|
|
||||||
* 而 [Bot] 的网络处理中使用 `identity` 为 "BotNetworkHandler".
|
|
||||||
*
|
|
||||||
* Java 调用: `Utils.getDefaultLogger().invoke(identity)`
|
|
||||||
*/
|
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
"Use MiraiLogger.create",
|
"Use MiraiLogger.create",
|
||||||
level = DeprecationLevel.ERROR,
|
level = DeprecationLevel.ERROR,
|
||||||
replaceWith = ReplaceWith("MiraiLogger.create(identity)", "net.mamoe.mirai.utils.MiraiLogger")
|
replaceWith = ReplaceWith("MiraiLogger.create(identity)", "net.mamoe.mirai.utils.MiraiLogger")
|
||||||
)
|
)
|
||||||
@PlannedRemoval("2.0-M2")
|
@kotlin.internal.HidesMembers
|
||||||
public var DefaultLogger: (identity: String?) -> MiraiLogger
|
@JvmSynthetic
|
||||||
get() = { MiraiLogger.create(it) }
|
public inline fun DefaultLogger(identity: String?): MiraiLogger = MiraiLogger.create(identity)
|
||||||
set(value) = MiraiLogger.setDefaultLoggerCreator(value)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 给这个 logger 添加一个开关, 用于控制是否记录 log
|
* 给这个 logger 添加一个开关, 用于控制是否记录 log
|
||||||
|
Loading…
Reference in New Issue
Block a user