Skip to content

Commit 63858d9

Browse files
committed
Move XRD debug settings to copy shell command
To avoid interference of ALIENPY_DEBUG and XRD_LOGLEVEL set for CTF copy failures debugging with CCDB fetches from alien, which pollute stdout.
1 parent 0a74715 commit 63858d9

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

Common/Utils/src/FileFetcher.cxx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ bool FileFetcher::copyFile(size_t id)
329329
bool aliencpMode = false;
330330
std::string uuid{};
331331
std::vector<std::string> logsToClean;
332+
std::string dbgset{};
332333
if (mCopyCmd.find("alien") != std::string::npos) {
333334
if (!gGrid && !TGrid::Connect("alien://")) {
334335
LOG(error) << "Copy command refers to alien but connection to Grid failed";
@@ -339,18 +340,18 @@ bool FileFetcher::copyFile(size_t id)
339340
c = '_';
340341
}
341342
}
342-
gSystem->Setenv("ALIENPY_DEBUG", "1");
343-
logsToClean.push_back(fmt::format("log_alienpy_{}.txt", uuid));
344-
gSystem->Setenv("ALIENPY_DEBUG_FILE", logsToClean.back().c_str());
345-
gSystem->Setenv("XRD_LOGLEVEL", "Dump");
346-
logsToClean.push_back(fmt::format("log_xrd_{}.txt", uuid));
347-
gSystem->Setenv("XRD_LOGFILE", logsToClean.back().c_str());
348-
LOGP(info, "debug log files for {}: ALIENPY_DEBUG_FILE={} XRD_LOGFILE={}", mInputFiles[id].getOrigName(),
349-
getenv("ALIENPY_DEBUG_FILE") ? getenv("ALIENPY_DEBUG_FILE") : "",
350-
getenv("XRD_LOGFILE") ? getenv("XRD_LOGFILE") : "");
343+
if (!(getenv("ALIENPY_DEBUG") && std::stoi(getenv("ALIENPY_DEBUG")) == 1)) {
344+
logsToClean.push_back(fmt::format("log_alienpy_{}.txt", uuid));
345+
dbgset += fmt::format("ALIENPY_DEBUG=1 ALIENPY_DEBUG_FILE={} ", logsToClean.back());
346+
}
347+
if (!(getenv("XRD_LOGLEVEL") && strcmp(getenv("XRD_LOGLEVEL"), "Dump") == 0)) {
348+
logsToClean.push_back(fmt::format("log_xrd_{}.txt", uuid));
349+
dbgset += fmt::format("XRD_LOGLEVEL=Dump XRD_LOGFILE={} ", logsToClean.back());
350+
}
351+
LOGP(debug, "debug setting for for {}: {}", mInputFiles[id].getOrigName(), dbgset);
351352
}
352353
auto realCmd = std::regex_replace(std::regex_replace(mCopyCmd, std::regex(R"(\?src)"), mInputFiles[id].getOrigName()), std::regex(R"(\?dst)"), mInputFiles[id].getLocalName());
353-
auto fullCmd = fmt::format(R"(sh -c "{}" >> {} 2>&1)", realCmd, mCopyCmdLogFile);
354+
auto fullCmd = fmt::format(R"(sh -c "{}{}" >> {} 2>&1)", dbgset, realCmd, mCopyCmdLogFile);
354355
LOG(info) << "Executing " << fullCmd;
355356
const auto sysRet = gSystem->Exec(fullCmd.c_str());
356357
if (sysRet != 0) {

0 commit comments

Comments
 (0)