10
10
#include "common/logging.h"
12
12
int lttng_ust_log_level = LTTNG_UST_LOG_LEVEL_UNKNOWN;
13
int lttng_ust_log_critical_action = LTTNG_UST_LOG_CRITICAL_ACTION_UNKNOWN;
15
16
* Initialize the global log level from the "LTTNG_UST_DEBUG" environment
18
* This could end up being called concurently by multiple threads but doesn't
19
* This could end up being called concurrently by multiple threads but doesn't
19
20
* require a mutex since the input is invariant across threads and the result
20
21
* will be the same.
22
* Return the current log level to save the caller a second read of the global
25
int lttng_ust_logging_init(void)
24
void lttng_ust_logging_log_level_init(void)
27
26
char *lttng_ust_debug;
28
27
int current_log_level;
33
32
* Check early if we are initialized, this is unlikely as it's already tested
34
* in lttng_ust_debug_enabled before performing lazy initialization.
33
* in lttng_ust_logging_debug_enabled before performing lazy initialization.
36
35
if (caa_unlikely(current_log_level != LTTNG_UST_LOG_LEVEL_UNKNOWN))
40
39
* This getenv is not part of lttng_ust_getenv() because logging is
55
54
/* Initialize the log level */
56
55
CMM_STORE_SHARED(lttng_ust_log_level, current_log_level);
59
return current_log_level;
59
* Initialize the global log critical action from the "LTTNG_UST_ABORT_ON_CRITICAL"
60
* environment variable.
62
* This could end up being called concurrently by multiple threads but doesn't
63
* require a mutex since the input is invariant across threads and the result
67
void lttng_ust_logging_log_critical_action_init(void)
69
char *lttng_ust_abort_on_critical;
70
int current_log_critical_action;
72
current_log_critical_action = CMM_LOAD_SHARED(lttng_ust_log_critical_action);
75
* Check early if we are initialized, this is unlikely as it's already tested
76
* in lttng_ust_logging_abort_on_critical_enabled before performing lazy initialization.
78
if (caa_unlikely(current_log_critical_action != LTTNG_UST_LOG_CRITICAL_ACTION_UNKNOWN))
82
* This getenv is not part of lttng_ust_getenv() because logging is
83
* used in the getenv initialization and thus logging must be
84
* initialized prior to getenv.
86
lttng_ust_abort_on_critical = getenv("LTTNG_UST_ABORT_ON_CRITICAL");
89
* If the LTTNG_UST_ABORT_ON_CRITICAL environment variable is defined,
90
* call abort() on CRIT(), otherwise take no action.
92
if (lttng_ust_abort_on_critical)
93
current_log_critical_action = LTTNG_UST_LOG_CRITICAL_ACTION_ABORT;
95
current_log_critical_action = LTTNG_UST_LOG_CRITICAL_ACTION_NONE;
97
/* Initialize the log critical action */
98
CMM_STORE_SHARED(lttng_ust_log_critical_action, current_log_critical_action);
102
* Initialize the global log level from the "LTTNG_UST_DEBUG" environment
103
* variable and the global log critical action from "LTTNG_UST_ABORT_ON_CRITICAL".
105
* This could end up being called concurrently by multiple threads but doesn't
106
* require a mutex since the input is invariant across threads and the result
109
void lttng_ust_logging_init(void)
111
lttng_ust_logging_log_level_init();
112
lttng_ust_logging_log_critical_action_init();