xref: /aosp_15_r20/external/webrtc/test/logging/memory_log_writer.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
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 "test/logging/log_writer.h"
19 
20 namespace webrtc {
21 
22 // Allows creating log writer factories that creates log writers that saves
23 // their content to memory. When the log writers are destroyed, their content is
24 // saved to the logs_ member of this class. The intended usage is to keep this
25 // class alive after the created factories and writers have been destroyed and
26 // then use logs() to access all the saved logs.
27 class MemoryLogStorage {
28  public:
29   MemoryLogStorage();
30   ~MemoryLogStorage();
31   std::unique_ptr<LogWriterFactoryInterface> CreateFactory();
logs()32   const std::map<std::string, std::string>& logs() { return logs_; }
33 
34  private:
35   std::map<std::string, std::string> logs_;
36 };
37 
38 }  // namespace webrtc
39 
40 #endif  // TEST_LOGGING_MEMORY_LOG_WRITER_H_
41