crash_printer: use multibyte std::string

This commit is contained in:
otavepto 2024-06-29 03:53:23 +03:00
parent 00f1268e31
commit 8208d1541d
3 changed files with 5 additions and 5 deletions

View File

@ -6,7 +6,7 @@
namespace crash_printer { namespace crash_printer {
bool init(const std::wstring &log_file); bool init(const std::string &log_file);
void deinit(); void deinit();

View File

@ -8,7 +8,7 @@
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
std::wstring logs_filepath = L"./crash_test/zxc.txt"; std::string logs_filepath = "./crash_test/zxc.txt";
static LONG WINAPI exception_handler(LPEXCEPTION_POINTERS ex_pointers) static LONG WINAPI exception_handler(LPEXCEPTION_POINTERS ex_pointers)

View File

@ -14,7 +14,7 @@
static LPTOP_LEVEL_EXCEPTION_FILTER originalExceptionFilter = nullptr; static LPTOP_LEVEL_EXCEPTION_FILTER originalExceptionFilter = nullptr;
static std::wstring logs_filepath{}; static std::string logs_filepath{};
static void print_stacktrace(std::ofstream &file, CONTEXT* context) { static void print_stacktrace(std::ofstream &file, CONTEXT* context) {
auto this_proc = GetCurrentProcess(); auto this_proc = GetCurrentProcess();
@ -104,7 +104,7 @@ static void log_exception(LPEXCEPTION_POINTERS ex_pointers)
return; return;
} }
std::ofstream file(std::filesystem::path(logs_filepath), std::ios::app); std::ofstream file(std::filesystem::u8path(logs_filepath), std::ios::out | std::ios::app);
std::string time(common_helpers::get_utc_time()); std::string time(common_helpers::get_utc_time());
common_helpers::write(file, "[" + time + "]"); common_helpers::write(file, "[" + time + "]");
@ -133,7 +133,7 @@ static LONG WINAPI exception_handler(LPEXCEPTION_POINTERS ex_pointers)
} }
bool crash_printer::init(const std::wstring &log_file) bool crash_printer::init(const std::string &log_file)
{ {
logs_filepath = log_file; logs_filepath = log_file;
originalExceptionFilter = SetUnhandledExceptionFilter(exception_handler); originalExceptionFilter = SetUnhandledExceptionFilter(exception_handler);