Added inMemoryData usage in logger documentation

This commit is contained in:
2022-09-30 02:48:21 +08:00
parent a057a4d29c
commit 4bbebdffe4
2 changed files with 34 additions and 2 deletions

View File

@@ -147,6 +147,22 @@ You can also use `YukiHookLogger.contents` to get all the log file contents that
val fileContent = YukiHookLogger.contents 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. 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. 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 ::: 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).
::: :::

View File

@@ -143,6 +143,22 @@ YukiHookLogger.saveToFile("/sdcard/Documents/debug_log.log")
val fileContent = YukiHookLogger.contents 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.isRecord`。
你还可以使用 `YukiHookLogger.Configs.elements` 自定义调试日志对外显示的元素。 你还可以使用 `YukiHookLogger.Configs.elements` 自定义调试日志对外显示的元素。
@@ -163,6 +179,6 @@ override fun onInit() = configs {
::: tip ::: 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)。
::: :::