Skip to content

Commit

Permalink
Verbose logging and tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
fpetrini15 committed Oct 14, 2024
1 parent 189b8e3 commit 974368a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/backend_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ TritonBackend::Create(
auto it = find_if(
backend_cmdline_config.begin(), backend_cmdline_config.end(),
[](const std::pair<std::string, std::string>& config_pair) {
return config_pair.first == "additional-dependency-dir";
return config_pair.first == "additional-dependency-dirs";
});
std::string additional_dependency_dir_path;
if (it != backend_cmdline_config.end()) {
Expand Down
41 changes: 26 additions & 15 deletions src/shared_library.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ SharedLibrary::AddAdditionalDependencyDir(
} else {
return Status(Status::Code::INTERNAL, "PATH variable is empty");
}
std::wcout << "Before Add: " << original_path << std::endl;

LOG_VERBOSE(1) << "Environment before extending PATH: "
<< std::string(original_path.begin(), original_path.end());

std::wstring updated_path_value =
std::wstring(additional_path.begin(), additional_path.end());
Expand All @@ -276,14 +278,21 @@ SharedLibrary::AddAdditionalDependencyDir(
"failed to append user-provided directory to PATH " + errstr);
}

// TODO: Delete -- just for sanity purposes
std::wstring path_after;
len = GetEnvironmentVariableW(PATH.c_str(), NULL, 0);
if (len > 0) {
path_after.resize(len);
GetEnvironmentVariableW(PATH.c_str(), &path_after[0], len);
if (LOG_VERBOSE_IS_ON(1)) {
std::wstring path_after;
len = GetEnvironmentVariableW(PATH.c_str(), NULL, 0);
if (len > 0) {
path_after.resize(len);
GetEnvironmentVariableW(PATH.c_str(), &path_after[0], len);
}
LOG_VERBOSE(1) << "Environment after extending PATH: "
<< std::string(path_after.begin(), path_after.end());
}
std::wcout << "After Add: " << path_after << std::endl;
#else
LOG_WARNING
<< "The parameter \"additional-dependency-dirs\" has been specified but "
"is not supported for Linux. It is currently a Windows-only feature. "
"No change to the environment will take effect.";
#endif
return Status::Success;
}
Expand All @@ -307,14 +316,16 @@ SharedLibrary::RemoveAdditionalDependencyDir(std::wstring& original_path)
"failed to restore PATH to its original configuration " + errstr);
}

// TODO: Delete -- just for sanity purposes
std::wstring path_after;
DWORD len = GetEnvironmentVariableW(PATH.c_str(), NULL, 0);
if (len > 0) {
path_after.resize(len);
GetEnvironmentVariableW(PATH.c_str(), &path_after[0], len);
if (LOG_VERBOSE_IS_ON(1)) {
std::wstring path_after;
DWORD len = GetEnvironmentVariableW(PATH.c_str(), NULL, 0);
if (len > 0) {
path_after.resize(len);
GetEnvironmentVariableW(PATH.c_str(), &path_after[0], len);
}
LOG_VERBOSE(1) << "Environment after restoring PATH: "
<< std::string(path_after.begin(), path_after.end());
}
std::wcout << "After Restore: " << path_after << std::endl;
#endif
return Status::Success;
}
Expand Down

0 comments on commit 974368a

Please sign in to comment.