#define ENV_LOG_PRINT_LEVEL "PULSE_LOG_LEVEL"
#define ENV_LOG_BACKTRACE "PULSE_LOG_BACKTRACE"
#define ENV_LOG_BACKTRACE_SKIP "PULSE_LOG_BACKTRACE_SKIP"
+#define ENV_LOG_NO_RATELIMIT "PULSE_LOG_NO_RATE_LIMIT"
static char *ident = NULL; /* in local charset format */
static pa_log_target_t target = PA_LOG_STDERR, target_override;
static pa_log_level_t maximum_level = PA_LOG_ERROR, maximum_level_override = PA_LOG_ERROR;
static unsigned show_backtrace = 0, show_backtrace_override = 0, skip_backtrace = 0;
static pa_log_flags_t flags = 0, flags_override = 0;
+static pa_bool_t no_rate_limit = FALSE;
#ifdef HAVE_SYSLOG_H
static const int level_to_syslog[] = {
#endif
static void init_defaults(void) {
- const char *e;
+ PA_ONCE_BEGIN {
- if (!ident) {
- char binary[256];
- if (pa_get_binary_name(binary, sizeof(binary)))
- pa_log_set_ident(binary);
- }
+ const char *e;
- if (getenv(ENV_LOG_SYSLOG)) {
- target_override = PA_LOG_SYSLOG;
- target_override_set = TRUE;
- }
+ if (!ident) {
+ char binary[256];
+ if (pa_get_binary_name(binary, sizeof(binary)))
+ pa_log_set_ident(binary);
+ }
- if ((e = getenv(ENV_LOG_LEVEL))) {
- maximum_level_override = (pa_log_level_t) atoi(e);
+ if (getenv(ENV_LOG_SYSLOG)) {
+ target_override = PA_LOG_SYSLOG;
+ target_override_set = TRUE;
+ }
- if (maximum_level_override >= PA_LOG_LEVEL_MAX)
- maximum_level_override = PA_LOG_LEVEL_MAX-1;
- }
+ if ((e = getenv(ENV_LOG_LEVEL))) {
+ maximum_level_override = (pa_log_level_t) atoi(e);
- if (getenv(ENV_LOG_COLORS))
- flags_override |= PA_LOG_COLORS;
+ if (maximum_level_override >= PA_LOG_LEVEL_MAX)
+ maximum_level_override = PA_LOG_LEVEL_MAX-1;
+ }
- if (getenv(ENV_LOG_PRINT_TIME))
- flags_override |= PA_LOG_PRINT_TIME;
+ if (getenv(ENV_LOG_COLORS))
+ flags_override |= PA_LOG_COLORS;
- if (getenv(ENV_LOG_PRINT_FILE))
- flags_override |= PA_LOG_PRINT_FILE;
+ if (getenv(ENV_LOG_PRINT_TIME))
+ flags_override |= PA_LOG_PRINT_TIME;
- if (getenv(ENV_LOG_PRINT_META))
- flags_override |= PA_LOG_PRINT_META;
+ if (getenv(ENV_LOG_PRINT_FILE))
+ flags_override |= PA_LOG_PRINT_FILE;
- if (getenv(ENV_LOG_PRINT_LEVEL))
- flags_override |= PA_LOG_PRINT_LEVEL;
+ if (getenv(ENV_LOG_PRINT_META))
+ flags_override |= PA_LOG_PRINT_META;
- if ((e = getenv(ENV_LOG_BACKTRACE))) {
- show_backtrace_override = (unsigned) atoi(e);
+ if (getenv(ENV_LOG_PRINT_LEVEL))
+ flags_override |= PA_LOG_PRINT_LEVEL;
- if (show_backtrace_override <= 0)
- show_backtrace_override = 0;
- }
+ if ((e = getenv(ENV_LOG_BACKTRACE))) {
+ show_backtrace_override = (unsigned) atoi(e);
- if ((e = getenv(ENV_LOG_BACKTRACE_SKIP))) {
- skip_backtrace = (unsigned) atoi(e);
+ if (show_backtrace_override <= 0)
+ show_backtrace_override = 0;
+ }
- if (skip_backtrace <= 0)
- skip_backtrace = 0;
- }
+ if ((e = getenv(ENV_LOG_BACKTRACE_SKIP))) {
+ skip_backtrace = (unsigned) atoi(e);
+
+ if (skip_backtrace <= 0)
+ skip_backtrace = 0;
+ }
+
+ if (getenv(ENV_LOG_NO_RATELIMIT))
+ no_rate_limit = TRUE;
+
+ } PA_ONCE_END;
}
void pa_log_levelv_meta(
pa_assert(level < PA_LOG_LEVEL_MAX);
pa_assert(format);
- PA_ONCE_BEGIN {
- init_defaults();
- } PA_ONCE_END;
+ init_defaults();
_target = target_override_set ? target_override : target;
_maximum_level = PA_MAX(maximum_level, maximum_level_override);
/* Not more than 10 messages every 5s */
static PA_DEFINE_RATELIMIT(ratelimit, 5 * PA_USEC_PER_SEC, 10);
+ init_defaults();
+
+ if (no_rate_limit)
+ return TRUE;
+
return pa_ratelimit_test(&ratelimit);
}