cpp-common/bt2c/fmt.hpp: use `wise_enum::string_type` in `EnableIfIsWiseEnum` definition
[babeltrace.git] / src / logging / log.h
CommitLineData
beb0fb75 1/*
0235b0db
MJ
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (c) 2016 wonder-mice
71436ae4 5 * Copyright (c) 2016-2023 Philippe Proulx <pproulx@efficios.com>
0235b0db 6 *
71436ae4
SM
7 * This is very inspired by zf_log.h (see
8 * <https://github.com/wonder-mice/zf_log/>), but modified (mostly
9 * stripped down) for the use cases of Babeltrace.
beb0fb75
PP
10 */
11
71436ae4
SM
12#ifndef BABELTRACE_LOGGING_LOG_H
13#define BABELTRACE_LOGGING_LOG_H
beb0fb75 14
91d81473 15#include <errno.h>
373c938b
PP
16#include <stdlib.h>
17#include <stdio.h>
91d81473 18#include <string.h>
71436ae4 19#include <glib.h>
4fa90f32
PP
20#include <babeltrace2/babeltrace.h>
21
71436ae4 22#include "log-api.h"
beb0fb75 23
71436ae4
SM
24/*
25 * `BT_LOG_OUTPUT_LEVEL` (expression having the type `int`, optional):
26 * valid expression evaluating to the current (run-time) log level.
beb0fb75 27 *
71436ae4 28 * This is configured per translation unit.
beb0fb75 29 *
71436ae4
SM
30 * Note that BT_LOG*() statements will evaluate this expression each
31 * time if their level is equally or less verbose than
32 * `BT_LOG_MINIMAL_LEVEL`. Keep this expression as simple as possible,
33 * otherwise it will not only add run-time overhead, but also will
34 * increase the size of call sites (which will result in larger
35 * executable).
beb0fb75
PP
36 *
37 * Example:
38 *
71436ae4
SM
39 * #define BT_LOG_OUTPUT_LEVEL log_level
40 * #include "logging/log.h"
beb0fb75 41 *
71436ae4
SM
42 * If missing, you may only use logging macros having a `_cur_lvl`
43 * parameter.
beb0fb75 44 */
71436ae4
SM
45#ifdef BT_LOG_OUTPUT_LEVEL
46# define _BT_LOG_OUTPUT_LEVEL BT_LOG_OUTPUT_LEVEL
beb0fb75 47#else
71436ae4 48# define _BT_LOG_OUTPUT_LEVEL "Please define `BT_LOG_OUTPUT_LEVEL`"
beb0fb75
PP
49#endif
50
71436ae4
SM
51/*
52 * `BT_LOG_TAG` (expression having the type `const char *`, optional):
53 * component or module identifier.
beb0fb75 54 *
71436ae4 55 * This is configured per translation unit.
beb0fb75 56 *
71436ae4 57 * Example:
beb0fb75 58 *
71436ae4
SM
59 * // ...
60 * #define BT_LOG_TAG "MY.MODULE"
61 * #include "logging/log.h"
beb0fb75 62 */
71436ae4
SM
63#ifdef BT_LOG_TAG
64# define _BT_LOG_TAG BT_LOG_TAG
beb0fb75 65#else
71436ae4 66# define _BT_LOG_TAG NULL
beb0fb75 67#endif
beb0fb75 68
71436ae4
SM
69/*
70 * BT_LOG_ON_CUR_LVL() using `BT_LOG_OUTPUT_LEVEL` as the current
71 * (run-time) level.
beb0fb75 72 */
71436ae4
SM
73#define BT_LOG_ON(_lvl) BT_LOG_ON_CUR_LVL(_lvl, _BT_LOG_OUTPUT_LEVEL)
74#define BT_LOG_ON_TRACE BT_LOG_ON(BT_LOG_TRACE)
75#define BT_LOG_ON_DEBUG BT_LOG_ON(BT_LOG_DEBUG)
76#define BT_LOG_ON_INFO BT_LOG_ON(BT_LOG_INFO)
77#define BT_LOG_ON_WARNING BT_LOG_ON(BT_LOG_WARNING)
78#define BT_LOG_ON_ERROR BT_LOG_ON(BT_LOG_ERROR)
79#define BT_LOG_ON_FATAL BT_LOG_ON(BT_LOG_FATAL)
beb0fb75 80
71436ae4
SM
81/*
82 * BT_LOG_WRITE_CUR_LVL() using `BT_LOG_OUTPUT_LEVEL` as the current
83 * (run-time) level.
beb0fb75 84 */
71436ae4
SM
85#define BT_LOG_WRITE(_lvl, _tag, _msg) \
86 BT_LOG_WRITE_CUR_LVL((_lvl), _BT_LOG_OUTPUT_LEVEL, (_tag), (_msg))
beb0fb75 87
71436ae4
SM
88/*
89 * BT_LOG_WRITE_PRINTF_CUR_LVL() using `BT_LOG_OUTPUT_LEVEL` as the
90 * current (run-time) level.
beb0fb75 91 */
71436ae4
SM
92#define BT_LOG_WRITE_PRINTF(_lvl, _tag, _fmt, ...) \
93 BT_LOG_WRITE_PRINTF_CUR_LVL((_lvl), _BT_LOG_OUTPUT_LEVEL, \
94 (_tag), (_fmt), ##__VA_ARGS__)
beb0fb75 95
71436ae4
SM
96/*
97 * BT_LOG_WRITE_MEM_CUR_LVL() using `BT_LOG_OUTPUT_LEVEL` as the current
98 * (run-time) level.
beb0fb75 99 */
71436ae4
SM
100#define BT_LOG_WRITE_MEM(_lvl, _tag, _mem_data, _mem_len, _msg) \
101 BT_LOG_WRITE_MEM_CUR_LVL((_lvl), _BT_LOG_OUTPUT_LEVEL, (_tag), \
102 (_mem_data), (_mem_len), (_msg))
beb0fb75 103
71436ae4
SM
104/*
105 * BT_LOG_WRITE_MEM_PRINTF_CUR_LVL() using `BT_LOG_OUTPUT_LEVEL` as the
106 * current (run-time) level.
beb0fb75 107 */
71436ae4
SM
108#define BT_LOG_WRITE_MEM_PRINTF(_lvl, _tag, _mem_data, _mem_len, _fmt, ...) \
109 BT_LOG_WRITE_MEM_PRINTF_CUR_LVL((_lvl), _BT_LOG_OUTPUT_LEVEL, \
110 (_tag), (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
beb0fb75 111
71436ae4
SM
112/*
113 * BT_LOG_WRITE_ERRNO_CUR_LVL() using `BT_LOG_OUTPUT_LEVEL` as the
114 * current (run-time) level.
beb0fb75 115 */
71436ae4
SM
116#define BT_LOG_WRITE_ERRNO(_lvl, _tag, _init_msg, _msg) \
117 BT_LOG_WRITE_ERRNO_CUR_LVL((_lvl), _BT_LOG_OUTPUT_LEVEL, \
118 (_tag), (_init_msg), (_msg))
beb0fb75 119
71436ae4
SM
120/*
121 * BT_LOG_WRITE_ERRNO_PRINTF_CUR_LVL() using `BT_LOG_OUTPUT_LEVEL` as
122 * the current (run-time) level.
beb0fb75 123 */
71436ae4
SM
124#define BT_LOG_WRITE_ERRNO_PRINTF(_lvl, _tag, _init_msg, _fmt, ...) \
125 BT_LOG_WRITE_ERRNO_PRINTF_CUR_LVL((_lvl), _BT_LOG_OUTPUT_LEVEL, \
126 (_tag), (_init_msg), (_fmt), ##__VA_ARGS__)
beb0fb75 127
71436ae4
SM
128/* Internal: no-op function when a log level is disabled */
129static inline
130void _bt_log_unused(int dummy __attribute__((unused)), ...)
beb0fb75 131{
beb0fb75 132}
beb0fb75
PP
133
134#define _BT_LOG_UNUSED(...) \
71436ae4 135 do { if (0) _bt_log_unused(0, ##__VA_ARGS__); } while (0)
beb0fb75 136
71436ae4 137/* Trace level logging macros using `BT_LOG_TAG` */
ef267d12 138#if BT_LOG_ENABLED_TRACE
71436ae4
SM
139# define BT_LOGT_STR_CUR_LVL(_cur_lvl, _msg) \
140 BT_LOG_WRITE_CUR_LVL(BT_LOG_TRACE, (_cur_lvl), _BT_LOG_TAG, (_msg))
141# define BT_LOGT_STR(_msg) \
142 BT_LOG_WRITE(BT_LOG_TRACE, _BT_LOG_TAG, (_msg))
143# define BT_LOGT_CUR_LVL(_cur_lvl, _fmt, ...) \
144 BT_LOG_WRITE_PRINTF_CUR_LVL(BT_LOG_TRACE, (_cur_lvl), _BT_LOG_TAG, (_fmt), ##__VA_ARGS__)
145# define BT_LOGT(_fmt, ...) \
146 BT_LOG_WRITE_PRINTF(BT_LOG_TRACE, _BT_LOG_TAG, (_fmt), ##__VA_ARGS__)
147# define BT_LOGT_MEM_STR_CUR_LVL(_cur_lvl, _mem_data, _mem_len, _msg) \
148 BT_LOG_WRITE_MEM_CUR_LVL(BT_LOG_TRACE, (_cur_lvl), _BT_LOG_TAG, (_mem_data), (_mem_len), (_msg))
149# define BT_LOGT_MEM_STR(_mem_data, _mem_len, _msg) \
150 BT_LOG_WRITE_MEM(BT_LOG_TRACE, _BT_LOG_TAG, (_mem_data), (_mem_len), (_msg))
151# define BT_LOGT_MEM_CUR_LVL(_cur_lvl, _mem_data, _mem_len, _fmt, ...) \
152 BT_LOG_WRITE_MEM_PRINTF_CUR_LVL(BT_LOG_TRACE, (_cur_lvl), _BT_LOG_TAG, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
153# define BT_LOGT_MEM(_mem_data, _mem_len, _fmt, ...) \
154 BT_LOG_WRITE_MEM_PRINTF(BT_LOG_TRACE, _BT_LOG_TAG, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
155# define BT_LOGT_ERRNO_STR_CUR_LVL(_cur_lvl, _init_msg, _msg) \
156 BT_LOG_WRITE_ERRNO_CUR_LVL(BT_LOG_TRACE, (_cur_lvl), _BT_LOG_TAG, (_init_msg), (_msg))
157# define BT_LOGT_ERRNO_STR(_init_msg, _msg) \
158 BT_LOG_WRITE_ERRNO(BT_LOG_TRACE, _BT_LOG_TAG, (_init_msg), (_msg))
159# define BT_LOGT_ERRNO_CUR_LVL(_cur_lvl, _init_msg, _fmt, ...) \
160 BT_LOG_WRITE_ERRNO_PRINTF_CUR_LVL(BT_LOG_TRACE, (_cur_lvl), _BT_LOG_TAG, (_init_msg), (_fmt), ##__VA_ARGS__)
161# define BT_LOGT_ERRNO(_init_msg, _fmt, ...) \
162 BT_LOG_WRITE_ERRNO_PRINTF(BT_LOG_TRACE, _BT_LOG_TAG, (_init_msg), (_fmt), ##__VA_ARGS__)
beb0fb75 163#else
71436ae4
SM
164# define BT_LOGT_STR_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
165# define BT_LOGT_STR(...) _BT_LOG_UNUSED(__VA_ARGS__)
166# define BT_LOGT_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
167# define BT_LOGT(...) _BT_LOG_UNUSED(__VA_ARGS__)
168# define BT_LOGT_MEM_STR_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
169# define BT_LOGT_MEM_STR(...) _BT_LOG_UNUSED(__VA_ARGS__)
170# define BT_LOGT_MEM_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
171# define BT_LOGT_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__)
172# define BT_LOGT_ERRNO_STR_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
173# define BT_LOGT_ERRNO_STR(...) _BT_LOG_UNUSED(__VA_ARGS__)
174# define BT_LOGT_ERRNO_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
175# define BT_LOGT_ERRNO(...) _BT_LOG_UNUSED(__VA_ARGS__)
176#endif /* BT_LOG_ENABLED_TRACE */
177
178/* Debug level logging macros using `BT_LOG_TAG` */
beb0fb75 179#if BT_LOG_ENABLED_DEBUG
71436ae4
SM
180# define BT_LOGD_STR_CUR_LVL(_cur_lvl, _msg) \
181 BT_LOG_WRITE_CUR_LVL(BT_LOG_DEBUG, (_cur_lvl), _BT_LOG_TAG, (_msg))
182# define BT_LOGD_STR(_msg) \
183 BT_LOG_WRITE(BT_LOG_DEBUG, _BT_LOG_TAG, (_msg))
184# define BT_LOGD_CUR_LVL(_cur_lvl, _fmt, ...) \
185 BT_LOG_WRITE_PRINTF_CUR_LVL(BT_LOG_DEBUG, (_cur_lvl), _BT_LOG_TAG, (_fmt), ##__VA_ARGS__)
186# define BT_LOGD(_fmt, ...) \
187 BT_LOG_WRITE_PRINTF(BT_LOG_DEBUG, _BT_LOG_TAG, (_fmt), ##__VA_ARGS__)
188# define BT_LOGD_MEM_STR_CUR_LVL(_cur_lvl, _mem_data, _mem_len, _msg) \
189 BT_LOG_WRITE_MEM_CUR_LVL(BT_LOG_DEBUG, (_cur_lvl), _BT_LOG_TAG, (_mem_data), (_mem_len), (_msg))
190# define BT_LOGD_MEM_STR(_mem_data, _mem_len, _msg) \
191 BT_LOG_WRITE_MEM(BT_LOG_DEBUG, _BT_LOG_TAG, (_mem_data), (_mem_len), (_msg))
192# define BT_LOGD_MEM_CUR_LVL(_cur_lvl, _mem_data, _mem_len, _fmt, ...) \
193 BT_LOG_WRITE_MEM_PRINTF_CUR_LVL(BT_LOG_DEBUG, (_cur_lvl), _BT_LOG_TAG, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
194# define BT_LOGD_MEM(_mem_data, _mem_len, _fmt, ...) \
195 BT_LOG_WRITE_MEM_PRINTF(BT_LOG_DEBUG, _BT_LOG_TAG, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
196# define BT_LOGD_ERRNO_STR_CUR_LVL(_cur_lvl, _init_msg, _msg) \
197 BT_LOG_WRITE_ERRNO_CUR_LVL(BT_LOG_DEBUG, (_cur_lvl), _BT_LOG_TAG, (_init_msg), (_msg))
198# define BT_LOGD_ERRNO_STR(_init_msg, _msg) \
199 BT_LOG_WRITE_ERRNO(BT_LOG_DEBUG, _BT_LOG_TAG, (_init_msg), (_msg))
200# define BT_LOGD_ERRNO_CUR_LVL(_cur_lvl, _init_msg, _fmt, ...) \
201 BT_LOG_WRITE_ERRNO_PRINTF_CUR_LVL(BT_LOG_DEBUG, (_cur_lvl), _BT_LOG_TAG, (_init_msg), (_fmt), ##__VA_ARGS__)
202# define BT_LOGD_ERRNO(_init_msg, _fmt, ...) \
203 BT_LOG_WRITE_ERRNO_PRINTF(BT_LOG_DEBUG, _BT_LOG_TAG, (_init_msg), (_fmt), ##__VA_ARGS__)
beb0fb75 204#else
71436ae4
SM
205# define BT_LOGD_STR_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
206# define BT_LOGD_STR(...) _BT_LOG_UNUSED(__VA_ARGS__)
207# define BT_LOGD_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
208# define BT_LOGD(...) _BT_LOG_UNUSED(__VA_ARGS__)
209# define BT_LOGD_MEM_STR_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
210# define BT_LOGD_MEM_STR(...) _BT_LOG_UNUSED(__VA_ARGS__)
211# define BT_LOGD_MEM_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
212# define BT_LOGD_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__)
213# define BT_LOGD_ERRNO_STR_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
214# define BT_LOGD_ERRNO_STR(...) _BT_LOG_UNUSED(__VA_ARGS__)
215# define BT_LOGD_ERRNO_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
216# define BT_LOGD_ERRNO(...) _BT_LOG_UNUSED(__VA_ARGS__)
217#endif /* BT_LOG_ENABLED_DEBUG */
218
219/* Info level logging macros using `BT_LOG_TAG` */
beb0fb75 220#if BT_LOG_ENABLED_INFO
71436ae4
SM
221# define BT_LOGI_STR_CUR_LVL(_cur_lvl, _msg) \
222 BT_LOG_WRITE_CUR_LVL(BT_LOG_INFO, (_cur_lvl), _BT_LOG_TAG, (_msg))
223# define BT_LOGI_STR(_msg) \
224 BT_LOG_WRITE(BT_LOG_INFO, _BT_LOG_TAG, (_msg))
225# define BT_LOGI_CUR_LVL(_cur_lvl, _fmt, ...) \
226 BT_LOG_WRITE_PRINTF_CUR_LVL(BT_LOG_INFO, (_cur_lvl), _BT_LOG_TAG, (_fmt), ##__VA_ARGS__)
227# define BT_LOGI(_fmt, ...) \
228 BT_LOG_WRITE_PRINTF(BT_LOG_INFO, _BT_LOG_TAG, (_fmt), ##__VA_ARGS__)
229# define BT_LOGI_MEM_STR_CUR_LVL(_cur_lvl, _mem_data, _mem_len, _msg) \
230 BT_LOG_WRITE_MEM_CUR_LVL(BT_LOG_INFO, (_cur_lvl), _BT_LOG_TAG, (_mem_data), (_mem_len), (_msg))
231# define BT_LOGI_MEM_STR(_mem_data, _mem_len, _msg) \
232 BT_LOG_WRITE_MEM(BT_LOG_INFO, _BT_LOG_TAG, (_mem_data), (_mem_len), (_msg))
233# define BT_LOGI_MEM_CUR_LVL(_cur_lvl, _mem_data, _mem_len, _fmt, ...) \
234 BT_LOG_WRITE_MEM_PRINTF_CUR_LVL(BT_LOG_INFO, (_cur_lvl), _BT_LOG_TAG, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
235# define BT_LOGI_MEM(_mem_data, _mem_len, _fmt, ...) \
236 BT_LOG_WRITE_MEM_PRINTF(BT_LOG_INFO, _BT_LOG_TAG, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
237# define BT_LOGI_ERRNO_STR_CUR_LVL(_cur_lvl, _init_msg, _msg) \
238 BT_LOG_WRITE_ERRNO_CUR_LVL(BT_LOG_INFO, (_cur_lvl), _BT_LOG_TAG, (_init_msg), (_msg))
239# define BT_LOGI_ERRNO_STR(_init_msg, _msg) \
240 BT_LOG_WRITE_ERRNO(BT_LOG_INFO, _BT_LOG_TAG, (_init_msg), (_msg))
241# define BT_LOGI_ERRNO_CUR_LVL(_cur_lvl, _init_msg, _fmt, ...) \
242 BT_LOG_WRITE_ERRNO_PRINTF_CUR_LVL(BT_LOG_INFO, (_cur_lvl), _BT_LOG_TAG, (_init_msg), (_fmt), ##__VA_ARGS__)
243# define BT_LOGI_ERRNO(_init_msg, _fmt, ...) \
244 BT_LOG_WRITE_ERRNO_PRINTF(BT_LOG_INFO, _BT_LOG_TAG, (_init_msg), (_fmt), ##__VA_ARGS__)
beb0fb75 245#else
71436ae4
SM
246# define BT_LOGI_STR_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
247# define BT_LOGI_STR(...) _BT_LOG_UNUSED(__VA_ARGS__)
248# define BT_LOGI_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
249# define BT_LOGI(...) _BT_LOG_UNUSED(__VA_ARGS__)
250# define BT_LOGI_MEM_STR_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
251# define BT_LOGI_MEM_STR(...) _BT_LOG_UNUSED(__VA_ARGS__)
252# define BT_LOGI_MEM_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
253# define BT_LOGI_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__)
254# define BT_LOGI_ERRNO_STR_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
255# define BT_LOGI_ERRNO_STR(...) _BT_LOG_UNUSED(__VA_ARGS__)
256# define BT_LOGI_ERRNO_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
257# define BT_LOGI_ERRNO(...) _BT_LOG_UNUSED(__VA_ARGS__)
258#endif /* BT_LOG_ENABLED_INFO */
259
260/* Warning level logging macros using `BT_LOG_TAG` */
770538dd 261#if BT_LOG_ENABLED_WARNING
71436ae4
SM
262# define BT_LOGW_STR_CUR_LVL(_cur_lvl, _msg) \
263 BT_LOG_WRITE_CUR_LVL(BT_LOG_WARNING, (_cur_lvl), _BT_LOG_TAG, (_msg))
264# define BT_LOGW_STR(_msg) \
265 BT_LOG_WRITE(BT_LOG_WARNING, _BT_LOG_TAG, (_msg))
266# define BT_LOGW_CUR_LVL(_cur_lvl, _fmt, ...) \
267 BT_LOG_WRITE_PRINTF_CUR_LVL(BT_LOG_WARNING, (_cur_lvl), _BT_LOG_TAG, (_fmt), ##__VA_ARGS__)
268# define BT_LOGW(_fmt, ...) \
269 BT_LOG_WRITE_PRINTF(BT_LOG_WARNING, _BT_LOG_TAG, (_fmt), ##__VA_ARGS__)
270# define BT_LOGW_MEM_STR_CUR_LVL(_cur_lvl, _mem_data, _mem_len, _msg) \
271 BT_LOG_WRITE_MEM_CUR_LVL(BT_LOG_WARNING, (_cur_lvl), _BT_LOG_TAG, (_mem_data), (_mem_len), (_msg))
272# define BT_LOGW_MEM_STR(_mem_data, _mem_len, _msg) \
273 BT_LOG_WRITE_MEM(BT_LOG_WARNING, _BT_LOG_TAG, (_mem_data), (_mem_len), (_msg))
274# define BT_LOGW_MEM_CUR_LVL(_cur_lvl, _mem_data, _mem_len, _fmt, ...) \
275 BT_LOG_WRITE_MEM_PRINTF_CUR_LVL(BT_LOG_WARNING, (_cur_lvl), _BT_LOG_TAG, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
276# define BT_LOGW_MEM(_mem_data, _mem_len, _fmt, ...) \
277 BT_LOG_WRITE_MEM_PRINTF(BT_LOG_WARNING, _BT_LOG_TAG, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
278# define BT_LOGW_ERRNO_STR_CUR_LVL(_cur_lvl, _init_msg, _msg) \
279 BT_LOG_WRITE_ERRNO_CUR_LVL(BT_LOG_WARNING, (_cur_lvl), _BT_LOG_TAG, (_init_msg), (_msg))
280# define BT_LOGW_ERRNO_STR(_init_msg, _msg) \
281 BT_LOG_WRITE_ERRNO(BT_LOG_WARNING, _BT_LOG_TAG, (_init_msg), (_msg))
282# define BT_LOGW_ERRNO_CUR_LVL(_cur_lvl, _init_msg, _fmt, ...) \
283 BT_LOG_WRITE_ERRNO_PRINTF_CUR_LVL(BT_LOG_WARNING, (_cur_lvl), _BT_LOG_TAG, (_init_msg), (_fmt), ##__VA_ARGS__)
284# define BT_LOGW_ERRNO(_init_msg, _fmt, ...) \
285 BT_LOG_WRITE_ERRNO_PRINTF(BT_LOG_WARNING, _BT_LOG_TAG, (_init_msg), (_fmt), ##__VA_ARGS__)
beb0fb75 286#else
71436ae4
SM
287# define BT_LOGW_STR_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
288# define BT_LOGW_STR(...) _BT_LOG_UNUSED(__VA_ARGS__)
289# define BT_LOGW_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
290# define BT_LOGW(...) _BT_LOG_UNUSED(__VA_ARGS__)
291# define BT_LOGW_MEM_STR_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
292# define BT_LOGW_MEM_STR(...) _BT_LOG_UNUSED(__VA_ARGS__)
293# define BT_LOGW_MEM_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
294# define BT_LOGW_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__)
295# define BT_LOGW_ERRNO_STR_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
296# define BT_LOGW_ERRNO_STR(...) _BT_LOG_UNUSED(__VA_ARGS__)
297# define BT_LOGW_ERRNO_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
298# define BT_LOGW_ERRNO(...) _BT_LOG_UNUSED(__VA_ARGS__)
299#endif /* BT_LOG_ENABLED_WARNING */
300
301/* Error level logging macros using `BT_LOG_TAG` */
beb0fb75 302#if BT_LOG_ENABLED_ERROR
71436ae4
SM
303# define BT_LOGE_STR_CUR_LVL(_cur_lvl, _msg) \
304 BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, (_cur_lvl), _BT_LOG_TAG, (_msg))
305# define BT_LOGE_STR(_msg) \
306 BT_LOG_WRITE(BT_LOG_ERROR, _BT_LOG_TAG, (_msg))
307# define BT_LOGE_CUR_LVL(_cur_lvl, _fmt, ...) \
308 BT_LOG_WRITE_PRINTF_CUR_LVL(BT_LOG_ERROR, (_cur_lvl), _BT_LOG_TAG, (_fmt), ##__VA_ARGS__)
309# define BT_LOGE(_fmt, ...) \
310 BT_LOG_WRITE_PRINTF(BT_LOG_ERROR, _BT_LOG_TAG, (_fmt), ##__VA_ARGS__)
311# define BT_LOGE_MEM_STR_CUR_LVL(_cur_lvl, _mem_data, _mem_len, _msg) \
312 BT_LOG_WRITE_MEM_CUR_LVL(BT_LOG_ERROR, (_cur_lvl), _BT_LOG_TAG, (_mem_data), (_mem_len), (_msg))
313# define BT_LOGE_MEM_STR(_mem_data, _mem_len, _msg) \
314 BT_LOG_WRITE_MEM(BT_LOG_ERROR, _BT_LOG_TAG, (_mem_data), (_mem_len), (_msg))
315# define BT_LOGE_MEM_CUR_LVL(_cur_lvl, _mem_data, _mem_len, _fmt, ...) \
316 BT_LOG_WRITE_MEM_PRINTF_CUR_LVL(BT_LOG_ERROR, (_cur_lvl), _BT_LOG_TAG, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
317# define BT_LOGE_MEM(_mem_data, _mem_len, _fmt, ...) \
318 BT_LOG_WRITE_MEM_PRINTF(BT_LOG_ERROR, _BT_LOG_TAG, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
319# define BT_LOGE_ERRNO_STR_CUR_LVL(_cur_lvl, _init_msg, _msg) \
320 BT_LOG_WRITE_ERRNO_CUR_LVL(BT_LOG_ERROR, (_cur_lvl), _BT_LOG_TAG, (_init_msg), (_msg))
321# define BT_LOGE_ERRNO_STR(_init_msg, _msg) \
322 BT_LOG_WRITE_ERRNO(BT_LOG_ERROR, _BT_LOG_TAG, (_init_msg), (_msg))
323# define BT_LOGE_ERRNO_CUR_LVL(_cur_lvl, _init_msg, _fmt, ...) \
324 BT_LOG_WRITE_ERRNO_PRINTF_CUR_LVL(BT_LOG_ERROR, (_cur_lvl), _BT_LOG_TAG, (_init_msg), (_fmt), ##__VA_ARGS__)
325# define BT_LOGE_ERRNO(_init_msg, _fmt, ...) \
326 BT_LOG_WRITE_ERRNO_PRINTF(BT_LOG_ERROR, _BT_LOG_TAG, (_init_msg), (_fmt), ##__VA_ARGS__)
beb0fb75 327#else
71436ae4
SM
328# define BT_LOGE_STR_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
329# define BT_LOGE_STR(...) _BT_LOG_UNUSED(__VA_ARGS__)
330# define BT_LOGE_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
331# define BT_LOGE(...) _BT_LOG_UNUSED(__VA_ARGS__)
332# define BT_LOGE_MEM_STR_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
333# define BT_LOGE_MEM_STR(...) _BT_LOG_UNUSED(__VA_ARGS__)
334# define BT_LOGE_MEM_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
335# define BT_LOGE_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__)
336# define BT_LOGE_ERRNO_STR_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
337# define BT_LOGE_ERRNO_STR(...) _BT_LOG_UNUSED(__VA_ARGS__)
338# define BT_LOGE_ERRNO_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
339# define BT_LOGE_ERRNO(...) _BT_LOG_UNUSED(__VA_ARGS__)
340#endif /* BT_LOG_ENABLED_ERROR */
341
342/* Fatal level logging macros using `BT_LOG_TAG` */
beb0fb75 343#if BT_LOG_ENABLED_FATAL
71436ae4
SM
344# define BT_LOGF_STR_CUR_LVL(_cur_lvl, _msg) \
345 BT_LOG_WRITE_CUR_LVL(BT_LOG_FATAL, (_cur_lvl), _BT_LOG_TAG, (_msg))
346# define BT_LOGF_STR(_msg) \
347 BT_LOG_WRITE(BT_LOG_FATAL, _BT_LOG_TAG, (_msg))
348# define BT_LOGF_CUR_LVL(_cur_lvl, _fmt, ...) \
349 BT_LOG_WRITE_PRINTF_CUR_LVL(BT_LOG_FATAL, (_cur_lvl), _BT_LOG_TAG, (_fmt), ##__VA_ARGS__)
350# define BT_LOGF(_fmt, ...) \
351 BT_LOG_WRITE_PRINTF(BT_LOG_FATAL, _BT_LOG_TAG, (_fmt), ##__VA_ARGS__)
352# define BT_LOGF_MEM_STR_CUR_LVL(_cur_lvl, _mem_data, _mem_len, _msg) \
353 BT_LOG_WRITE_MEM_CUR_LVL(BT_LOG_FATAL, (_cur_lvl), _BT_LOG_TAG, (_mem_data), (_mem_len), (_msg))
354# define BT_LOGF_MEM_STR(_mem_data, _mem_len, _msg) \
355 BT_LOG_WRITE_MEM(BT_LOG_FATAL, _BT_LOG_TAG, (_mem_data), (_mem_len), (_msg))
356# define BT_LOGF_MEM_CUR_LVL(_cur_lvl, _mem_data, _mem_len, _fmt, ...) \
357 BT_LOG_WRITE_MEM_PRINTF_CUR_LVL(BT_LOG_FATAL, (_cur_lvl), _BT_LOG_TAG, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
358# define BT_LOGF_MEM(_mem_data, _mem_len, _fmt, ...) \
359 BT_LOG_WRITE_MEM_PRINTF(BT_LOG_FATAL, _BT_LOG_TAG, (_mem_data), (_mem_len), (_fmt), ##__VA_ARGS__)
360# define BT_LOGF_ERRNO_STR_CUR_LVL(_cur_lvl, _init_msg, _msg) \
361 BT_LOG_WRITE_ERRNO_CUR_LVL(BT_LOG_FATAL, (_cur_lvl), _BT_LOG_TAG, (_init_msg), (_msg))
362# define BT_LOGF_ERRNO_STR(_init_msg, _msg) \
363 BT_LOG_WRITE_ERRNO(BT_LOG_FATAL, _BT_LOG_TAG, (_init_msg), (_msg))
364# define BT_LOGF_ERRNO_CUR_LVL(_cur_lvl, _init_msg, _fmt, ...) \
365 BT_LOG_WRITE_ERRNO_PRINTF_CUR_LVL(BT_LOG_FATAL, (_cur_lvl), _BT_LOG_TAG, (_init_msg), (_fmt), ##__VA_ARGS__)
366# define BT_LOGF_ERRNO(_init_msg, _fmt, ...) \
367 BT_LOG_WRITE_ERRNO_PRINTF(BT_LOG_FATAL, _BT_LOG_TAG, (_init_msg), (_fmt), ##__VA_ARGS__)
beb0fb75 368#else
71436ae4
SM
369# define BT_LOGF_STR_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
370# define BT_LOGF_STR(...) _BT_LOG_UNUSED(__VA_ARGS__)
371# define BT_LOGF_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
372# define BT_LOGF(...) _BT_LOG_UNUSED(__VA_ARGS__)
373# define BT_LOGF_MEM_STR_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
374# define BT_LOGF_MEM_STR(...) _BT_LOG_UNUSED(__VA_ARGS__)
375# define BT_LOGF_MEM_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
376# define BT_LOGF_MEM(...) _BT_LOG_UNUSED(__VA_ARGS__)
377# define BT_LOGF_ERRNO_STR_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
378# define BT_LOGF_ERRNO_STR(...) _BT_LOG_UNUSED(__VA_ARGS__)
379# define BT_LOGF_ERRNO_CUR_LVL(...) _BT_LOG_UNUSED(__VA_ARGS__)
380# define BT_LOGF_ERRNO(...) _BT_LOG_UNUSED(__VA_ARGS__)
381#endif /* BT_LOG_ENABLED_FATAL */
6b06582d
PP
382
383/*
71436ae4
SM
384 * Tell the world that `log.h` was included without having to rely on
385 * the specific include guard.
6b06582d 386 */
7151fb67
PP
387#define BT_LOG_SUPPORTED
388
71436ae4 389#endif /* BABELTRACE_LOGGING_LOG_H */
This page took 0.120601 seconds and 4 git commands to generate.