feat: write Dalamud.Boot logs to dalamud.boot.log

This commit is contained in:
goaaats 2022-05-29 17:25:29 +02:00
parent ad4f2db203
commit a7540d0fef
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
5 changed files with 39 additions and 14 deletions

View file

@ -9,8 +9,17 @@ HMODULE g_hModule;
HINSTANCE g_hGameInstance = GetModuleHandleW(nullptr);
DllExport DWORD WINAPI Initialize(LPVOID lpParam, HANDLE hMainThreadContinue) {
logging::log_file.open(utils::get_env<std::wstring>("DALAMUD_BOOT_LOGFILE"), std::ios_base::out | std::ios_base::app);
if (bootconfig::is_show_console())
ConsoleSetup(L"Dalamud Boot");
if (!logging::log_file) {
logging::print<logging::E>("Couldn't open log file!");
}
logging::print<logging::I>("Dalamud.Boot Injectable, (c) 2021 XIVLauncher Contributors");
logging::print<logging::I>("Built at: " __DATE__ "@" __TIME__);
if (bootconfig::is_wait_messagebox())
MessageBoxW(nullptr, L"Press OK to continue", L"Dalamud Boot", MB_OK);
@ -22,9 +31,6 @@ DllExport DWORD WINAPI Initialize(LPVOID lpParam, HANDLE hMainThreadContinue) {
logging::print<logging::W>("Error: {}", e.what());
}
logging::print<logging::I>("Dalamud.Boot Injectable, (c) 2021 XIVLauncher Contributors");
logging::print<logging::I>("Built at : " __DATE__ "@" __TIME__);
if (bootconfig::is_wait_debugger()) {
logging::print<logging::I>("Waiting for debugger to attach...");
while (!IsDebuggerPresent())
@ -87,6 +93,7 @@ BOOL APIENTRY DllMain(const HMODULE hModule, const DWORD dwReason, LPVOID lpRese
case DLL_PROCESS_DETACH:
xivfixes::apply_all(false);
veh::remove_handler();
//logging::log_file.close();
break;
}
return TRUE;

View file

@ -32,4 +32,10 @@ void logging::print(Level level, const char* s) {
DWORD wr;
WriteFile(GetStdHandle(STD_ERROR_HANDLE), &estr[0], static_cast<DWORD>(estr.size()), &wr, nullptr);
if (log_file.is_open())
{
log_file << estr;
log_file.flush();
}
}

View file

@ -3,10 +3,13 @@
#include <format>
#include <numeric>
#include <string>
#include <fstream>
#include "unicode.h"
namespace logging {
inline std::ofstream log_file;
enum Level : int {
Verbose = 0,
V = 0,