mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Enable UWP logging in release builds with FirefoxRealityLogStdout env var.
This commit is contained in:
parent
d6ae56b75e
commit
a5970ab9c7
1 changed files with 24 additions and 14 deletions
|
@ -161,21 +161,31 @@ Servo::Servo(hstring url, hstring args, GLsizei width, GLsizei height,
|
||||||
|
|
||||||
sServo = this; // FIXME;
|
sServo = this; // FIXME;
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifndef _DEBUG
|
||||||
|
char buffer[1024];
|
||||||
|
bool logToFile = GetEnvironmentVariableA("FirefoxRealityLogStdout", buffer,
|
||||||
|
sizeof(buffer)) != 0;
|
||||||
|
#else
|
||||||
|
bool logToFile = true;
|
||||||
|
#endif
|
||||||
|
if (logToFile) {
|
||||||
auto current = winrt::Windows::Storage::ApplicationData::Current();
|
auto current = winrt::Windows::Storage::ApplicationData::Current();
|
||||||
auto filePath = std::wstring(current.LocalFolder().Path()) + L"\\stdout.txt";
|
auto filePath =
|
||||||
|
std::wstring(current.LocalFolder().Path()) + L"\\stdout.txt";
|
||||||
sLogHandle =
|
sLogHandle =
|
||||||
CreateFile2(filePath.c_str(), GENERIC_WRITE, 0, CREATE_ALWAYS, nullptr);
|
CreateFile2(filePath.c_str(), GENERIC_WRITE, 0, CREATE_ALWAYS, nullptr);
|
||||||
if (sLogHandle == INVALID_HANDLE_VALUE)
|
if (sLogHandle == INVALID_HANDLE_VALUE) {
|
||||||
throw std::runtime_error("Failed to open the log file: error code " +
|
throw std::runtime_error("Failed to open the log file: error code " +
|
||||||
std::to_string(GetLastError()));
|
std::to_string(GetLastError()));
|
||||||
|
}
|
||||||
|
|
||||||
if (SetFilePointer(sLogHandle, 0, nullptr, FILE_END) ==
|
if (SetFilePointer(sLogHandle, 0, nullptr, FILE_END) ==
|
||||||
INVALID_SET_FILE_POINTER)
|
INVALID_SET_FILE_POINTER) {
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"Failed to set file pointer to the end of file: error code " +
|
"Failed to set file pointer to the end of file: error code " +
|
||||||
std::to_string(GetLastError()));
|
std::to_string(GetLastError()));
|
||||||
#endif
|
}
|
||||||
|
}
|
||||||
|
|
||||||
capi::CHostCallbacks c;
|
capi::CHostCallbacks c;
|
||||||
c.on_load_started = &on_load_started;
|
c.on_load_started = &on_load_started;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue