From 4bbebdffe4e6608e0f24a58c3ac7d95c830b60df Mon Sep 17 00:00:00 2001 From: fankesyooni Date: Fri, 30 Sep 2022 02:48:21 +0800 Subject: [PATCH] Added inMemoryData usage in logger documentation --- .../src/en/api/special-features/logger.md | 18 +++++++++++++++++- .../src/zh-cn/api/special-features/logger.md | 18 +++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/docs-source/src/en/api/special-features/logger.md b/docs-source/src/en/api/special-features/logger.md index a4ebdd5f..4a7aef95 100644 --- a/docs-source/src/en/api/special-features/logger.md +++ b/docs-source/src/en/api/special-features/logger.md @@ -147,6 +147,22 @@ You can also use `YukiHookLogger.contents` to get all the log file contents that val fileContent = YukiHookLogger.contents ``` +If you need an array of real-time log data structures, you can directly get the content of `YukiHookLogger.inMemoryData`. + +> The following example + +```kotlin +// Get the currently printed real-time log data structure array +YukiHookLogger.inMemoryData.forEach { + it.timestamp // Get timestamp + it.time // Get UTC time + it.priority // Get priority + it.msg // Get message + it.throwable // Get exception + // ... +} +``` + The above features require `YukiHookLogger.Configs.isRecord` to be enabled. You can also use `YukiHookLogger.Configs.elements` to customize the elements that debug logs display externally. @@ -167,6 +183,6 @@ override fun onInit() = configs { ::: tip -For more functions, please refer to [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.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 5ad2de81..f764f19e 100644 --- a/docs-source/src/zh-cn/api/special-features/logger.md +++ b/docs-source/src/zh-cn/api/special-features/logger.md @@ -143,6 +143,22 @@ YukiHookLogger.saveToFile("/sdcard/Documents/debug_log.log") val fileContent = YukiHookLogger.contents ``` +如果你需要一个实时日志的数据结构数组,你可以直接获取 `YukiHookLogger.inMemoryData` 的内容。 + +> 示例如下 + +```kotlin +// 获取当前已打印的实时日志数据结构数组 +YukiHookLogger.inMemoryData.forEach { + it.timestamp // 获取时间戳 + it.time // 获取 UTC 时间 + it.priority // 获取优先级 + it.msg // 获取消息 + it.throwable // 获取异常 + // ... +} +``` + 以上功能需要启用 `YukiHookLogger.Configs.isRecord`。 你还可以使用 `YukiHookLogger.Configs.elements` 自定义调试日志对外显示的元素。 @@ -163,6 +179,6 @@ override fun onInit() = configs { ::: tip -更多功能请参考 [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.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