aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-06-19 17:01:01 +0200
committerEelco Dolstra <edolstra@gmail.com>2017-06-19 18:51:32 +0200
commit00aa7c6705c073aab8b24ae945ea9a09d5d256aa (patch)
treedae4358695a6982c69e0b03b8de308c3a53e275d
parent1888f7889b107ecbca7ad47f3a1132c32a17d227 (diff)
Show aws-sdk-cpp log messages
-rw-r--r--src/libstore/s3-binary-cache-store.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libstore/s3-binary-cache-store.cc b/src/libstore/s3-binary-cache-store.cc
index fb36dbc7b..39d98cd61 100644
--- a/src/libstore/s3-binary-cache-store.cc
+++ b/src/libstore/s3-binary-cache-store.cc
@@ -12,6 +12,8 @@
#include <aws/core/Aws.h>
#include <aws/core/client/ClientConfiguration.h>
#include <aws/core/client/DefaultRetryStrategy.h>
+#include <aws/core/utils/logging/FormattedLogSystem.h>
+#include <aws/core/utils/logging/LogMacros.h>
#include <aws/s3/S3Client.h>
#include <aws/s3/model/CreateBucketRequest.h>
#include <aws/s3/model/GetBucketLocationRequest.h>
@@ -41,6 +43,16 @@ R && checkAws(const FormatOrString & fs, Aws::Utils::Outcome<R, E> && outcome)
return outcome.GetResultWithOwnership();
}
+class AwsLogger : public Aws::Utils::Logging::FormattedLogSystem
+{
+ using Aws::Utils::Logging::FormattedLogSystem::FormattedLogSystem;
+
+ void ProcessFormattedStatement(Aws::String && statement) override
+ {
+ debug("AWS: %s", chomp(statement));
+ }
+};
+
static void initAWS()
{
static std::once_flag flag;
@@ -51,6 +63,16 @@ static void initAWS()
shared.cc), so don't let aws-sdk-cpp override it. */
options.cryptoOptions.initAndCleanupOpenSSL = false;
+ if (verbosity >= lvlDebug) {
+ options.loggingOptions.logLevel =
+ verbosity == lvlDebug
+ ? Aws::Utils::Logging::LogLevel::Debug
+ : Aws::Utils::Logging::LogLevel::Trace;
+ options.loggingOptions.logger_create_fn = [options]() {
+ return std::make_shared<AwsLogger>(options.loggingOptions.logLevel);
+ };
+ }
+
Aws::InitAPI(options);
});
}