ctf: append error causes when returning errors
[babeltrace.git] / src / plugins / ctf / common / metadata / logging.h
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (c) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 */
6
7 #ifndef CTF_METADATA_LOGGING_H
8 #define CTF_METADATA_LOGGING_H
9
10 #include <babeltrace2/babeltrace.h>
11 #include "logging/log.h"
12
13 /*
14 * This global log level is for the generated lexer and parser: we can't
15 * use a contextual log level for their "tracing", so they rely on this.
16 */
17 BT_LOG_LEVEL_EXTERN_SYMBOL(ctf_plugin_metadata_log_level);
18
19 /*
20 * To be used by functions without a context structure to pass all the
21 * logging configuration at once.
22 */
23 struct meta_log_config {
24 bt_logging_level log_level;
25
26 /* Weak, exactly one of these must be set */
27 bt_self_component *self_comp;
28 bt_self_component_class *self_comp_class;
29 };
30
31 #define _BT_LOGT_LINENO(_lineno, _msg, args...) \
32 BT_LOGT("At line %u in metadata stream: " _msg, _lineno, ## args)
33
34 #define _BT_LOGW_LINENO(_lineno, _msg, args...) \
35 BT_LOGW("At line %u in metadata stream: " _msg, _lineno, ## args)
36
37 #define _BT_LOGE_APPEND_CAUSE_LINENO(_lineno, _msg, args...) \
38 do { \
39 BT_LOGE("At line %u in metadata stream: " _msg, _lineno, ## args); \
40 (void) BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN( \
41 "CTF metadata parser", "At line %u in metadata stream: " _msg, _lineno, ## args); \
42 } while (0)
43
44 #define _BT_COMP_LOGT_LINENO(_lineno, _msg, args...) \
45 BT_COMP_LOGT("At line %u in metadata stream: " _msg, _lineno, ## args)
46
47 #define _BT_COMP_LOGW_LINENO(_lineno, _msg, args...) \
48 BT_COMP_LOGW("At line %u in metadata stream: " _msg, _lineno, ## args)
49
50 #define _BT_COMP_LOGE_LINENO(_lineno, _msg, args...) \
51 BT_COMP_LOGE("At line %u in metadata stream: " _msg, _lineno, ## args)
52
53 #define _BT_COMP_LOGE_APPEND_CAUSE_LINENO(_lineno, _msg, args...) \
54 BT_COMP_LOGE_APPEND_CAUSE(BT_COMP_LOG_SELF_COMP, "At line %u in metadata stream: " _msg, _lineno, ## args)
55
56 #define _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(_msg, args...) \
57 BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE( \
58 BT_COMP_LOG_SELF_COMP, \
59 BT_COMP_LOG_SELF_COMP_CLASS, \
60 _msg, ## args)
61
62 #endif /* CTF_METADATA_LOGGING_H */
This page took 0.03337 seconds and 4 git commands to generate.