diff --git a/docs-source/src/en/config/move-to-api-1-3-x.md b/docs-source/src/en/config/move-to-api-1-3-x.md index 8ce16f41..cc4a53b6 100644 --- a/docs-source/src/en/config/move-to-api-1-3-x.md +++ b/docs-source/src/en/config/move-to-api-1-3-x.md @@ -91,4 +91,8 @@ Now this method will be useless and will not be called back. If necessary, pleas `YukiHookAPI` Starting with `1.3.0`, the way in which the module `Activity` behavior has changed. -Please read [Register Module App's Activity](../api/special-features/host-inject#register-module-app-s-activity) for more information. \ No newline at end of file +Please read [Register Module App's Activity](../api/special-features/host-inject#register-module-app-s-activity) for more information. + +## YLog Behavior Change + +`YukiHookAPI` allows the `msg` parameter of `YLog` to be passed into any object starting from `1.3.0`, and they will be automatically converted using the `toString()` method. \ No newline at end of file diff --git a/docs-source/src/zh-cn/config/move-to-api-1-3-x.md b/docs-source/src/zh-cn/config/move-to-api-1-3-x.md index d4f5dea7..e7f8e41c 100644 --- a/docs-source/src/zh-cn/config/move-to-api-1-3-x.md +++ b/docs-source/src/zh-cn/config/move-to-api-1-3-x.md @@ -85,4 +85,8 @@ val instance: Any `YukiHookAPI` 从 `1.3.0` 版本开始,注册模块 `Activity` 行为的方式发生了变更。 -请阅读 [注册模块 Activity](../api/special-features/host-inject#注册模块-activity) 以了解更多信息。 \ No newline at end of file +请阅读 [注册模块 Activity](../api/special-features/host-inject#注册模块-activity) 以了解更多信息。 + +## YLog 行为变更 + +`YukiHookAPI` 从 `1.3.0` 版本开始允许 `YLog` 的 `msg` 参数传入任意对象,它们都会自动使用 `toString()` 方法进行转换。 \ No newline at end of file diff --git a/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/log/YLog.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/log/YLog.kt index 6e091f06..cd06c7ba 100644 --- a/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/log/YLog.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/log/YLog.kt @@ -231,8 +231,8 @@ object YLog { * @param tag 日志打印的标签 - 建议和自己的模块名称设置成一样的 - 默认为 [Configs.tag] * @param env 日志打印的环境 - 默认为 [EnvType.BOTH] */ - fun debug(msg: String = "", e: Throwable? = null, tag: String = Configs.tag, env: EnvType = EnvType.BOTH) = - log(env, YLogData(priority = "D", tag = tag, msg = msg, throwable = e)) + fun debug(msg: Any? = null, e: Throwable? = null, tag: String = Configs.tag, env: EnvType = EnvType.BOTH) = + log(env, YLogData(priority = "D", tag = tag, msg = msg.toString(), throwable = e)) /** * 打印 Info 级别 Log @@ -243,8 +243,8 @@ object YLog { * @param tag 日志打印的标签 - 建议和自己的模块名称设置成一样的 - 默认为 [Configs.tag] * @param env 日志打印的环境 - 默认为 [EnvType.BOTH] */ - fun info(msg: String = "", e: Throwable? = null, tag: String = Configs.tag, env: EnvType = EnvType.BOTH) = - log(env, YLogData(priority = "I", tag = tag, msg = msg, throwable = e)) + fun info(msg: Any? = null, e: Throwable? = null, tag: String = Configs.tag, env: EnvType = EnvType.BOTH) = + log(env, YLogData(priority = "I", tag = tag, msg = msg.toString(), throwable = e)) /** * 打印 Warn 级别 Log @@ -255,8 +255,8 @@ object YLog { * @param tag 日志打印的标签 - 建议和自己的模块名称设置成一样的 - 默认为 [Configs.tag] * @param env 日志打印的环境 - 默认为 [EnvType.BOTH] */ - fun warn(msg: String = "", e: Throwable? = null, tag: String = Configs.tag, env: EnvType = EnvType.BOTH) = - log(env, YLogData(priority = "W", tag = tag, msg = msg, throwable = e)) + fun warn(msg: Any? = null, e: Throwable? = null, tag: String = Configs.tag, env: EnvType = EnvType.BOTH) = + log(env, YLogData(priority = "W", tag = tag, msg = msg.toString(), throwable = e)) /** * 打印 Error 级别 Log @@ -267,8 +267,8 @@ object YLog { * @param e 可填入异常堆栈信息 - 将自动完整打印到控制台 * @param env 日志打印的环境 - 默认为 [EnvType.BOTH] */ - fun error(msg: String = "", e: Throwable? = null, tag: String = Configs.tag, env: EnvType = EnvType.BOTH) = - log(env, YLogData(priority = "E", tag = tag, msg = msg, throwable = e)) + fun error(msg: Any? = null, e: Throwable? = null, tag: String = Configs.tag, env: EnvType = EnvType.BOTH) = + log(env, YLogData(priority = "E", tag = tag, msg = msg.toString(), throwable = e)) /** * [YukiHookAPI] (内部) 打印 Debug 级别 Log @@ -276,9 +276,9 @@ object YLog { * @param e 可填入异常堆栈信息 - 将自动完整打印到控制台 * @param isImplicit 是否隐式打印 - 不会记录 - 也不会显示包名和用户 ID */ - internal fun innerD(msg: String = "", e: Throwable? = null, isImplicit: Boolean = false) { + internal fun innerD(msg: Any? = null, e: Throwable? = null, isImplicit: Boolean = false) { if (Configs.isEnable.not() || YukiHookAPI.Configs.isDebug.not()) return initKavaRefLoggerIfNot() - log(EnvType.BOTH, YLogData(priority = "D", msg = msg, throwable = e), isImplicit) + log(EnvType.BOTH, YLogData(priority = "D", msg = msg.toString(), throwable = e), isImplicit) } /** @@ -287,9 +287,9 @@ object YLog { * @param e 可填入异常堆栈信息 - 将自动完整打印到控制台 * @param isImplicit 是否隐式打印 - 不会记录 - 也不会显示包名和用户 ID */ - internal fun innerI(msg: String = "", e: Throwable? = null, isImplicit: Boolean = false) { + internal fun innerI(msg: Any? = null, e: Throwable? = null, isImplicit: Boolean = false) { if (Configs.isEnable.not()) return initKavaRefLoggerIfNot() - log(EnvType.BOTH, YLogData(priority = "I", msg = msg, throwable = e), isImplicit) + log(EnvType.BOTH, YLogData(priority = "I", msg = msg.toString(), throwable = e), isImplicit) } /** @@ -298,9 +298,9 @@ object YLog { * @param e 可填入异常堆栈信息 - 将自动完整打印到控制台 * @param isImplicit 是否隐式打印 - 不会记录 - 也不会显示包名和用户 ID */ - internal fun innerW(msg: String = "", e: Throwable? = null, isImplicit: Boolean = false) { + internal fun innerW(msg: Any? = null, e: Throwable? = null, isImplicit: Boolean = false) { if (Configs.isEnable.not()) return initKavaRefLoggerIfNot() - log(EnvType.BOTH, YLogData(priority = "W", msg = msg, throwable = e), isImplicit) + log(EnvType.BOTH, YLogData(priority = "W", msg = msg.toString(), throwable = e), isImplicit) } /** @@ -309,9 +309,9 @@ object YLog { * @param e 可填入异常堆栈信息 - 将自动完整打印到控制台 * @param isImplicit 是否隐式打印 - 不会记录 - 也不会显示包名和用户 ID */ - internal fun innerE(msg: String = "", e: Throwable? = null, isImplicit: Boolean = false) { + internal fun innerE(msg: Any? = null, e: Throwable? = null, isImplicit: Boolean = false) { if (Configs.isEnable.not()) return initKavaRefLoggerIfNot() - log(EnvType.BOTH, YLogData(priority = "E", msg = msg, throwable = e), isImplicit) + log(EnvType.BOTH, YLogData(priority = "E", msg = msg.toString(), throwable = e), isImplicit) } /**