diff --git a/common/log/LogContext.cpp b/common/log/LogContext.cpp index 258cc5655ecadae51d28cf0bb4a349fbf47ac4f1..335d3c0ff9ff4ac150cfd02268d31e5eee2c1ccc 100644 --- a/common/log/LogContext.cpp +++ b/common/log/LogContext.cpp @@ -41,6 +41,17 @@ void LogContext::pushOrReplace(const Param& param) throw() { } } +void LogContext::moveToTheEndIfPresent(const std::string& paramName) throw() { + ParamNameMatcher match(paramName); + std::list<Param>::iterator i = + std::find_if(m_params.begin(), m_params.end(), match); + if (i != m_params.end()) { + const Param param(paramName,i->getValue()); + m_params.erase(i); + m_params.push_back(param); + } +} + void LogContext::erase(const std::string& paramName) throw() { ParamNameMatcher match(paramName); m_params.erase(std::remove_if(m_params.begin(), m_params.end(), match), m_params.end()); diff --git a/common/log/LogContext.hpp b/common/log/LogContext.hpp index 09b13e0814071b59cf57393d13c790a7ab135227..92be7db1151b9f02a52c96bf42f829d626ebd1e2 100644 --- a/common/log/LogContext.hpp +++ b/common/log/LogContext.hpp @@ -59,6 +59,14 @@ public: * @param param */ void pushOrReplace(const Param & param) throw(); + + /** + * Move a parameter with a given name to the end of the container it it + * present. + * + * @param paramName The name of the parameter to check and move. + */ + void moveToTheEndIfPresent(const std::string ¶mName) throw(); /** * Removes a parameter from the list. diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp b/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp index e0ccfbf1ce6a3389b4909f9d4100289f974e2997..563bb7cf16df62618d7275275c654697c39f387e 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp @@ -394,6 +394,7 @@ void castor::tape::tapeserver::daemon::TapeReadSingleThread::logWithStat( /1000/1000/m_stats.totalTime:0.0) .add("driveTransferSpeedMBps", m_stats.totalTime?1.0*(m_stats.dataVolume+m_stats.headerVolume) /1000/1000/m_stats.totalTime:0.0); + m_logContext.moveToTheEndIfPresent("status"); m_logContext.log(level,msg); } diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp index 07e153302017cccc32659bf554c70747fed05e98..c4bfb0452b4a76829b46a04dcffa66f005615505 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp @@ -529,6 +529,7 @@ int level,const std::string& msg, cta::log::ScopedParamContainer& params){ /1000/1000/m_stats.totalTime:0.0) .add("driveTransferSpeedMBps", m_stats.totalTime?1.0*(m_stats.dataVolume+m_stats.headerVolume) /1000/1000/m_stats.totalTime:0.0); + m_logContext.moveToTheEndIfPresent("status"); m_logContext.log(level, msg); } diff --git a/tapeserver/daemon/DriveHandler.cpp b/tapeserver/daemon/DriveHandler.cpp index 13c2d121c04971eaba80e87b03b59e42a5200949..caa1ba8170b463a147cc15b067aaeebabdd0284f 100644 --- a/tapeserver/daemon/DriveHandler.cpp +++ b/tapeserver/daemon/DriveHandler.cpp @@ -764,6 +764,7 @@ SubprocessHandler::ProcessingStatus DriveHandler::processSigChild() { m_sessionEndContext.pushOrReplace({"status", "failure"}); } // In all cases we log the end of the session. + m_sessionEndContext.moveToTheEndIfPresent("status"); m_sessionEndContext.log(cta::log::INFO, "Tape session finished"); m_sessionEndContext.clear(); // And record we do not have a process anymore.