diff --git a/docs-source/src/en/api/special-features/logger.md b/docs-source/src/en/api/special-features/logger.md index 5ce4780a..c57a0099 100644 --- a/docs-source/src/en/api/special-features/logger.md +++ b/docs-source/src/en/api/special-features/logger.md @@ -163,10 +163,26 @@ YukiHookLogger.inMemoryData.forEach { } ``` -The above features require `YukiHookLogger.Configs.isRecord` to be enabled. +If you want to format or save the obtained custom log data to a file, you only need to use the following method. + +> The following example + +```kotlin +// Assume this is the custom log data you get +val data: ArrayList +// Format log data to String +val dataString = YukiHookLogger.contents(data) +// Save log data to file +// Please note +// The saved file path must have read and write permissions +// Otherwise an exception will be thrown +YukiHookLogger.saveToFile("/sdcard/Documents/debug_log.log", data) +``` ::: danger +You need to enable **YukiHookLogger.Configs.isRecord** to get the contents of **YukiHookLogger.inMemoryData**. + The obtained log data is isolated from each other in the Host App and the Module App's process. You can only get the corresponding log data in the corresponding process. @@ -195,6 +211,6 @@ override fun onInit() = configs { ::: tip -For more functions, please refer to [YukiHookLogger.inMemoryData](../public/com/highcapable/yukihookapi/hook/log/LoggerFactory#inmemorydata-field), [YukiHookLogger.contents](../public/com/highcapable/yukihookapi/hook/log/LoggerFactory#contents-field), [YukiHookLogger.saveToFile](../public/com/highcapable/yukihookapi/hook/log/LoggerFactory#savetofile-method) methods and [YukiHookLogger.Configs](../public/com/highcapable/yukihookapi/hook/log/LoggerFactory#configs-object). +For more functions, please refer to [YukiHookLogger.inMemoryData](../public/com/highcapable/yukihookapi/hook/log/LoggerFactory#inmemorydata-field), [YukiHookLogger.contents](../public/com/highcapable/yukihookapi/hook/log/LoggerFactory#contents-field), [YukiHookLogger.contents](../public/com/highcapable/yukihookapi/hook/log/LoggerFactory#contents-method), [YukiHookLogger.saveToFile](../public/com/highcapable/yukihookapi/hook/log/LoggerFactory#savetofile-method) methods and [YukiHookLogger.Configs](../public/com/highcapable/yukihookapi/hook/log/LoggerFactory#configs-object). ::: \ No newline at end of file diff --git a/docs-source/src/zh-cn/api/special-features/logger.md b/docs-source/src/zh-cn/api/special-features/logger.md index fa6e4f35..23d1e6a8 100644 --- a/docs-source/src/zh-cn/api/special-features/logger.md +++ b/docs-source/src/zh-cn/api/special-features/logger.md @@ -159,10 +159,24 @@ YukiHookLogger.inMemoryData.forEach { } ``` -以上功能需要启用 `YukiHookLogger.Configs.isRecord`。 +如果你想对得到的自定义日志数据进行格式化或保存到文件,你只需要使用如下方法即可。 + +> 示例如下 + +```kotlin +// 假设这就是你得到的自定义日志数据 +val data: ArrayList +// 格式化日志数据到字符串 +val dataString = YukiHookLogger.contents(data) +// 保存日志数据到文件 +// 请注意保存的文件路径必须拥有读写权限,否则会抛出异常 +YukiHookLogger.saveToFile("/sdcard/Documents/debug_log.log", data) +``` ::: danger +你需要启用 **YukiHookLogger.Configs.isRecord** 才能获取到 **YukiHookLogger.inMemoryData** 的内容。 + 获取到的日志数据在 Hook APP (宿主) 及模块进程中是相互隔离的。 你只能在对应的进程中获取对应的日志数据,如果你需要在任何地方实时得到这些日志数据,请参考 [Xposed 模块与宿主通讯桥](xposed-channel)、[注册模块 Activity](host-inject#注册模块-activity)。 @@ -189,6 +203,6 @@ override fun onInit() = configs { ::: tip -更多功能请参考 [YukiHookLogger.inMemoryData](../public/com/highcapable/yukihookapi/hook/log/LoggerFactory#inmemorydata-field)、[YukiHookLogger.contents](../public/com/highcapable/yukihookapi/hook/log/LoggerFactory#contents-field)、[YukiHookLogger.saveToFile](../public/com/highcapable/yukihookapi/hook/log/LoggerFactory#savetofile-method) 方法以及 [YukiHookLogger.Configs](../public/com/highcapable/yukihookapi/hook/log/LoggerFactory#configs-object)。 +更多功能请参考 [YukiHookLogger.inMemoryData](../public/com/highcapable/yukihookapi/hook/log/LoggerFactory#inmemorydata-field)、[YukiHookLogger.contents](../public/com/highcapable/yukihookapi/hook/log/LoggerFactory#contents-field)、[YukiHookLogger.contents](../public/com/highcapable/yukihookapi/hook/log/LoggerFactory#contents-method)、[YukiHookLogger.saveToFile](../public/com/highcapable/yukihookapi/hook/log/LoggerFactory#savetofile-method) 方法以及 [YukiHookLogger.Configs](../public/com/highcapable/yukihookapi/hook/log/LoggerFactory#configs-object)。 ::: \ No newline at end of file