Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 51cf897

Browse files
committed
Extend WEBRTC_TRACE to stderr output
Signed-off-by: jdai12 <[email protected]> Change-Id: I0d18ab40d09eb97c7b5724702de9950cbb59ca6a Reviewed-on: https://git-ccr-1.devtools.intel.com/gerrit/56241
1 parent 0c0f03f commit 51cf897

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

webrtc/system_wrappers/source/trace_impl.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ TraceImpl::TraceImpl()
6868
: callback_(NULL),
6969
row_count_text_(0),
7070
file_count_text_(0),
71-
trace_file_(FileWrapper::Create()) {
71+
trace_file_(FileWrapper::Create()),
72+
is_stderr_(false) {
7273
}
7374

7475
TraceImpl::~TraceImpl() {
@@ -290,6 +291,8 @@ int32_t TraceImpl::SetTraceFileImpl(const char* file_name_utf8,
290291
trace_file_path_.clear();
291292

292293
if (file_name_utf8) {
294+
is_stderr_ = false;
295+
293296
if (add_file_counter) {
294297
file_count_text_ = 1;
295298

@@ -307,6 +310,12 @@ int32_t TraceImpl::SetTraceFileImpl(const char* file_name_utf8,
307310
}
308311
trace_file_path_ = file_name_utf8;
309312
}
313+
} else {
314+
is_stderr_ = true;
315+
316+
if (!trace_file_->OpenFromFileHandle(stderr)) {
317+
return -1;
318+
}
310319
}
311320
row_count_text_ = 0;
312321
return 0;
@@ -363,7 +372,7 @@ void TraceImpl::WriteToFile(const char* msg, uint16_t length) {
363372
if (!trace_file_->is_open())
364373
return;
365374

366-
if (row_count_text_ > WEBRTC_TRACE_MAX_FILE_SIZE) {
375+
if (!is_stderr_ && row_count_text_ > WEBRTC_TRACE_MAX_FILE_SIZE) {
367376
// wrap file
368377
row_count_text_ = 0;
369378
trace_file_->Flush();

webrtc/system_wrappers/source/trace_impl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ class TraceImpl : public Trace {
9898
const std::unique_ptr<FileWrapper> trace_file_ GUARDED_BY(crit_);
9999
std::string trace_file_path_ GUARDED_BY(crit_);
100100
rtc::CriticalSection crit_;
101+
102+
bool is_stderr_;
101103
};
102104

103105
} // namespace webrtc

0 commit comments

Comments
 (0)