Skip to content
This repository has been archived by the owner on Jun 18, 2022. It is now read-only.

Commit

Permalink
add more logging to cloud uploading
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Verstraeten committed May 21, 2018
1 parent 011c3cb commit 1bf01be
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
25 changes: 22 additions & 3 deletions src/kerberos/cloud/S3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ namespace kerberos
// ----------------------------------------------
// Before send the headers, we need to sort them!

BINFO << "S3: Sending new file to cloud.";

std::sort(canonicalizedAmzHeaders.begin(), canonicalizedAmzHeaders.end());

for(int i = 0; i < canonicalizedAmzHeaders.size(); i++)
{
LINFO << canonicalizedAmzHeaders[i];
BINFO << "S3 - File info: " << canonicalizedAmzHeaders[i];
}

return canonicalizedAmzHeaders;
Expand Down Expand Up @@ -252,6 +254,8 @@ namespace kerberos
// Check if file really was uploaded.
// We'll query the S3 bucket and check if it's there.

BINFO << "S3: file succesfully uploaded.";

return doesExist(pathToImage);

}
Expand All @@ -260,9 +264,17 @@ namespace kerberos
// User is not allowed to push with these credentials.
// We remove the symbol.

BINFO << "S3: permission denied, your file wasn't uploaded.";

return true;

}

else {

BINFO << "S3: file was not uploaded, something went wrong. Please check if you internet connectivity works.";

}
}

return false;
Expand Down Expand Up @@ -337,15 +349,22 @@ namespace kerberos
curl_easy_setopt(curlHandle, CURLOPT_WRITEFUNCTION, write);
curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, &output);

BINFO << "S3: checking is exists in bucket.";
BINFO << "S3: checking if file exists in bucket.";

result = curl_easy_perform(curlHandle); //Perform
long http_code = 0;
curl_easy_getinfo (curlHandle, CURLINFO_RESPONSE_CODE, &http_code);
curl_easy_cleanup(curlHandle);
curl_slist_free_all(httpHeaders);

return (http_code == 200 && result != CURLE_ABORTED_BY_CALLBACK);
if(http_code == 200 && result != CURLE_ABORTED_BY_CALLBACK)
{
BINFO << "S3: file exists in bucket, succesfully uploaded.";
return true;
}

BINFO << "S3: file wasn't uploaded, something went wrong.";
return false;
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int main(int argc, char** argv)
config.setAll(easyloggingpp::ConfigurationType::ToFile, "true");
std::string logFile = (helper::getValueByKey(parameters, "log")) ?: LOG_PATH;
config.setAll(easyloggingpp::ConfigurationType::Filename, logFile);
config.setAll(easyloggingpp::ConfigurationType::RollOutSize, "100000"); // 100MB
config.setAll(easyloggingpp::ConfigurationType::RollOutSize, "2048"); // 2KB
easyloggingpp::Loggers::reconfigureAllLoggers(config);

LINFO << "Logging is written to: " + logFile;
Expand Down

0 comments on commit 1bf01be

Please sign in to comment.