Skip to content

Commit

Permalink
refactor: add config to switch crashlogger
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Feb 12, 2024
1 parent f5cf22b commit 26e0a52
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/ll/core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace ll {

struct LeviConfig {

int version = 13;
int version = 14;

std::string language = "system";
struct {
Expand All @@ -26,6 +26,7 @@ struct LeviConfig {
struct {
struct {
bool enabled = true;
bool builtin = false;
std::string logPath = R"(.\logs\crash)";
std::string dumpPrefix = "minidump_";
std::string logPrefix = "trace_";
Expand Down
6 changes: 0 additions & 6 deletions src/ll/core/CrashLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

#include "vcruntime.h"

#if _HAS_CXX23
#define LL_BUILTIN_CRASHLOGGER 0
#else
#define LL_BUILTIN_CRASHLOGGER 0
#endif

namespace ll {
class CrashLogger {
public:
Expand Down
16 changes: 5 additions & 11 deletions src/ll/core/LeviLamina.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,6 @@ namespace i18n {
extern std::string globalDefaultLocaleName;
}

void startCrashLogger() {
#if !LL_BUILTIN_CRASHLOGGER
CrashLogger::initCrashLogger();
#else
static CrashLoggerNew crashLogger{};
#endif
}

void leviLaminaMain() {
error_utils::setSehTranslator();

Expand Down Expand Up @@ -244,7 +236,11 @@ void leviLaminaMain() {
ll::service::PlayerInfo::getInstance();
}
if (globalConfig.modules.crashLogger.enabled) {
startCrashLogger();
if (globalConfig.modules.crashLogger.builtin) {
static CrashLoggerNew crashLogger{};
} else {
CrashLogger::initCrashLogger();
}
}

// Register Exit Event Handler.
Expand Down Expand Up @@ -300,5 +296,3 @@ LL_AUTO_STATIC_HOOK(LeviLaminaMainHook, HookPriority::High, "main", int, int arg
return res;
}
} // namespace ll

[[maybe_unused]] BOOL WINAPI DllMain(HMODULE, DWORD, LPVOID) { return true; }

0 comments on commit 26e0a52

Please sign in to comment.