file_log_writer.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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_FILE_LOG_WRITER_H_
  11. #define TEST_LOGGING_FILE_LOG_WRITER_H_
  12. #include <cstdio>
  13. #include <memory>
  14. #include <string>
  15. #include <vector>
  16. #include "test/logging/log_writer.h"
  17. namespace webrtc {
  18. namespace webrtc_impl {
  19. class FileLogWriter final : public RtcEventLogOutput {
  20. public:
  21. explicit FileLogWriter(std::string file_path);
  22. ~FileLogWriter() final;
  23. bool IsActive() const override;
  24. bool Write(const std::string& value) override;
  25. void Flush() override;
  26. private:
  27. std::FILE* const out_;
  28. };
  29. } // namespace webrtc_impl
  30. class FileLogWriterFactory final : public LogWriterFactoryInterface {
  31. public:
  32. explicit FileLogWriterFactory(std::string base_path);
  33. ~FileLogWriterFactory() final;
  34. std::unique_ptr<RtcEventLogOutput> Create(std::string filename) override;
  35. private:
  36. const std::string base_path_;
  37. std::vector<std::unique_ptr<webrtc_impl::FileLogWriter>> writers_;
  38. };
  39. } // namespace webrtc
  40. #endif // TEST_LOGGING_FILE_LOG_WRITER_H_