• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "src/trace_processor/storage/trace_storage.h"
25 #include "src/trace_processor/util/descriptors.h"
26 #include "src/trace_processor/util/proto_to_args_parser.h"
27 
28 namespace perfetto::trace_processor {
29 
30 class TraceProcessorContext;
31 
32 class ProtoLogParser {
33  public:
34   explicit ProtoLogParser(TraceProcessorContext*);
35   void ParseProtoLogMessage(PacketSequenceStateGeneration* sequence_state,
36                             protozero::ConstBytes,
37                             int64_t timestamp);
38   void ParseProtoLogViewerConfig(protozero::ConstBytes);
39 
40  private:
41   std::string FormatMessage(const std::string& message,
42                             const std::vector<int64_t>& sint64_params,
43                             const std::vector<double>& double_params,
44                             const std::vector<bool>& boolean_params,
45                             const std::vector<std::string>& string_params);
46 
47   TraceProcessorContext* const context_;
48   DescriptorPool pool_;
49   util::ProtoToArgsParser args_parser_;
50 
51   const StringId log_level_debug_string_id_;
52   const StringId log_level_verbose_string_id_;
53   const StringId log_level_info_string_id_;
54   const StringId log_level_warn_string_id_;
55   const StringId log_level_error_string_id_;
56   const StringId log_level_wtf_string_id_;
57   const StringId log_level_unknown_string_id_;
58 };
59 }  // namespace perfetto::trace_processor
60 
61 #endif  // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_WINSCOPE_PROTOLOG_PARSER_H_
62