2 * SPDX-License-Identifier: MIT
4 * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
7 #ifndef BABELTRACE_PLUGINS_TEXT_PRETTY_PRETTY_H
8 #define BABELTRACE_PLUGINS_TEXT_PRETTY_PRETTY_H
13 #include "common/macros.h"
14 #include <babeltrace2/babeltrace.h>
17 * `bt_field_*_enumeration` are backed by 64 bits integers so the maximum
18 * number of bitflags in any enumeration is 64.
20 #define ENUMERATION_MAX_BITFLAGS_COUNT (sizeof(uint64_t) * 8)
28 enum pretty_color_option
{
29 PRETTY_COLOR_OPT_NEVER
,
30 PRETTY_COLOR_OPT_AUTO
,
31 PRETTY_COLOR_OPT_ALWAYS
,
34 struct pretty_options
{
37 enum pretty_default name_default
;
38 enum pretty_default field_default
;
40 bool print_scope_field_names
;
41 bool print_header_field_names
;
42 bool print_context_field_names
;
43 bool print_payload_field_names
;
45 bool print_delta_field
;
46 bool print_enum_flags
;
47 bool print_loglevel_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
;
56 bool print_timestamp_cycles
;
60 enum pretty_color_option color
;
64 struct pretty_component
{
65 struct pretty_options options
;
66 bt_message_iterator
*iterator
;
68 int depth
; /* nesting, used for tabulation alignment. */
74 uint64_t last_cycles_timestamp
;
75 uint64_t delta_cycles
;
77 uint64_t last_real_timestamp
;
78 uint64_t delta_real_timestamp
;
80 bool negative_timestamp_warning_done
;
83 * For each bit of the integer backing the enumeration we have a list
84 * (GPtrArray) of labels (char *) for that bit.
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.
92 GPtrArray
*enum_bit_labels
[ENUMERATION_MAX_BITFLAGS_COUNT
];
94 bt_logging_level log_level
;
95 bt_self_component
*self_comp
;
98 bt_component_class_get_supported_mip_versions_method_status
99 pretty_supported_mip_versions(bt_self_component_class_sink
*self_component_class
,
100 const bt_value
*params
, void *initialize_method_data
,
101 bt_logging_level logging_level
,
102 bt_integer_range_set_unsigned
*supported_versions
);
104 bt_component_class_initialize_method_status
pretty_init(
105 bt_self_component_sink
*component
,
106 bt_self_component_sink_configuration
*config
,
107 const bt_value
*params
,
108 void *init_method_data
);
110 bt_component_class_sink_consume_method_status
pretty_consume(
111 bt_self_component_sink
*component
);
113 bt_component_class_sink_graph_is_configured_method_status
pretty_graph_is_configured(
114 bt_self_component_sink
*component
);
116 void pretty_finalize(bt_self_component_sink
*component
);
118 int pretty_print_event(struct pretty_component
*pretty
,
119 const bt_message
*event_msg
);
121 int pretty_print_discarded_items(struct pretty_component
*pretty
,
122 const bt_message
*msg
);
124 void pretty_print_init(void);
126 #endif /* BABELTRACE_PLUGINS_TEXT_PRETTY_PRETTY_H */