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 #ifndef LOG_PARSE_H 16 #define LOG_PARSE_H 17 18 #include <map> 19 #include <set> 20 #include <stack> 21 #include <string> 22 23 #include "common_defines.h" 24 namespace OHOS { 25 namespace HiviewDFX { 26 class LogParse { 27 public: LogParse()28 LogParse() {}; ~LogParse()29 ~LogParse() {}; 30 LogParse(const LogParse&) = delete; 31 LogParse& operator=(const LogParse&) = delete; 32 bool IsIgnoreLibrary(const std::string& val) const; 33 void SetFrame(std::stack<std::string>& stack, std::map<std::string, std::string>& eventInfo) const; 34 std::string GetFilterTrace(const std::string& info, std::vector<std::string>& trace, 35 std::string eventType) const; 36 std::stack<std::string> GetStackTop(const std::vector<std::string>& validStack, const size_t num) const; 37 38 private: 39 std::vector<std::string> GetValidStack(size_t num, std::stack<std::string>& inStack) const; 40 std::vector<std::string> StackToPart(std::stack<std::string>& inStack, size_t num) const; 41 void MatchIgnoreLibrary(std::stack<std::string> inStack, std::stack<std::string>& outStack, size_t num) const; 42 std::string GetValidBlock(std::stack<std::string> inStack, std::vector<std::string>& lastPart) const; 43 44 private: 45 static const int STACK_LEN_MAX = 30; 46 static const std::map<std::string, std::set<std::string>> ignoreList_; 47 }; 48 } 49 } 50 #endif 51