-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlog_parser.cc
40 lines (29 loc) · 1.07 KB
/
log_parser.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2020 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "croslog/log_parser.h"
#include <string>
#include <utility>
namespace {
std::string StripLeadingNull(std::string&& entire_line) {
int null_len = 0;
for (; null_len < entire_line.size(); null_len++) {
if (entire_line[null_len] != '\0')
break;
}
return entire_line.substr(null_len);
}
} // anonymous namespace
namespace croslog {
MaybeLogEntry LogParser::Parse(std::string&& entire_line) {
// This hack is the temporary solution for crbug.com/1132182.
// TODO(yoshiki): remove this after solving the issue.
if (!entire_line.empty() && entire_line[0] == '\0') {
LOG(WARNING) << "The line has leading NULLs. This is unresolved bug. "
"Please report this to crbug.com/1132182. Content: "
<< entire_line;
entire_line = StripLeadingNull(std::move(entire_line));
}
return ParseInternal(std::move(entire_line));
}
} // namespace croslog