AWS SDK for C++  0.14.3
AWS SDK for C++
DefaultLogSystem.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010-2015 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/Core_EXPORTS.h>
19 
25 
26 #include <thread>
27 #include <memory>
28 #include <mutex>
29 #include <atomic>
30 #include <condition_variable>
31 
32 namespace Aws
33 {
34  namespace Utils
35  {
36  namespace Logging
37  {
43  {
44  public:
46 
50  DefaultLogSystem(LogLevel logLevel, const std::shared_ptr<Aws::OStream>& logFile);
55  DefaultLogSystem(LogLevel logLevel, const Aws::String& filenamePrefix);
56  virtual ~DefaultLogSystem();
57 
62  {
63  public:
64  LogSynchronizationData() : m_stopLogging(false) {}
65 
66  std::mutex m_logQueueMutex;
67  std::condition_variable m_queueSignal;
69  std::atomic<bool> m_stopLogging;
70 
71  private:
73  LogSynchronizationData& operator =(const LogSynchronizationData& rhs) = delete;
74  };
75 
76  protected:
80  virtual void ProcessFormattedStatement(Aws::String&& statement) override;
81 
82  private:
83  DefaultLogSystem(const DefaultLogSystem& rhs) = delete;
84  DefaultLogSystem& operator =(const DefaultLogSystem& rhs) = delete;
85 
86  LogSynchronizationData m_syncData;
87 
88  std::thread m_loggingThread;
89  };
90 
91  } // namespace Logging
92  } // namespace Utils
93 } // namespace Aws
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition: AWSString.h:97
std::queue< T, Deque< T > > Queue
Definition: AWSQueue.h:29
#define AWS_CORE_API
Definition: Core_EXPORTS.h:35
JSON (JavaScript Object Notation).