Sebastian Jansson | 52de8b0 | 2019-01-16 17:25:44 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | #ifndef TEST_LOGGING_MEMORY_LOG_WRITER_H_ |
| 11 | #define TEST_LOGGING_MEMORY_LOG_WRITER_H_ |
| 12 | |
| 13 | #include <map> |
| 14 | #include <memory> |
| 15 | #include <string> |
| 16 | #include <vector> |
| 17 | |
| 18 | #include "rtc_base/memory_stream.h" |
| 19 | #include "test/logging/log_writer.h" |
| 20 | |
| 21 | namespace webrtc { |
| 22 | |
| 23 | // Allows creating log writer factories that creates log writers that saves |
| 24 | // their content to memory. When the log writers are destroyed, their content is |
| 25 | // saved to the logs_ member of this class. The intended usage is to keep this |
| 26 | // class alive after the created factories and writers have been destroyed and |
| 27 | // then use logs() to access all the saved logs. |
| 28 | class MemoryLogStorage { |
| 29 | public: |
| 30 | MemoryLogStorage(); |
| 31 | ~MemoryLogStorage(); |
| 32 | std::unique_ptr<LogWriterFactoryInterface> CreateFactory(); |
| 33 | const std::map<std::string, std::string>& logs() { return logs_; } |
| 34 | |
| 35 | private: |
| 36 | std::map<std::string, std::string> logs_; |
| 37 | }; |
| 38 | |
| 39 | } // namespace webrtc |
| 40 | |
| 41 | #endif // TEST_LOGGING_MEMORY_LOG_WRITER_H_ |