lib: add bt_field_class_variant_borrow_option_by_{index,name}()
[babeltrace.git] / include / babeltrace2 / logging.h
1 #ifndef BABELTRACE2_LOGGING_H
2 #define BABELTRACE2_LOGGING_H
3
4 /*
5 * Copyright (c) 2010-2019 EfficiOS Inc. and Linux Foundation
6 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
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
23 * SOFTWARE.
24 */
25
26 #ifndef __BT_IN_BABELTRACE_H
27 # error "Please include <babeltrace2/babeltrace.h> instead."
28 #endif
29
30 #include <stdint.h>
31 #include <stdbool.h>
32 #include <stddef.h>
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 /**
39 @defgroup logging Logging
40 @ingroup apiref
41 @brief Logging.
42
43 @code
44 #include <babeltrace2/logging.h>
45 @endcode
46
47 The functions in this module control the Babeltrace library's logging
48 behaviour.
49
50 You can set the current global log level of the library with
51 bt_logging_set_global_level(). Note that, if the level you set is below
52 the minimal logging level (configured at build time, which you can get
53 with bt_logging_get_minimal_level()), the logging statement between the
54 current global log level and the minimal log level are not executed.
55
56 @file
57 @brief Logging functions.
58 @sa logging
59
60 @addtogroup logging
61 @{
62 */
63
64 /**
65 @brief Log levels.
66 */
67 typedef enum bt_logging_level {
68 /// Additional, low-level debugging context information.
69 BT_LOGGING_LEVEL_TRACE = 1,
70
71 /**
72 Debugging information, only useful when searching for the
73 cause of a bug.
74 */
75 BT_LOGGING_LEVEL_DEBUG = 2,
76
77 /**
78 Non-debugging information and failure to load optional
79 subsystems.
80 */
81 BT_LOGGING_LEVEL_INFO = 3,
82
83 /**
84 Errors caused by a bad usage of the library, that is, a
85 non-observance of the documented function preconditions.
86
87 The library's and object's states remain consistent when a
88 warning is issued.
89 */
90 BT_LOGGING_LEVEL_WARNING = 4,
91
92 /**
93 An important error from which the library cannot recover, but
94 the executed stack of functions can still return cleanly.
95 */
96 BT_LOGGING_LEVEL_ERROR = 5,
97
98 /**
99 The library cannot continue to work in this condition: it must
100 terminate immediately, without even returning to the user's
101 execution.
102 */
103 BT_LOGGING_LEVEL_FATAL = 6,
104
105 /// Logging is disabled.
106 BT_LOGGING_LEVEL_NONE = 0xff,
107 } bt_logging_level;
108
109 /**
110 @brief Returns the minimal log level of the Babeltrace library.
111
112 The minimal log level is defined at the library's build time. Any
113 logging statement with a level below the minimal log level is not
114 compiled. This means that it is useless, although possible, to set the
115 global log level with bt_logging_set_global_level() below this level.
116
117 @returns Minimal, build time log level.
118
119 @sa bt_logging_get_global_level(): Returns the current global log level.
120 */
121 extern bt_logging_level bt_logging_get_minimal_level(void);
122
123 /**
124 @brief Returns the current global log level of the Babeltrace library.
125
126 @returns Current global log level.
127
128 @sa bt_logging_set_global_level(): Sets the current global log level.
129 @sa bt_logging_get_minimal_level(): Returns the minimal log level.
130 */
131 extern bt_logging_level bt_logging_get_global_level(void);
132
133 /**
134 @brief Sets the current global log level of the Babeltrace library
135 to \p log_level.
136
137 If \p log_level is below what bt_logging_get_minimal_level() returns,
138 the logging statements with a level between \p log_level and the minimal
139 log level cannot be executed.
140
141 @param[in] log_level Library's new global log level.
142
143 @sa bt_logging_get_global_level(): Returns the global log level.
144 */
145 extern void bt_logging_set_global_level(bt_logging_level log_level);
146
147 /** @} */
148
149 #ifdef __cplusplus
150 }
151 #endif
152
153 #endif /* BABELTRACE2_LOGGING_H */
This page took 0.032132 seconds and 4 git commands to generate.