2 * SPDX-License-Identifier: MIT
4 * Copyright (c) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
7 #ifndef CTF_METADATA_LOGGING_H
8 #define CTF_METADATA_LOGGING_H
10 #include <babeltrace2/babeltrace.h>
12 #include "logging/log.h"
15 * This global log level is for the generated lexer and parser: we can't
16 * use a contextual log level for their "tracing", so they rely on this.
18 BT_LOG_LEVEL_EXTERN_SYMBOL(ctf_plugin_metadata_log_level);
21 * To be used by functions without a context structure to pass all the
22 * logging configuration at once.
24 struct meta_log_config
26 bt_logging_level log_level;
28 /* Weak, exactly one of these must be set */
29 bt_self_component *self_comp;
30 bt_self_component_class *self_comp_class;
33 #define _BT_LOGT_LINENO(_lineno, _msg, args...) \
34 BT_LOGT("At line %u in metadata stream: " _msg, _lineno, ##args)
36 #define _BT_LOGW_LINENO(_lineno, _msg, args...) \
37 BT_LOGW("At line %u in metadata stream: " _msg, _lineno, ##args)
39 #define _BT_LOGE_APPEND_CAUSE_LINENO(_lineno, _msg, args...) \
41 BT_LOGE("At line %u in metadata stream: " _msg, _lineno, ##args); \
42 (void) BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN( \
43 "CTF metadata parser", "At line %u in metadata stream: " _msg, _lineno, ##args); \
46 #define _BT_COMP_LOGT_LINENO(_lineno, _msg, args...) \
47 BT_COMP_LOGT("At line %u in metadata stream: " _msg, _lineno, ##args)
49 #define _BT_COMP_LOGW_LINENO(_lineno, _msg, args...) \
50 BT_COMP_LOGW("At line %u in metadata stream: " _msg, _lineno, ##args)
52 #define _BT_COMP_LOGE_LINENO(_lineno, _msg, args...) \
53 BT_COMP_LOGE("At line %u in metadata stream: " _msg, _lineno, ##args)
55 #define _BT_COMP_LOGE_APPEND_CAUSE_LINENO(_lineno, _msg, args...) \
56 BT_COMP_LOGE_APPEND_CAUSE(BT_COMP_LOG_SELF_COMP, "At line %u in metadata stream: " _msg, \
59 #define _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(_msg, args...) \
60 BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(BT_COMP_LOG_SELF_COMP, BT_COMP_LOG_SELF_COMP_CLASS, \
63 #endif /* CTF_METADATA_LOGGING_H */