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