memory_log_writer.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. #include <map>
  13. #include <memory>
  14. #include <string>
  15. #include <vector>
  16. #include "rtc_base/memory_stream.h"
  17. #include "test/logging/log_writer.h"
  18. namespace webrtc {
  19. // Allows creating log writer factories that creates log writers that saves
  20. // their content to memory. When the log writers are destroyed, their content is
  21. // saved to the logs_ member of this class. The intended usage is to keep this
  22. // class alive after the created factories and writers have been destroyed and
  23. // then use logs() to access all the saved logs.
  24. class MemoryLogStorage {
  25. public:
  26. MemoryLogStorage();
  27. ~MemoryLogStorage();
  28. std::unique_ptr<LogWriterFactoryInterface> CreateFactory();
  29. const std::map<std::string, std::string>& logs() { return logs_; }
  30. private:
  31. std::map<std::string, std::string> logs_;
  32. };
  33. } // namespace webrtc
  34. #endif // TEST_LOGGING_MEMORY_LOG_WRITER_H_