cpp-common/bt2c/fmt.hpp: use `wise_enum::string_type` in `EnableIfIsWiseEnum` definition
[babeltrace.git] / src / plugins / text / pretty / pretty.h
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 */
6
7 #ifndef BABELTRACE_PLUGIN_TEXT_PRETTY_PRETTY_H
8 #define BABELTRACE_PLUGIN_TEXT_PRETTY_PRETTY_H
9
10 #include <glib.h>
11 #include <stdio.h>
12 #include <stdbool.h>
13 #include "common/macros.h"
14 #include <babeltrace2/babeltrace.h>
15
16 /*
17 * `bt_field_*_enumeration` are backed by 64 bits integers so the maximum
18 * number of bitflags in any enumeration is 64.
19 */
20 #define ENUMERATION_MAX_BITFLAGS_COUNT (sizeof(uint64_t) * 8)
21
22 enum pretty_default {
23 PRETTY_DEFAULT_UNSET,
24 PRETTY_DEFAULT_SHOW,
25 PRETTY_DEFAULT_HIDE,
26 };
27
28 enum pretty_color_option {
29 PRETTY_COLOR_OPT_NEVER,
30 PRETTY_COLOR_OPT_AUTO,
31 PRETTY_COLOR_OPT_ALWAYS,
32 };
33
34 struct pretty_options {
35 char *output_path;
36
37 enum pretty_default name_default;
38 enum pretty_default field_default;
39
40 bool print_scope_field_names;
41 bool print_header_field_names;
42 bool print_context_field_names;
43 bool print_payload_field_names;
44
45 bool print_delta_field;
46 bool print_enum_flags;
47 bool print_loglevel_field;
48 bool print_emf_field;
49 bool print_callsite_field;
50 bool print_trace_field;
51 bool print_trace_domain_field;
52 bool print_trace_procname_field;
53 bool print_trace_vpid_field;
54 bool print_trace_hostname_field;
55
56 bool print_timestamp_cycles;
57 bool clock_seconds;
58 bool clock_date;
59 bool clock_gmt;
60 enum pretty_color_option color;
61 bool verbose;
62 };
63
64 struct pretty_component {
65 struct pretty_options options;
66 bt_message_iterator *iterator;
67 FILE *out, *err;
68 int depth; /* nesting, used for tabulation alignment. */
69 bool start_line;
70 GString *string;
71 GString *tmp_string;
72 bool use_colors;
73
74 uint64_t last_cycles_timestamp;
75 uint64_t delta_cycles;
76
77 uint64_t last_real_timestamp;
78 uint64_t delta_real_timestamp;
79
80 bool negative_timestamp_warning_done;
81
82 /*
83 * For each bit of the integer backing the enumeration we have a list
84 * (GPtrArray) of labels (char *) for that bit.
85 *
86 * Allocate all label arrays during the initialization of the component
87 * and reuse the same set of arrays for all enumerations. This prevents
88 * allocation and deallocation everytime the component encounters a
89 * enumeration field. Allocating and deallocating that often could
90 * severely impact performance.
91 */
92 GPtrArray *enum_bit_labels[ENUMERATION_MAX_BITFLAGS_COUNT];
93
94 bt_logging_level log_level;
95 bt_self_component *self_comp;
96 };
97
98 bt_component_class_initialize_method_status pretty_init(
99 bt_self_component_sink *component,
100 bt_self_component_sink_configuration *config,
101 const bt_value *params,
102 void *init_method_data);
103
104 bt_component_class_sink_consume_method_status pretty_consume(
105 bt_self_component_sink *component);
106
107 bt_component_class_sink_graph_is_configured_method_status pretty_graph_is_configured(
108 bt_self_component_sink *component);
109
110 void pretty_finalize(bt_self_component_sink *component);
111
112 int pretty_print_event(struct pretty_component *pretty,
113 const bt_message *event_msg);
114
115 int pretty_print_discarded_items(struct pretty_component *pretty,
116 const bt_message *msg);
117
118 void pretty_print_init(void);
119
120 #endif /* BABELTRACE_PLUGIN_TEXT_PRETTY_PRETTY_H */
This page took 0.03153 seconds and 4 git commands to generate.