Azure::Core::Diagnostics (#1851)

Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
This commit is contained in:
Anton Kolesnyk 2021-03-10 17:20:45 -08:00 committed by GitHub
parent f1773636c2
commit de0cb8a720
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 28 additions and 26 deletions

View File

@ -34,7 +34,7 @@
- Changed type of `Azure::Core::Http::RetryOptions::StatusCodes` from `std::vector` to `std::set`.
- Renamed `Azure::Core::Http::LoggingPolicy` to `LogPolicy`.
- Introduced `Azure::Core::Http::LogOptions`, a mandatory parameter for `LogPolicy` construction. Entities that are not specified in the allow lists are hidden in the log.
- Moved `Azure::Core::Logging` namespace entities to `Azure::Core::Logger` class.
- Moved `Azure::Core::Logging` namespace entities to `Azure::Core::Diagnostics::Logger` class.
- Removed `Azure::Core::DateTime::GetRfc3339String()`: `Azure::Core::DateTime::ToString()` was extended to provide the same functionality.
- Renamed the `Range` type to `HttpRange` within the `Azure::Core::Http` namespace.
- Moved `Azure::Core::Response<T>` to `Azure::Response<T>`.

View File

@ -405,7 +405,7 @@ namespace Azure { namespace Core { namespace Http {
* @brief Logs every HTTP request.
*
* @details Logs every HTTP request and response.
* @remark See Azure::Core::Logger.
* @remark See Azure::Core::Diagnostics::Logger.
*/
class LogPolicy : public HttpPolicy {
LogOptions m_options;

View File

@ -9,7 +9,7 @@
#include <atomic>
#include <type_traits>
namespace Azure { namespace Core { namespace _internal {
namespace Azure { namespace Core { namespace Diagnostics { namespace _internal {
class Log {
using LogLevelInt = std::underlying_type<Logger::Level>::type;
@ -36,4 +36,4 @@ namespace Azure { namespace Core { namespace _internal {
static void EnableLogging(bool isEnabled);
static void SetLogLevel(Logger::Level logLevel);
};
}}} // namespace Azure::Core::_internal
}}}} // namespace Azure::Core::Diagnostics::_internal

View File

@ -12,7 +12,7 @@
#include <functional>
#include <string>
namespace Azure { namespace Core {
namespace Azure { namespace Core { namespace Diagnostics {
/**
* @brief Log message handler.
*/
@ -49,13 +49,14 @@ namespace Azure { namespace Core {
/**
* @brief Set the function that will be invoked to report an SDK log message.
*
* @param listener An #Azure::Core::Logger::Listener function that will be invoked when
* the SDK reports a log message. If `nullptr`, no function will be invoked.
* @param listener An #Azure::Core::Diagnostics::Logger::Listener function that will be invoked
* when the SDK reports a log message. If `nullptr`, no function will be invoked.
*/
static void SetListener(Listener listener);
/**
* @brief Sets the #Azure::Core::Logger::Level an application is interested in receiving.
* @brief Sets the #Azure::Core::Diagnostics::Logger::Level an application is interested in
* receiving.
*
* @param level Maximum log level.
*/
@ -65,4 +66,4 @@ namespace Azure { namespace Core {
Logger() = delete;
~Logger() = delete;
};
}} // namespace Azure::Core
}}} // namespace Azure::Core::Diagnostics

View File

@ -25,8 +25,8 @@
#include <iostream>
#include <string>
using namespace Azure::Core;
using namespace Azure::Core::_detail;
using namespace Azure::Core::Diagnostics;
using namespace Azure::Core::Diagnostics::_detail;
namespace {
Logger::Level const* GetEnvironmentLogLevel()
@ -51,7 +51,7 @@ Logger::Level const* GetEnvironmentLogLevel()
if (envVar)
{
auto const logLevelStr = _internal::StringExtensions::ToLower(envVar);
auto const logLevelStr = Azure::Core::_internal::StringExtensions::ToLower(envVar);
// See https://github.com/Azure/azure-sdk-for-java/wiki/Logging-with-Azure-SDK
// And

View File

@ -16,7 +16,7 @@
#include <windows.h>
#endif
namespace Azure { namespace Core { namespace _detail {
namespace Azure { namespace Core { namespace Diagnostics { namespace _detail {
class EnvironmentLogLevelListener {
EnvironmentLogLevelListener() = delete;
@ -36,4 +36,4 @@ namespace Azure { namespace Core { namespace _detail {
inline Logger::Listener EnvironmentLogLevelListener::GetLogListener() { return nullptr; }
#endif
}}} // namespace Azure::Core::_detail
}}}} // namespace Azure::Core::Diagnostics::_detail

View File

@ -110,8 +110,8 @@ int pollSocketUntilEventOrTimeout(
return result;
}
using Azure::Core::Logger;
using Azure::Core::_internal::Log;
using Azure::Core::Diagnostics::Logger;
using Azure::Core::Diagnostics::_internal::Log;
#if defined(AZ_PLATFORM_WINDOWS)
// Windows needs this after every write to socket or performance would be reduced to 1/4 for

View File

@ -126,7 +126,8 @@ std::unique_ptr<RawResponse> Azure::Core::Http::LogPolicy::Send(
NextHttpPolicy nextHttpPolicy,
Context const& ctx) const
{
using Azure::Core::_internal::Log;
using Azure::Core::Diagnostics::Logger;
using Azure::Core::Diagnostics::_internal::Log;
if (Log::ShouldWrite(Logger::Level::Verbose))
{

View File

@ -101,8 +101,8 @@ bool ShouldRetryOnResponse(
RetryNumber attempt,
Delay& retryAfter)
{
using Azure::Core::Logger;
using Azure::Core::_internal::Log;
using Azure::Core::Diagnostics::Logger;
using Azure::Core::Diagnostics::_internal::Log;
// Are we out of retry attempts?
if (WasLastAttempt(retryOptions, attempt))
{
@ -182,8 +182,8 @@ std::unique_ptr<RawResponse> Azure::Core::Http::RetryPolicy::Send(
NextHttpPolicy nextHttpPolicy,
Context const& ctx) const
{
using Azure::Core::Logger;
using Azure::Core::_internal::Log;
using Azure::Core::Diagnostics::Logger;
using Azure::Core::Diagnostics::_internal::Log;
auto retryContext = CreateRetryContext(ctx);

View File

@ -9,8 +9,8 @@
#include "environment_log_level_listener_private.hpp"
using namespace Azure::Core;
using namespace Azure::Core::_internal;
using namespace Azure::Core::Diagnostics;
using namespace Azure::Core::Diagnostics::_internal;
namespace {
static std::shared_timed_mutex g_logListenerMutex;

View File

@ -4,8 +4,8 @@
#include <azure/core/internal/log.hpp>
#include <gtest/gtest.h>
using Azure::Core::Logger;
using Azure::Core::_internal::Log;
using Azure::Core::Diagnostics::Logger;
using Azure::Core::Diagnostics::_internal::Log;
TEST(Logger, Levels)
{

View File

@ -37,7 +37,7 @@ TEST(SimplifiedHeader, core)
EXPECT_NO_THROW(Azure::Core::Cryptography::Md5Hash m);
EXPECT_NO_THROW(Azure::Core::Http::RawResponse r(
1, 1, Azure::Core::Http::HttpStatusCode::Accepted, "phrase"));
EXPECT_NO_THROW(Azure::Core::Logger::Listener ll = nullptr);
EXPECT_NO_THROW(Azure::Core::Diagnostics::Logger::Listener ll = nullptr);
EXPECT_NO_THROW(Azure::MatchConditions mc);
EXPECT_NO_THROW(Azure::ModifiedConditions mc);
EXPECT_NO_THROW(Azure::Core::Nullable<int> n);