From 6d10673e074689f8ed98e59b3fbb6f419c7fda0e Mon Sep 17 00:00:00 2001 From: fankesyooni Date: Thu, 22 Sep 2022 15:06:54 +0800 Subject: [PATCH] Added Throwable.toStackTrace function in UtilsFactory --- .../highcapable/yukihookapi/hook/utils/UtilsFactory.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/utils/UtilsFactory.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/utils/UtilsFactory.kt index 7b723c69..27f98c57 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/utils/UtilsFactory.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/utils/UtilsFactory.kt @@ -27,6 +27,8 @@ */ package com.highcapable.yukihookapi.hook.utils +import java.io.ByteArrayOutputStream +import java.io.PrintStream import java.util.concurrent.ExecutorService import java.util.concurrent.Executors @@ -85,6 +87,12 @@ internal inline fun T.takeIf(other: Any?, predicate: (T) -> Boolean) = if (o */ internal inline fun T.let(other: Any?, block: (T) -> R) = if (other != null) let(block) else null +/** + * 获取完整的异常堆栈内容 + * @return [String] + */ +internal fun Throwable.toStackTrace() = ByteArrayOutputStream().also { printStackTrace(PrintStream(it)) }.toString() + /** * 计算方法执行耗时 * @param block 方法块