1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include "log_analyzer.h"
16
17 #include "faultlog_util.h"
18 #include "smart_parser.h"
19 #include "tbox.h"
20
21 namespace OHOS {
22 namespace HiviewDFX {
AnalysisFaultlog(const FaultLogInfo & info,std::map<std::string,std::string> & eventInfos)23 bool AnalysisFaultlog(const FaultLogInfo& info, std::map<std::string, std::string>& eventInfos)
24 {
25 auto eventType = GetFaultNameByType(info.faultLogType, false);
26 eventInfos = SmartParser::Analysis(info.logPath, SMART_PARSER_PATH, eventType);
27 if (eventInfos.empty()) {
28 eventInfos.insert(std::make_pair("fingerPrint", Tbox::CalcFingerPrint(info.module + info.reason +
29 info.summary, 0, FP_BUFFER)));
30 return false;
31 }
32
33 Tbox::FilterTrace(eventInfos);
34 std::string fingerPrint = Tbox::CalcFingerPrint(info.module + info.reason + eventInfos["FIRST_FRAME"] +
35 eventInfos["SECOND_FRAME"] + eventInfos["LAST_FRAME"], 0, FP_BUFFER);
36 eventInfos["fingerPrint"] = fingerPrint;
37 return true;
38 }
39 } // namespace HiviewDFX
40 } // namespace OHOS
41