@@ -493,21 +493,25 @@ void CCDBDownloader::transferFinished(CURL* easy_handle, CURLcode curlCode)
493493 curl_easy_getinfo (easy_handle, CURLINFO_EFFECTIVE_URL, &url);
494494 LOG (debug) << " Transfer for " << url << " finished with code " << httpCode << " \n " ;
495495
496+ std::string currentHost = requestData->hosts [performData->hostInd ];
497+ std::string loggingMessage = prepareLogMessage (currentHost, requestData->userAgent , requestData->path , requestData->timestamp , requestData->headers , httpCode);
498+
496499 // Get alternative locations for the same host
497500 auto locations = getLocations (&(requestData->hoPair .header ));
498501
499502 // React to received http code
500- if (404 == httpCode) {
501- LOG (error) << " Requested resource does not exist: " << url;
502- } else if (304 == httpCode) {
503- LOGP (debug, " Object exists but I am not serving it since it's already in your possession" );
504- contentRetrieved = true ;
505- } else if (300 <= httpCode && httpCode < 400 && performData->locInd < locations.size ()) {
506- followRedirect (performData, easy_handle, locations, rescheduled, contentRetrieved);
507- } else if (200 <= httpCode && httpCode < 300 ) {
508- contentRetrieved = true ;
503+ if (200 <= httpCode && httpCode < 400 ) {
504+ LOG (debug) << loggingMessage;
505+ if (304 == httpCode) {
506+ LOGP (debug, " Object exists but I am not serving it since it's already in your possession" );
507+ contentRetrieved = true ;
508+ } else if (300 <= httpCode && httpCode < 400 && performData->locInd < locations.size ()) {
509+ followRedirect (performData, easy_handle, locations, rescheduled, contentRetrieved);
510+ } else if (200 <= httpCode && httpCode < 300 ) {
511+ contentRetrieved = true ;
512+ }
509513 } else {
510- LOG (error) << " Error in fetching object " << url << " , curl response code: " << httpCode ;
514+ LOG (error) << loggingMessage ;
511515 }
512516
513517 // Check if content was retrieved, or scheduled to be retrieved
@@ -694,4 +698,21 @@ void CCDBDownloader::asynchSchedule(CURL* handle, size_t* requestCounter)
694698 // return codeVector;
695699}
696700
701+ std::string CCDBDownloader::prepareLogMessage (std::string host_url, std::string userAgent, const std::string& path, long ts, const std::map<std::string, std::string>* headers, long httpCode) const
702+ {
703+ std::string upath{path};
704+ if (headers) {
705+ auto ent = headers->find (" Valid-From" );
706+ if (ent != headers->end ()) {
707+ upath += " /" + ent->second ;
708+ }
709+ ent = headers->find (" ETag" );
710+ if (ent != headers->end ()) {
711+ upath += " /" + ent->second ;
712+ }
713+ }
714+ upath.erase (remove (upath.begin (), upath.end (), ' \" ' ), upath.end ());
715+ return fmt::format (" CcdbDownloader finished transfer {}{}{} for {} (agent_id: {}) with http code: {}" , host_url, (host_url.back () == ' /' ) ? " " : " /" , upath, (ts < 0 ) ? getCurrentTimestamp () : ts, userAgent, httpCode);
716+ }
717+
697718} // namespace o2
0 commit comments