Skip to content

Commit e9d94b1

Browse files
authored
Merge pull request #2363 from kbenzie/benie/windows-improve-adapter-load-logging
Improve logging of loading adapters on Windows
2 parents 2f479e0 + da5befe commit e9d94b1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

source/common/windows/ur_lib_loader.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void LibLoader::freeAdapterLibrary(HMODULE handle) {
1717
BOOL res = FreeLibrary(handle);
1818
if (!res) {
1919
logger::error(
20-
"Failed to unload the library with the handle at address {}",
20+
"Failed to unload the library with the handle at address 0x{}",
2121
handle);
2222
} else {
2323
logger::info("unloaded adapter 0x{}", handle);
@@ -27,10 +27,14 @@ void LibLoader::freeAdapterLibrary(HMODULE handle) {
2727

2828
std::unique_ptr<HMODULE, LibLoader::lib_dtor>
2929
LibLoader::loadAdapterLibrary(const char *name) {
30-
auto handle = std::unique_ptr<HMODULE, LibLoader::lib_dtor>(
31-
LoadLibraryExA(name, nullptr, 0));
32-
logger::info("loaded adapter 0x{} ({})", handle, name);
33-
return handle;
30+
if (HMODULE handle = LoadLibraryExA(name, nullptr, 0)) {
31+
logger::info("loaded adapter 0x{}: {}", handle, name);
32+
return std::unique_ptr<HMODULE, LibLoader::lib_dtor>{handle};
33+
} else {
34+
logger::debug("loading adapter failed with error {}: {}",
35+
GetLastError(), name);
36+
}
37+
return nullptr;
3438
}
3539

3640
void *LibLoader::getFunctionPtr(HMODULE handle, const char *func_name) {

0 commit comments

Comments
 (0)