xref: /aosp_15_r20/external/perfetto/src/trace_processor/importers/proto/winscope/protolog_parser.h (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_WINSCOPE_PROTOLOG_PARSER_H_
18 #define SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_WINSCOPE_PROTOLOG_PARSER_H_
19 
20 #include <cstdint>
21 #include <string>
22 #include <vector>
23 
24 #include "protos/perfetto/trace/android/protolog.pbzero.h"
25 #include "src/trace_processor/importers/proto/winscope/protolog_message_decoder.h"
26 #include "src/trace_processor/storage/trace_storage.h"
27 #include "src/trace_processor/util/descriptors.h"
28 #include "src/trace_processor/util/proto_to_args_parser.h"
29 
30 namespace perfetto::trace_processor {
31 
32 class TraceProcessorContext;
33 
34 class ProtoLogParser {
35  public:
36   explicit ProtoLogParser(TraceProcessorContext*);
37   void ParseProtoLogMessage(PacketSequenceStateGeneration* sequence_state,
38                             protozero::ConstBytes,
39                             int64_t timestamp);
40   void ParseAndAddViewerConfigToMessageDecoder(protozero::ConstBytes);
41 
42  private:
43   void PopulateReservedRowWithMessage(tables::ProtoLogTable::Id table_row_id,
44                                       ProtoLogLevel level,
45                                       std::string& group_tag,
46                                       std::string& formatted_message,
47                                       std::optional<StringId> stacktrace,
48                                       std::optional<std::string>& location);
49 
50   TraceProcessorContext* const context_;
51   util::ProtoToArgsParser args_parser_;
52 
53   const StringId log_level_debug_string_id_;
54   const StringId log_level_verbose_string_id_;
55   const StringId log_level_info_string_id_;
56   const StringId log_level_warn_string_id_;
57   const StringId log_level_error_string_id_;
58   const StringId log_level_wtf_string_id_;
59   const StringId log_level_unknown_string_id_;
60 };
61 }  // namespace perfetto::trace_processor
62 
63 #endif  // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_WINSCOPE_PROTOLOG_PARSER_H_
64