azure-core
logger.hpp
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // SPDX-License-Identifier: MIT
3 
9 #pragma once
10 
11 #include <functional>
12 #include <string>
13 
14 namespace Azure { namespace Core { namespace Diagnostics {
18  class Logger final {
19  public:
24  // https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core/src/main/java/com/azure/core/util/logging/LogLevel.java
25  enum class Level : int
26  {
28  Verbose = 1,
29 
31  Informational = 2,
32 
34  Warning = 3,
35 
37  Error = 4,
38  };
39 
46  static void SetListener(std::function<void(Level level, std::string const& message)> listener);
47 
54  static void SetLevel(Level level);
55 
56  private:
61  Logger() = delete;
62 
68  ~Logger() = delete;
69  };
70 }}} // namespace Azure::Core::Diagnostics
Azure::Core::Diagnostics::Logger::Level::Verbose
@ Verbose
Logging level for detailed troubleshooting scenarios.
Azure::Core::Diagnostics::Logger::Level::Error
@ Error
Logging level for failures that the application is unlikely to recover from.
Azure::Core::Diagnostics::Logger::Level
Level
Log message level.
Definition: logger.hpp:26
Azure::Core::Diagnostics::Logger
Log message handler.
Definition: logger.hpp:18
Azure::Core::Diagnostics::Logger::SetLevel
static void SetLevel(Level level)
Sets the log message level an application is interested in receiving.
Definition: logger.cpp:51
Azure::Core::Diagnostics::Logger::Level::Informational
@ Informational
Logging level when a function operates normally.
Azure
Azure SDK abstractions.
Definition: azure_assert.hpp:55
Azure::Core::Diagnostics::Logger::Level::Warning
@ Warning
Logging level when a function fails to perform its intended task.
Azure::Core::Diagnostics::Logger::SetListener
static void SetListener(std::function< void(Level level, std::string const &message)> listener)
Sets the function that will be invoked to report an Azure SDK log message.
Definition: logger.cpp:43