Useless logging during RdbmsCatalogue::reserveDiskSpace and RdbmsCatalogue::releaseDiskSpace
In the method RdbmsCatalogue::reserveDiskSpace, the parameters that we want to log do not appear in the log message.
Ex:
Dec 7 13:43:36.340044 tpsrv01 cta-taped: LVL="DEBUG" PID="496" TID="496" MSG="In RetrieveMount::reserveDiskSpace(): reservation request content." thread="MainThread" tapeDrive="VDSTK61" mountId="3"
Dec 7 13:43:36.341586 tpsrv01 cta-taped: LVL="DEBUG" PID="496" TID="496" MSG="In RetrieveMount::reserveDiskSpace(): state before reservation." thread="MainThread" tapeDrive="VDSTK61" mountId="3"
Dec 7 13:43:36.346431 tpsrv01 cta-taped: LVL="DEBUG" PID="496" TID="496" MSG="In RetrieveMount::reserveDiskSpace(): state after reservation." thread="MainThread" tapeDrive="VDSTK61" mountId="3"
This happens because the code creates the ScopedParamContainer
inside a lambda function, which then goes out of scope when that function exits:
void RdbmsCatalogue::reserveDiskSpace(const std::string& driveName, const DiskSpaceReservationRequest& diskSpaceReservation, log::LogContext & lc) {
if (diskSpaceReservation.empty()) return;
// Try add our reservation to the drive status.
auto setLogParam = [&lc](const std::string& diskSystemName, uint64_t bytes) {
log::ScopedParamContainer params(lc);
params.add("diskSystem", diskSystemName)
.add("reservation", bytes);
};
std::string diskSystemName = diskSpaceReservation.begin()->first;
uint64_t bytes = diskSpaceReservation.begin()->second;
setLogParam(diskSystemName, bytes);
lc.log(log::DEBUG, "In RetrieveMount::reserveDiskSpace(): reservation request content.");
std::tie(diskSystemName, bytes) = getDiskSpaceReservation(driveName);
setLogParam(diskSystemName, bytes);
lc.log(log::DEBUG, "In RetrieveMount::reserveDiskSpace(): state before reservation.");
addDiskSpaceReservation(driveName, diskSpaceReservation.begin()->first,
diskSpaceReservation.begin()->second);
std::tie(diskSystemName, bytes) = getDiskSpaceReservation(driveName);
setLogParam(diskSystemName, bytes);
lc.log(log::DEBUG, "In RetrieveMount::reserveDiskSpace(): state after reservation.");
}
Edited by Miguel Barros