aws_log_system.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #pragma once
17 
18 #include <aws/core/utils/logging/LogLevel.h>
19 #include <aws/core/utils/logging/LogSystemInterface.h>
20 
21 #include <atomic>
22 #include <string>
23 
24 #define DEFAULT_LOG_MESSAGE_SIZE_BYTES 1024
25 
26 namespace Aws {
27 namespace Utils {
28 namespace Logging {
29 
30 class AWSLogSystem : public Aws::Utils::Logging::LogSystemInterface
31 {
32 public:
33  explicit AWSLogSystem(Aws::Utils::Logging::LogLevel log_level);
34  AWSLogSystem(AWSLogSystem const &) = delete; // Do not allow copy constructor
35  AWSLogSystem & operator=(AWSLogSystem const &) = delete; // Do not allow assignment operator
36  ~AWSLogSystem() override = default;
37 
38  // Gets the currently configured log level.
39  Aws::Utils::Logging::LogLevel GetLogLevel() const override;
40 
41  // Set a new log level. This has the immediate effect of changing the log.
42  void SetLogLevel(Aws::Utils::Logging::LogLevel log_level);
43 
44  // Log using printf style output. Prefer using LogStream
45  void Log(Aws::Utils::Logging::LogLevel log_level, const char * tag, const char * format,
46  ...) override;
47 
48  // Logs from a streambuffer.
49  void LogStream(Aws::Utils::Logging::LogLevel log_level, const char * tag,
50  const Aws::OStringStream & message_stream) override;
51 
52 protected:
53  virtual void LogInfo(const char * tag, const std::string & message) = 0;
54  virtual void LogDebug(const char * tag, const std::string & message) = 0;
55  virtual void LogTrace(const char * tag, const std::string & message) = 0;
56  virtual void LogWarn(const char * tag, const std::string & message) = 0;
57  virtual void LogError(const char * tag, const std::string & message) = 0;
58  virtual void LogFatal(const char * tag, const std::string & message) = 0;
59 
60 private:
61  std::atomic<Aws::Utils::Logging::LogLevel> configured_log_level_;
62 
63  void LogMessage(Aws::Utils::Logging::LogLevel log_level, const char * tag,
64  const std::string & message);
65 };
66 
67 } // namespace Logging
68 } // namespace Utils
69 } // namespace Aws
virtual void LogDebug(const char *tag, const std::string &message)=0
virtual void LogInfo(const char *tag, const std::string &message)=0
virtual void LogFatal(const char *tag, const std::string &message)=0
void Log(Aws::Utils::Logging::LogLevel log_level, const char *tag, const char *format,...) override
void LogMessage(Aws::Utils::Logging::LogLevel log_level, const char *tag, const std::string &message)
Aws::Utils::Logging::LogLevel GetLogLevel() const override
AWSLogSystem(Aws::Utils::Logging::LogLevel log_level)
virtual void LogTrace(const char *tag, const std::string &message)=0
~AWSLogSystem() override=default
void LogStream(Aws::Utils::Logging::LogLevel log_level, const char *tag, const Aws::OStringStream &message_stream) override
virtual void LogWarn(const char *tag, const std::string &message)=0
AWSLogSystem & operator=(AWSLogSystem const &)=delete
void SetLogLevel(Aws::Utils::Logging::LogLevel log_level)
std::atomic< Aws::Utils::Logging::LogLevel > configured_log_level_
virtual void LogError(const char *tag, const std::string &message)=0


aws_common
Author(s): AWS RoboMaker
autogenerated on Sat Mar 6 2021 03:11:38