4373312787e89298b37a1daac096f6b89d4111cf
1 #ifndef BABELTRACE_LIB_LOGGING_INTERNAL_H
2 #define BABELTRACE_LIB_LOGGING_INTERNAL_H
5 * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 #include <babeltrace/babeltrace-internal.h>
29 #define BT_LOG_OUTPUT_LEVEL bt_lib_log_level
31 #include <babeltrace/logging-internal.h>
36 #define BT_LIB_LOG(_lvl, _fmt, ...) \
38 if (BT_LOG_ON(_lvl)) { \
39 bt_lib_log(_BT_LOG_SRCLOC_FUNCTION, __FILE__, \
40 __LINE__, _lvl, _BT_LOG_TAG, \
41 (_fmt), ##__VA_ARGS__); \
46 * The six macros below are logging statements which are specialized
47 * for the Babeltrace library.
49 * `_fmt` is a typical printf()-style format string, with the following
52 * * The `*` width specifier is not accepted.
53 * * The `*` precision specifier is not accepted.
54 * * The `j` and `t` length modifiers are not accepted.
55 * * The `n` format specifier is not accepted.
56 * * The format specifiers defined in <inttypes.h> are not accepted
57 * except for `PRId64`, `PRIu64`, `PRIx64`, `PRIX64`, `PRIo64`, and
60 * The Babeltrace extension conversion specifier is accepted. Its syntax
63 * 1. Introductory `%!` sequence.
65 * 2. Optional: `[` followed by a custom prefix for the printed fields
66 * of this specifier, followed by `]`. The standard form is to end
67 * this prefix with `-` so that, for example, with the prefix
68 * `prefix-`, the complete field name is `prefix-addr`.
70 * 3. Optional: `+` to print extended fields. This depends on the
71 * provided format specifier.
73 * 4. Format specifier (see below).
75 * The available format specifiers are:
78 * Reference count information. The parameter is any Babeltrace
82 * CTF IR field type. The parameter type is `struct bt_field_type *`.
85 * CTF IR field. The parameter type is `struct bt_field *`.
88 * Field path. The parameter type is `struct bt_field_path *`.
91 * CTF IR event class. The parameter type is `struct bt_event_class *`.
94 * CTF IR event. The parameter type is `struct bt_event *`.
97 * CTF IR stream class. The parameter type is `struct bt_stream_class *`.
100 * CTF IR stream. The parameter type is `struct bt_stream *`.
103 * Packet. The parameter type is `struct bt_packet *`.
106 * CTF IR trace. The parameter type is `struct bt_trace *`.
109 * Clock class. The parameter type is `struct bt_clock_class *`.
112 * Clock value. The parameter type is `struct bt_clock_value *`.
115 * Value. The parameter type is `struct bt_value *`.
118 * Notification. The parameter type is `struct bt_notification *`.
121 * Notification iterator. The parameter type is
122 * `struct bt_notification_iterator *`.
125 * Component class. The parameter type is `struct bt_component_class *`.
128 * Component. The parameter type is `struct bt_component *`.
131 * Port. The parameter type is `struct bt_port *`.
134 * Connection. The parameter type is `struct bt_connection *`.
137 * Graph. The parameter type is `struct bt_graph *`.
140 * Plugin. The parameter type is `struct bt_plugin *`.
143 * Object pool. The parameter type is `struct bt_object_pool *`.
145 * Conversion specifier examples:
152 * The string `, ` is printed between individual fields, but not after
153 * the last one. Therefore you must put this separator in the format
154 * string between two Babeltrace objects, e.g.:
156 * BT_LIB_LOGW("Message: count=%u, %!E, %!+C", count, event_class,
159 * Example with a custom prefix:
161 * BT_LIB_LOGI("Some message: %![ec-a-]e, %![ec-b-]+e", ec_a, ec_b);
163 * It is safe to pass NULL as any Babeltrace object parameter: the
164 * macros only print its null address.
166 #define BT_LIB_LOGF(_fmt, ...) BT_LIB_LOG(BT_LOG_FATAL, _fmt, ##__VA_ARGS__)
167 #define BT_LIB_LOGE(_fmt, ...) BT_LIB_LOG(BT_LOG_ERROR, _fmt, ##__VA_ARGS__)
168 #define BT_LIB_LOGW(_fmt, ...) BT_LIB_LOG(BT_LOG_WARN, _fmt, ##__VA_ARGS__)
169 #define BT_LIB_LOGI(_fmt, ...) BT_LIB_LOG(BT_LOG_INFO, _fmt, ##__VA_ARGS__)
170 #define BT_LIB_LOGD(_fmt, ...) BT_LIB_LOG(BT_LOG_DEBUG, _fmt, ##__VA_ARGS__)
171 #define BT_LIB_LOGV(_fmt, ...) BT_LIB_LOG(BT_LOG_VERBOSE, _fmt, ##__VA_ARGS__)
174 * Log statement, specialized for the Babeltrace library.
176 * Use one of the BT_LIB_LOGF*() macros above instead of calling this
180 void bt_lib_log(const char *func
, const char *file
, unsigned line
,
181 int lvl
, const char *tag
, const char *fmt
, ...);
183 #endif /* BABELTRACE_LIB_LOGGING_INTERNAL_H */
This page took 0.033235 seconds and 3 git commands to generate.