29
29
LTTNG_UST_LOG_LEVEL_DEBUG,
32
enum lttng_ust_log_critical_action {
33
LTTNG_UST_LOG_CRITICAL_ACTION_UNKNOWN = 0,
34
LTTNG_UST_LOG_CRITICAL_ACTION_NONE,
35
LTTNG_UST_LOG_CRITICAL_ACTION_ABORT,
32
38
extern int lttng_ust_log_level /* enum lttng_ust_log_level */
33
39
__attribute__((visibility("hidden")));
41
extern int lttng_ust_log_critical_action /* enum lttng_ust_log_critical_action */
42
__attribute__((visibility("hidden")));
36
45
* Initialize the global log level from the "LTTNG_UST_DEBUG" environment
46
* variable and the global log critical action from "LTTNG_UST_ABORT_ON_CRITICAL".
39
48
* This could end up being called concurrently by multiple threads but doesn't
40
49
* require a mutex since the input is invariant across threads and the result
41
50
* will be the same.
43
* Return the current log level to save the caller a second read of the global
46
int lttng_ust_logging_init(void)
52
void lttng_ust_logging_init(void)
47
53
__attribute__((visibility("hidden")));
49
55
#ifdef LTTNG_UST_DEBUG
61
67
current_log_level = CMM_LOAD_SHARED(lttng_ust_log_level);
63
69
/* If the global log level is unknown, lazy-initialize it. */
64
if (caa_unlikely(current_log_level == LTTNG_UST_LOG_LEVEL_UNKNOWN))
65
current_log_level = lttng_ust_logging_init();
70
if (caa_unlikely(current_log_level == LTTNG_UST_LOG_LEVEL_UNKNOWN)) {
71
lttng_ust_logging_init();
72
current_log_level = CMM_LOAD_SHARED(lttng_ust_log_level);
67
75
return current_log_level == LTTNG_UST_LOG_LEVEL_DEBUG;
69
77
#endif /* #ifdef LTTNG_UST_DEBUG */
79
#ifdef LTTNG_UST_ABORT_ON_CRITICAL
81
bool lttng_ust_logging_abort_on_critical_enabled(void)
85
#else /* #ifdef LTTNG_UST_ABORT_ON_CRITICAL */
87
bool lttng_ust_logging_abort_on_critical_enabled(void)
89
int current_log_critical_action;
91
current_log_critical_action = CMM_LOAD_SHARED(lttng_ust_log_critical_action);
93
/* If the global log critical action is unknown, lazy-initialize it. */
94
if (caa_unlikely(current_log_critical_action == LTTNG_UST_LOG_CRITICAL_ACTION_UNKNOWN)) {
95
lttng_ust_logging_init();
96
current_log_critical_action = CMM_LOAD_SHARED(lttng_ust_log_critical_action);
99
return current_log_critical_action == LTTNG_UST_LOG_CRITICAL_ACTION_ABORT;
101
#endif /* #ifdef LTTNG_UST_ABORT_ON_CRITICAL */
72
* The default component for error messages.
104
* The default component for log statements.
74
106
#ifndef UST_COMPONENT
75
107
#define UST_COMPONENT libust
113
145
#define DBG_raw(fmt, args...) sigsafe_print_err(fmt, ## args)
114
146
#define WARN(fmt, args...) ERRMSG("Warning: " fmt, ## args)
115
147
#define ERR(fmt, args...) ERRMSG("Error: " fmt, ## args)
116
#define BUG(fmt, args...) ERRMSG("BUG: " fmt, ## args)
148
#define CRIT(fmt, args...) \
150
ERRMSG("Critical: " fmt, ## args); \
151
if (lttng_ust_logging_abort_on_critical_enabled()) { \
118
156
#if !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))