Return status instead of CHECKing in event log parser.
This CL adds ParseStatus/ParseStatusOr classes and returns those instead of CHECKing that the log is well formed. Some refactoring was required. We also add a allow_incomplete_logs parameter to the parser which by default is false. Setting it to true will make the parser log a warning but return success for errors that typically indicate that the log has been truncated. "Deeper" errors indicating log corruption still return an error. Bug: webrtc:11064 Change-Id: Id5bd6e321de07e250662ae3aaa5ef15f48db6d55 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/158746 Reviewed-by: Ivo Creusen <ivoc@webrtc.org> Reviewed-by: Sebastian Jansson <srte@webrtc.org> Commit-Queue: Björn Terelius <terelius@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29679}
This commit is contained in:
committed by
Commit Bot
parent
cc9bf6398c
commit
a06048a41e
@ -42,9 +42,15 @@ std::unique_ptr<RtcEventLogSource> RtcEventLogSource::CreateFromFile(
|
||||
absl::optional<uint32_t> ssrc_filter) {
|
||||
auto source = std::unique_ptr<RtcEventLogSource>(new RtcEventLogSource());
|
||||
ParsedRtcEventLog parsed_log;
|
||||
if (!parsed_log.ParseFile(file_name) ||
|
||||
!source->Initialize(parsed_log, ssrc_filter)) {
|
||||
std::cerr << "Error while parsing event log, skipping." << std::endl;
|
||||
auto status = parsed_log.ParseFile(file_name);
|
||||
if (!status.ok()) {
|
||||
std::cerr << "Failed to parse event log: " << status.message() << std::endl;
|
||||
std::cerr << "Skipping log." << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
if (!source->Initialize(parsed_log, ssrc_filter)) {
|
||||
std::cerr << "Failed to initialize source from event log, skipping."
|
||||
<< std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
return source;
|
||||
@ -55,9 +61,15 @@ std::unique_ptr<RtcEventLogSource> RtcEventLogSource::CreateFromString(
|
||||
absl::optional<uint32_t> ssrc_filter) {
|
||||
auto source = std::unique_ptr<RtcEventLogSource>(new RtcEventLogSource());
|
||||
ParsedRtcEventLog parsed_log;
|
||||
if (!parsed_log.ParseString(file_contents) ||
|
||||
!source->Initialize(parsed_log, ssrc_filter)) {
|
||||
std::cerr << "Error while parsing event log, skipping." << std::endl;
|
||||
auto status = parsed_log.ParseString(file_contents);
|
||||
if (!status.ok()) {
|
||||
std::cerr << "Failed to parse event log: " << status.message() << std::endl;
|
||||
std::cerr << "Skipping log." << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
if (!source->Initialize(parsed_log, ssrc_filter)) {
|
||||
std::cerr << "Failed to initialize source from event log, skipping."
|
||||
<< std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
return source;
|
||||
|
||||
Reference in New Issue
Block a user