aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging
diff options
context:
space:
mode:
authornalpp <nalpp@yandex-team.ru>2022-02-10 16:46:46 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:46 +0300
commit30d1ef3941e0dc835be7609de5ebee66958f215a (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging
parent87f3eb38999df2d3c1cb77f8ffb9c52ec9c516fb (diff)
downloadydb-30d1ef3941e0dc835be7609de5ebee66958f215a.tar.gz
Restoring authorship annotation for <nalpp@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging')
-rw-r--r--contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/AWSLogging.cpp94
-rw-r--r--contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/ConsoleLogSystem.cpp26
-rw-r--r--contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/DefaultLogSystem.cpp210
-rw-r--r--contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/FormattedLogSystem.cpp186
-rw-r--r--contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/LogLevel.cpp80
5 files changed, 298 insertions, 298 deletions
diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/AWSLogging.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/AWSLogging.cpp
index 82a49da4fb..fc1b9fcc2e 100644
--- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/AWSLogging.cpp
+++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/AWSLogging.cpp
@@ -2,50 +2,50 @@
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
-
-
-#include <aws/core/utils/logging/AWSLogging.h>
-#include <aws/core/utils/logging/LogSystemInterface.h>
-#include <aws/core/utils/memory/stl/AWSStack.h>
-
-#include <memory>
-
-using namespace Aws::Utils;
-using namespace Aws::Utils::Logging;
-
-static std::shared_ptr<LogSystemInterface> AWSLogSystem(nullptr);
-static std::shared_ptr<LogSystemInterface> OldLogger(nullptr);
-
-namespace Aws
-{
-namespace Utils
-{
-namespace Logging {
-
-void InitializeAWSLogging(const std::shared_ptr<LogSystemInterface> &logSystem) {
- AWSLogSystem = logSystem;
-}
-
-void ShutdownAWSLogging(void) {
- InitializeAWSLogging(nullptr);
-}
-
-LogSystemInterface *GetLogSystem() {
- return AWSLogSystem.get();
-}
-
-void PushLogger(const std::shared_ptr<LogSystemInterface> &logSystem)
-{
- OldLogger = AWSLogSystem;
- AWSLogSystem = logSystem;
-}
-
-void PopLogger()
-{
- AWSLogSystem = OldLogger;
- OldLogger = nullptr;
-}
-
-} // namespace Logging
-} // namespace Utils
-} // namespace Aws \ No newline at end of file
+
+
+#include <aws/core/utils/logging/AWSLogging.h>
+#include <aws/core/utils/logging/LogSystemInterface.h>
+#include <aws/core/utils/memory/stl/AWSStack.h>
+
+#include <memory>
+
+using namespace Aws::Utils;
+using namespace Aws::Utils::Logging;
+
+static std::shared_ptr<LogSystemInterface> AWSLogSystem(nullptr);
+static std::shared_ptr<LogSystemInterface> OldLogger(nullptr);
+
+namespace Aws
+{
+namespace Utils
+{
+namespace Logging {
+
+void InitializeAWSLogging(const std::shared_ptr<LogSystemInterface> &logSystem) {
+ AWSLogSystem = logSystem;
+}
+
+void ShutdownAWSLogging(void) {
+ InitializeAWSLogging(nullptr);
+}
+
+LogSystemInterface *GetLogSystem() {
+ return AWSLogSystem.get();
+}
+
+void PushLogger(const std::shared_ptr<LogSystemInterface> &logSystem)
+{
+ OldLogger = AWSLogSystem;
+ AWSLogSystem = logSystem;
+}
+
+void PopLogger()
+{
+ AWSLogSystem = OldLogger;
+ OldLogger = nullptr;
+}
+
+} // namespace Logging
+} // namespace Utils
+} // namespace Aws \ No newline at end of file
diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/ConsoleLogSystem.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/ConsoleLogSystem.cpp
index ac7cbba8c0..dec7cef82f 100644
--- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/ConsoleLogSystem.cpp
+++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/ConsoleLogSystem.cpp
@@ -2,19 +2,19 @@
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
-
-
-#include <aws/core/utils/logging/ConsoleLogSystem.h>
-
-#include <iostream>
-
-using namespace Aws::Utils;
-using namespace Aws::Utils::Logging;
-
-void ConsoleLogSystem::ProcessFormattedStatement(Aws::String&& statement)
-{
- std::cout << statement;
-}
+
+
+#include <aws/core/utils/logging/ConsoleLogSystem.h>
+
+#include <iostream>
+
+using namespace Aws::Utils;
+using namespace Aws::Utils::Logging;
+
+void ConsoleLogSystem::ProcessFormattedStatement(Aws::String&& statement)
+{
+ std::cout << statement;
+}
void ConsoleLogSystem::Flush()
{
diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/DefaultLogSystem.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/DefaultLogSystem.cpp
index 065dc9b037..7286bb6378 100644
--- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/DefaultLogSystem.cpp
+++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/DefaultLogSystem.cpp
@@ -2,114 +2,114 @@
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
-
-
-#include <aws/core/utils/logging/DefaultLogSystem.h>
-
-#include <aws/core/utils/DateTime.h>
-#include <aws/core/utils/memory/stl/AWSVector.h>
-
-#include <fstream>
-
-using namespace Aws::Utils;
-using namespace Aws::Utils::Logging;
-
-static const char* AllocationTag = "DefaultLogSystem";
-static const int BUFFERED_MSG_COUNT = 100;
-
+
+
+#include <aws/core/utils/logging/DefaultLogSystem.h>
+
+#include <aws/core/utils/DateTime.h>
+#include <aws/core/utils/memory/stl/AWSVector.h>
+
+#include <fstream>
+
+using namespace Aws::Utils;
+using namespace Aws::Utils::Logging;
+
+static const char* AllocationTag = "DefaultLogSystem";
+static const int BUFFERED_MSG_COUNT = 100;
+
static std::shared_ptr<Aws::OFStream> MakeDefaultLogFile(const Aws::String& filenamePrefix)
-{
- Aws::String newFileName = filenamePrefix + DateTime::CalculateGmtTimestampAsString("%Y-%m-%d-%H") + ".log";
- return Aws::MakeShared<Aws::OFStream>(AllocationTag, newFileName.c_str(), Aws::OFStream::out | Aws::OFStream::app);
-}
-
-static void LogThread(DefaultLogSystem::LogSynchronizationData* syncData, const std::shared_ptr<Aws::OStream>& logFile, const Aws::String& filenamePrefix, bool rollLog)
-{
- // localtime requires access to env. variables to get Timezone, which is not thread-safe
- int32_t lastRolledHour = DateTime::Now().GetHour(false /*localtime*/);
- std::shared_ptr<Aws::OStream> log = logFile;
-
- for(;;)
- {
- std::unique_lock<std::mutex> locker(syncData->m_logQueueMutex);
+{
+ Aws::String newFileName = filenamePrefix + DateTime::CalculateGmtTimestampAsString("%Y-%m-%d-%H") + ".log";
+ return Aws::MakeShared<Aws::OFStream>(AllocationTag, newFileName.c_str(), Aws::OFStream::out | Aws::OFStream::app);
+}
+
+static void LogThread(DefaultLogSystem::LogSynchronizationData* syncData, const std::shared_ptr<Aws::OStream>& logFile, const Aws::String& filenamePrefix, bool rollLog)
+{
+ // localtime requires access to env. variables to get Timezone, which is not thread-safe
+ int32_t lastRolledHour = DateTime::Now().GetHour(false /*localtime*/);
+ std::shared_ptr<Aws::OStream> log = logFile;
+
+ for(;;)
+ {
+ std::unique_lock<std::mutex> locker(syncData->m_logQueueMutex);
syncData->m_queueSignal.wait(locker, [&](){ return syncData->m_stopLogging == true || syncData->m_queuedLogMessages.size() > 0; } );
-
- if (syncData->m_stopLogging && syncData->m_queuedLogMessages.size() == 0)
- {
- break;
- }
-
- Aws::Vector<Aws::String> messages(std::move(syncData->m_queuedLogMessages));
- syncData->m_queuedLogMessages.reserve(BUFFERED_MSG_COUNT);
-
- locker.unlock();
-
- if (messages.size() > 0)
- {
- if (rollLog)
- {
- // localtime requires access to env. variables to get Timezone, which is not thread-safe
- int32_t currentHour = DateTime::Now().GetHour(false /*localtime*/);
- if (currentHour != lastRolledHour)
- {
- log = MakeDefaultLogFile(filenamePrefix);
- lastRolledHour = currentHour;
- }
- }
-
- for (const auto& msg : messages)
- {
- (*log) << msg;
- }
-
- log->flush();
- }
- }
-}
-
-DefaultLogSystem::DefaultLogSystem(LogLevel logLevel, const std::shared_ptr<Aws::OStream>& logFile) :
- Base(logLevel),
- m_syncData(),
- m_loggingThread()
-{
- m_loggingThread = std::thread(LogThread, &m_syncData, logFile, "", false);
-}
-
-DefaultLogSystem::DefaultLogSystem(LogLevel logLevel, const Aws::String& filenamePrefix) :
- Base(logLevel),
- m_syncData(),
- m_loggingThread()
-{
- m_loggingThread = std::thread(LogThread, &m_syncData, MakeDefaultLogFile(filenamePrefix), filenamePrefix, true);
-}
-
-DefaultLogSystem::~DefaultLogSystem()
-{
- {
- std::lock_guard<std::mutex> locker(m_syncData.m_logQueueMutex);
+
+ if (syncData->m_stopLogging && syncData->m_queuedLogMessages.size() == 0)
+ {
+ break;
+ }
+
+ Aws::Vector<Aws::String> messages(std::move(syncData->m_queuedLogMessages));
+ syncData->m_queuedLogMessages.reserve(BUFFERED_MSG_COUNT);
+
+ locker.unlock();
+
+ if (messages.size() > 0)
+ {
+ if (rollLog)
+ {
+ // localtime requires access to env. variables to get Timezone, which is not thread-safe
+ int32_t currentHour = DateTime::Now().GetHour(false /*localtime*/);
+ if (currentHour != lastRolledHour)
+ {
+ log = MakeDefaultLogFile(filenamePrefix);
+ lastRolledHour = currentHour;
+ }
+ }
+
+ for (const auto& msg : messages)
+ {
+ (*log) << msg;
+ }
+
+ log->flush();
+ }
+ }
+}
+
+DefaultLogSystem::DefaultLogSystem(LogLevel logLevel, const std::shared_ptr<Aws::OStream>& logFile) :
+ Base(logLevel),
+ m_syncData(),
+ m_loggingThread()
+{
+ m_loggingThread = std::thread(LogThread, &m_syncData, logFile, "", false);
+}
+
+DefaultLogSystem::DefaultLogSystem(LogLevel logLevel, const Aws::String& filenamePrefix) :
+ Base(logLevel),
+ m_syncData(),
+ m_loggingThread()
+{
+ m_loggingThread = std::thread(LogThread, &m_syncData, MakeDefaultLogFile(filenamePrefix), filenamePrefix, true);
+}
+
+DefaultLogSystem::~DefaultLogSystem()
+{
+ {
+ std::lock_guard<std::mutex> locker(m_syncData.m_logQueueMutex);
m_syncData.m_stopLogging = true;
- }
-
- m_syncData.m_queueSignal.notify_one();
-
- m_loggingThread.join();
-}
-
-void DefaultLogSystem::ProcessFormattedStatement(Aws::String&& statement)
-{
- std::unique_lock<std::mutex> locker(m_syncData.m_logQueueMutex);
- m_syncData.m_queuedLogMessages.emplace_back(std::move(statement));
- if(m_syncData.m_queuedLogMessages.size() >= BUFFERED_MSG_COUNT)
- {
- locker.unlock();
- m_syncData.m_queueSignal.notify_one();
- }
- else
- {
- locker.unlock();
- }
-}
-
+ }
+
+ m_syncData.m_queueSignal.notify_one();
+
+ m_loggingThread.join();
+}
+
+void DefaultLogSystem::ProcessFormattedStatement(Aws::String&& statement)
+{
+ std::unique_lock<std::mutex> locker(m_syncData.m_logQueueMutex);
+ m_syncData.m_queuedLogMessages.emplace_back(std::move(statement));
+ if(m_syncData.m_queuedLogMessages.size() >= BUFFERED_MSG_COUNT)
+ {
+ locker.unlock();
+ m_syncData.m_queueSignal.notify_one();
+ }
+ else
+ {
+ locker.unlock();
+ }
+}
+
void DefaultLogSystem::Flush()
{
m_syncData.m_queueSignal.notify_one();
diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/FormattedLogSystem.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/FormattedLogSystem.cpp
index 8cca6d89a8..41c4d7e09c 100644
--- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/FormattedLogSystem.cpp
+++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/FormattedLogSystem.cpp
@@ -2,98 +2,98 @@
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
-
-
-#include <aws/core/utils/logging/FormattedLogSystem.h>
-
-#include <aws/core/utils/DateTime.h>
-#include <aws/core/utils/Array.h>
-
-#include <fstream>
-#include <cstdarg>
-#include <stdio.h>
-#include <thread>
-
-using namespace Aws::Utils;
-using namespace Aws::Utils::Logging;
-
-static Aws::String CreateLogPrefixLine(LogLevel logLevel, const char* tag)
-{
- Aws::StringStream ss;
-
- switch(logLevel)
- {
- case LogLevel::Error:
- ss << "[ERROR] ";
- break;
-
- case LogLevel::Fatal:
- ss << "[FATAL] ";
- break;
-
- case LogLevel::Warn:
- ss << "[WARN] ";
- break;
-
- case LogLevel::Info:
- ss << "[INFO] ";
- break;
-
- case LogLevel::Debug:
- ss << "[DEBUG] ";
- break;
-
- case LogLevel::Trace:
- ss << "[TRACE] ";
- break;
-
- default:
- ss << "[UNKOWN] ";
- break;
- }
-
+
+
+#include <aws/core/utils/logging/FormattedLogSystem.h>
+
+#include <aws/core/utils/DateTime.h>
+#include <aws/core/utils/Array.h>
+
+#include <fstream>
+#include <cstdarg>
+#include <stdio.h>
+#include <thread>
+
+using namespace Aws::Utils;
+using namespace Aws::Utils::Logging;
+
+static Aws::String CreateLogPrefixLine(LogLevel logLevel, const char* tag)
+{
+ Aws::StringStream ss;
+
+ switch(logLevel)
+ {
+ case LogLevel::Error:
+ ss << "[ERROR] ";
+ break;
+
+ case LogLevel::Fatal:
+ ss << "[FATAL] ";
+ break;
+
+ case LogLevel::Warn:
+ ss << "[WARN] ";
+ break;
+
+ case LogLevel::Info:
+ ss << "[INFO] ";
+ break;
+
+ case LogLevel::Debug:
+ ss << "[DEBUG] ";
+ break;
+
+ case LogLevel::Trace:
+ ss << "[TRACE] ";
+ break;
+
+ default:
+ ss << "[UNKOWN] ";
+ break;
+ }
+
ss << DateTime::Now().CalculateGmtTimeWithMsPrecision() << " " << tag << " [" << std::this_thread::get_id() << "] ";
-
- return ss.str();
-}
-
-FormattedLogSystem::FormattedLogSystem(LogLevel logLevel) :
- m_logLevel(logLevel)
-{
-}
-
-void FormattedLogSystem::Log(LogLevel logLevel, const char* tag, const char* formatStr, ...)
-{
- Aws::StringStream ss;
- ss << CreateLogPrefixLine(logLevel, tag);
-
- std::va_list args;
- va_start(args, formatStr);
-
- va_list tmp_args; //unfortunately you cannot consume a va_list twice
- va_copy(tmp_args, args); //so we have to copy it
- #ifdef WIN32
- const int requiredLength = _vscprintf(formatStr, tmp_args) + 1;
- #else
- const int requiredLength = vsnprintf(nullptr, 0, formatStr, tmp_args) + 1;
- #endif
- va_end(tmp_args);
-
- Array<char> outputBuff(requiredLength);
- #ifdef WIN32
- vsnprintf_s(outputBuff.GetUnderlyingData(), requiredLength, _TRUNCATE, formatStr, args);
- #else
- vsnprintf(outputBuff.GetUnderlyingData(), requiredLength, formatStr, args);
- #endif // WIN32
-
- ss << outputBuff.GetUnderlyingData() << std::endl;
-
- ProcessFormattedStatement(ss.str());
-
- va_end(args);
-}
-
-void FormattedLogSystem::LogStream(LogLevel logLevel, const char* tag, const Aws::OStringStream &message_stream)
-{
+
+ return ss.str();
+}
+
+FormattedLogSystem::FormattedLogSystem(LogLevel logLevel) :
+ m_logLevel(logLevel)
+{
+}
+
+void FormattedLogSystem::Log(LogLevel logLevel, const char* tag, const char* formatStr, ...)
+{
+ Aws::StringStream ss;
+ ss << CreateLogPrefixLine(logLevel, tag);
+
+ std::va_list args;
+ va_start(args, formatStr);
+
+ va_list tmp_args; //unfortunately you cannot consume a va_list twice
+ va_copy(tmp_args, args); //so we have to copy it
+ #ifdef WIN32
+ const int requiredLength = _vscprintf(formatStr, tmp_args) + 1;
+ #else
+ const int requiredLength = vsnprintf(nullptr, 0, formatStr, tmp_args) + 1;
+ #endif
+ va_end(tmp_args);
+
+ Array<char> outputBuff(requiredLength);
+ #ifdef WIN32
+ vsnprintf_s(outputBuff.GetUnderlyingData(), requiredLength, _TRUNCATE, formatStr, args);
+ #else
+ vsnprintf(outputBuff.GetUnderlyingData(), requiredLength, formatStr, args);
+ #endif // WIN32
+
+ ss << outputBuff.GetUnderlyingData() << std::endl;
+
+ ProcessFormattedStatement(ss.str());
+
+ va_end(args);
+}
+
+void FormattedLogSystem::LogStream(LogLevel logLevel, const char* tag, const Aws::OStringStream &message_stream)
+{
ProcessFormattedStatement(CreateLogPrefixLine(logLevel, tag) + message_stream.str() + "\n");
-}
+}
diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/LogLevel.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/LogLevel.cpp
index 643985bd14..9ff1bf3126 100644
--- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/LogLevel.cpp
+++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/logging/LogLevel.cpp
@@ -2,44 +2,44 @@
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
-
-#include <aws/core/utils/logging/LogLevel.h>
-
-#include <aws/core/utils/memory/stl/AWSMap.h>
-#include <aws/core/utils/memory/stl/AWSString.h>
-#include <cassert>
-
-using namespace Aws::Utils::Logging;
-
-namespace Aws
+
+#include <aws/core/utils/logging/LogLevel.h>
+
+#include <aws/core/utils/memory/stl/AWSMap.h>
+#include <aws/core/utils/memory/stl/AWSString.h>
+#include <cassert>
+
+using namespace Aws::Utils::Logging;
+
+namespace Aws
+{
+namespace Utils
+{
+namespace Logging
+{
+
+Aws::String GetLogLevelName(LogLevel logLevel)
{
-namespace Utils
-{
-namespace Logging
-{
-
-Aws::String GetLogLevelName(LogLevel logLevel)
-{
- switch (logLevel)
- {
- case LogLevel::Fatal:
- return "FATAL";
- case LogLevel::Error:
- return "ERROR";
- case LogLevel::Warn:
- return "WARN";
- case LogLevel::Info:
- return "INFO";
- case LogLevel::Debug:
- return "DEBUG";
- case LogLevel::Trace:
- return "TRACE";
- default:
- assert(0);
- return "";
- }
-}
-
-} // namespace Logging
-} // namespace Utils
-} // namespace Aws
+ switch (logLevel)
+ {
+ case LogLevel::Fatal:
+ return "FATAL";
+ case LogLevel::Error:
+ return "ERROR";
+ case LogLevel::Warn:
+ return "WARN";
+ case LogLevel::Info:
+ return "INFO";
+ case LogLevel::Debug:
+ return "DEBUG";
+ case LogLevel::Trace:
+ return "TRACE";
+ default:
+ assert(0);
+ return "";
+ }
+}
+
+} // namespace Logging
+} // namespace Utils
+} // namespace Aws