Elad Alon | 83ccca1 | 2017-10-04 13:18:26 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 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 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 11 | #ifndef API_RTC_EVENT_LOG_OUTPUT_H_ |
| 12 | #define API_RTC_EVENT_LOG_OUTPUT_H_ |
Elad Alon | 83ccca1 | 2017-10-04 13:18:26 +0200 | [diff] [blame] | 13 | |
| 14 | #include <string> |
| 15 | |
Björn Terelius | 63299a3 | 2022-07-05 10:58:52 +0200 | [diff] [blame^] | 16 | #include "absl/strings/string_view.h" |
| 17 | |
Elad Alon | 83ccca1 | 2017-10-04 13:18:26 +0200 | [diff] [blame] | 18 | namespace webrtc { |
| 19 | |
Elad Alon | 8081073 | 2017-10-06 13:07:32 +0200 | [diff] [blame] | 20 | // NOTE: This class is still under development and may change without notice. |
Elad Alon | 83ccca1 | 2017-10-04 13:18:26 +0200 | [diff] [blame] | 21 | class RtcEventLogOutput { |
| 22 | public: |
| 23 | virtual ~RtcEventLogOutput() = default; |
| 24 | |
| 25 | // An output normally starts out active, though that might not always be |
| 26 | // the case (e.g. failed to open a file for writing). |
| 27 | // Once an output has become inactive (e.g. maximum file size reached), it can |
| 28 | // never become active again. |
| 29 | virtual bool IsActive() const = 0; |
| 30 | |
| 31 | // Write encoded events to an output. Returns true if the output was |
| 32 | // successfully written in its entirety. Otherwise, no guarantee is given |
| 33 | // about how much data was written, if any. The output sink becomes inactive |
Artem Titov | 0e61fdd | 2021-07-25 21:50:14 +0200 | [diff] [blame] | 34 | // after the first time `false` is returned. Write() may not be called on |
Elad Alon | 83ccca1 | 2017-10-04 13:18:26 +0200 | [diff] [blame] | 35 | // an inactive output sink. |
| 36 | virtual bool Write(const std::string& output) = 0; |
Björn Terelius | 63299a3 | 2022-07-05 10:58:52 +0200 | [diff] [blame^] | 37 | // TODO(bugs.webrtc.org/13579): Make pure virtual and remove the string ref |
| 38 | // once all classes implement the string_view version. |
| 39 | virtual bool Write(absl::string_view output) { |
| 40 | return Write(std::string(output)); |
| 41 | } |
Sebastian Jansson | 52de8b0 | 2019-01-16 17:25:44 +0100 | [diff] [blame] | 42 | |
| 43 | // Indicates that buffers should be written to disk if applicable. |
| 44 | virtual void Flush() {} |
Elad Alon | 83ccca1 | 2017-10-04 13:18:26 +0200 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | } // namespace webrtc |
| 48 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 49 | #endif // API_RTC_EVENT_LOG_OUTPUT_H_ |