mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
feat: write Dalamud.Boot logs to dalamud.boot.log
This commit is contained in:
parent
ad4f2db203
commit
a7540d0fef
5 changed files with 39 additions and 14 deletions
|
|
@ -9,9 +9,18 @@ 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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -101,6 +101,19 @@ namespace Dalamud.Injector
|
|||
}
|
||||
}
|
||||
|
||||
private static string GetLogPath(string filename)
|
||||
{
|
||||
var baseDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
|
||||
#if DEBUG
|
||||
var logPath = Path.Combine(baseDirectory, $"{filename}.log");
|
||||
#else
|
||||
var logPath = Path.Combine(baseDirectory, "..", "..", "..", "dalamud.injector.log");
|
||||
#endif
|
||||
|
||||
return logPath;
|
||||
}
|
||||
|
||||
private static void Init(List<string> args)
|
||||
{
|
||||
InitUnhandledException(args);
|
||||
|
|
@ -161,14 +174,6 @@ namespace Dalamud.Injector
|
|||
|
||||
private static void InitLogging()
|
||||
{
|
||||
var baseDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
|
||||
#if DEBUG
|
||||
var logPath = Path.Combine(baseDirectory, "dalamud.injector.log");
|
||||
#else
|
||||
var logPath = Path.Combine(baseDirectory, "..", "..", "..", "dalamud.injector.log");
|
||||
#endif
|
||||
|
||||
var levelSwitch = new LoggingLevelSwitch();
|
||||
|
||||
#if DEBUG
|
||||
|
|
@ -177,6 +182,10 @@ namespace Dalamud.Injector
|
|||
levelSwitch.MinimumLevel = LogEventLevel.Information;
|
||||
#endif
|
||||
|
||||
var logPath = GetLogPath("dalamud.injector");
|
||||
|
||||
Environment.SetEnvironmentVariable("DALAMUD_BOOT_LOGFILE", GetLogPath("dalamud.boot"));
|
||||
|
||||
CullLogFile(logPath, 1 * 1024 * 1024);
|
||||
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
|
|
|
|||
|
|
@ -73,9 +73,9 @@ int InitializeClrAndGetEntryPoint(
|
|||
|
||||
// =========================================================================== //
|
||||
|
||||
logging::print<logging::I>(L"with dotnet_path: %s", dotnet_path);
|
||||
logging::print<logging::I>(L"with config_path: %s", runtimeconfig_path.c_str());
|
||||
logging::print<logging::I>(L"with module_path: %s", module_path.c_str());
|
||||
logging::print<logging::I>(L"with dotnet_path: {}", dotnet_path);
|
||||
logging::print<logging::I>(L"with config_path: {}", runtimeconfig_path.c_str());
|
||||
logging::print<logging::I>(L"with module_path: {}", module_path.c_str());
|
||||
|
||||
if (!std::filesystem::exists(dotnet_path))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue