Remove some streams from rtc_base/
Bug: webrtc:8982 Change-Id: Id372dde980fae493debf20873b6aeee8a7f1b045 Reviewed-on: https://webrtc-review.googlesource.com/78781 Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23396}
This commit is contained in:
parent
78b1c4a487
commit
55378f48b1
@ -654,6 +654,7 @@ rtc_static_library("rtc_numerics") {
|
||||
}
|
||||
|
||||
rtc_source_set("rtc_json") {
|
||||
testonly = true
|
||||
defines = []
|
||||
sources = [
|
||||
"json.cc",
|
||||
|
||||
@ -11,14 +11,15 @@
|
||||
#include "rtc_base/filerotatingstream.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/fileutils.h"
|
||||
#include "rtc_base/pathutils.h"
|
||||
#include "rtc_base/strings/string_builder.h"
|
||||
|
||||
// Note: We use std::cerr for logging in the write paths of this stream to avoid
|
||||
// Note: We use fprintf for logging in the write paths of this stream to avoid
|
||||
// infinite loops when logging.
|
||||
|
||||
namespace rtc {
|
||||
@ -149,7 +150,7 @@ StreamResult FileRotatingStream::Write(const void* data,
|
||||
return SR_EOS;
|
||||
}
|
||||
if (!file_stream_) {
|
||||
std::cerr << "Open() must be called before Write." << std::endl;
|
||||
std::fprintf(stderr, "Open() must be called before Write.\n");
|
||||
return SR_ERROR;
|
||||
}
|
||||
// Write as much as will fit in to the current file.
|
||||
@ -213,7 +214,7 @@ bool FileRotatingStream::Open() {
|
||||
std::vector<std::string> matching_files = GetFilesWithPrefix();
|
||||
for (auto matching_file : matching_files) {
|
||||
if (!Filesystem::DeleteFile(matching_file)) {
|
||||
std::cerr << "Failed to delete: " << matching_file << std::endl;
|
||||
std::fprintf(stderr, "Failed to delete: %s\n", matching_file.c_str());
|
||||
}
|
||||
}
|
||||
return OpenCurrentFile();
|
||||
@ -225,8 +226,7 @@ bool FileRotatingStream::Open() {
|
||||
bool FileRotatingStream::DisableBuffering() {
|
||||
disable_buffering_ = true;
|
||||
if (!file_stream_) {
|
||||
std::cerr << "Open() must be called before DisableBuffering()."
|
||||
<< std::endl;
|
||||
std::fprintf(stderr, "Open() must be called before DisableBuffering().\n");
|
||||
return false;
|
||||
}
|
||||
return file_stream_->DisableBuffering();
|
||||
@ -257,8 +257,8 @@ bool FileRotatingStream::OpenCurrentFile() {
|
||||
}
|
||||
int error = 0;
|
||||
if (!file_stream_->Open(file_path, mode, &error)) {
|
||||
std::cerr << "Failed to open: " << file_path << "Error: " << error
|
||||
<< std::endl;
|
||||
std::fprintf(stderr, "Failed to open: %s Error: %i\n", file_path.c_str(),
|
||||
error);
|
||||
file_stream_.reset();
|
||||
return false;
|
||||
}
|
||||
@ -286,7 +286,7 @@ void FileRotatingStream::RotateFiles() {
|
||||
std::string file_to_delete = file_names_[rotation_index_];
|
||||
if (Filesystem::IsFile(file_to_delete)) {
|
||||
if (!Filesystem::DeleteFile(file_to_delete)) {
|
||||
std::cerr << "Failed to delete: " << file_to_delete << std::endl;
|
||||
std::fprintf(stderr, "Failed to delete: %s\n", file_to_delete.c_str());
|
||||
}
|
||||
}
|
||||
for (auto i = rotation_index_; i > 0; --i) {
|
||||
@ -294,8 +294,8 @@ void FileRotatingStream::RotateFiles() {
|
||||
std::string unrotated_name = file_names_[i - 1];
|
||||
if (Filesystem::IsFile(unrotated_name)) {
|
||||
if (!Filesystem::MoveFile(unrotated_name, rotated_name)) {
|
||||
std::cerr << "Failed to move: " << unrotated_name << " to "
|
||||
<< rotated_name << std::endl;
|
||||
std::fprintf(stderr, "Failed to move: %s to %s\n",
|
||||
unrotated_name.c_str(), rotated_name.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -327,7 +327,8 @@ std::vector<std::string> FileRotatingStream::GetFilesWithPrefix() const {
|
||||
std::string FileRotatingStream::GetFilePath(size_t index,
|
||||
size_t num_files) const {
|
||||
RTC_DCHECK_LT(index, num_files);
|
||||
std::ostringstream file_name;
|
||||
char buf[1024];
|
||||
rtc::SimpleStringBuilder file_name(buf);
|
||||
// The format will be "_%<num_digits>zu". We want to zero pad the index so
|
||||
// that it will sort nicely.
|
||||
size_t max_digits = ((num_files - 1) / 10) + 1;
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
|
||||
#include "rtc_base/logsinks.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
|
||||
#include "rtc_base/checks.h"
|
||||
@ -37,7 +37,7 @@ FileRotatingLogSink::~FileRotatingLogSink() {
|
||||
|
||||
void FileRotatingLogSink::OnLogMessage(const std::string& message) {
|
||||
if (stream_->GetState() != SS_OPEN) {
|
||||
std::cerr << "Init() must be called before adding this sink." << std::endl;
|
||||
std::fprintf(stderr, "Init() must be called before adding this sink.\n");
|
||||
return;
|
||||
}
|
||||
stream_->WriteAll(message.c_str(), message.size(), nullptr, nullptr);
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
|
||||
#include <sys/utsname.h>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user