mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-23 07:57:51 -05:00
add the logcat writer
This commit is contained in:
parent
cd012df57e
commit
57a475b3b7
3 changed files with 20 additions and 1 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
using namespace geode::prelude;
|
||||
|
||||
static std::string getDateString(bool filesafe) {
|
||||
std::string crashlog::getDateString(bool filesafe) {
|
||||
auto const now = std::time(nullptr);
|
||||
auto const tm = *std::localtime(&now);
|
||||
std::ostringstream oss;
|
||||
|
|
|
@ -26,4 +26,6 @@ namespace crashlog {
|
|||
ghc::filesystem::path GEODE_DLL getCrashLogDirectory();
|
||||
|
||||
std::string GEODE_DLL writeCrashlog(geode::Mod* faultyMod, std::string const& info, std::string const& stacktrace, std::string const& registers);
|
||||
|
||||
std::string getDateString(bool filesafe);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,10 @@ using namespace geode::prelude;
|
|||
#include <link.h>
|
||||
#include <unwind.h>
|
||||
|
||||
|
||||
#include <jni.h>
|
||||
#include <Geode/cocos/platform/android/jni/JniHelper.h>
|
||||
|
||||
#include "backtrace/execinfo.hpp"
|
||||
|
||||
static constexpr size_t FRAME_SIZE = 64;
|
||||
|
@ -413,6 +417,19 @@ ghc::filesystem::path crashlog::getCrashLogDirectory() {
|
|||
}
|
||||
|
||||
bool crashlog::setupPlatformHandler() {
|
||||
auto path = crashlog::getCrashLogDirectory() / (getDateString(true) + ".log");
|
||||
|
||||
JniMethodInfo t;
|
||||
if (JniHelper::getStaticMethodInfo(t, "com/geode/launcher/utils/GeodeUtils", "writeLogcatCrashBuffer", "(Ljava/lang/String;)Z")) {
|
||||
jstring stringArg1 = t.env->NewStringUTF(path.string().c_str());
|
||||
|
||||
jboolean result = t.env->CallStaticBooleanMethod(t.classID, t.methodID, stringArg1);
|
||||
|
||||
t.env->DeleteLocalRef(stringArg1);
|
||||
t.env->DeleteLocalRef(t.classID);
|
||||
return result;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue