diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-01-23 23:58:57 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-01-23 23:58:57 +0100 |
commit | 77c4ccfcaff95f25be373e036999869746ed81a7 (patch) | |
tree | 2cc2528a1079276e3c181b77461ebef09c23fe01 /src/pulsecore/log.c | |
parent | 3dfe70cf7887cfb288e4423358350ef4511506b5 (diff) |
add pa_log_rate_limit()
Diffstat (limited to 'src/pulsecore/log.c')
-rw-r--r-- | src/pulsecore/log.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/pulsecore/log.c b/src/pulsecore/log.c index adf2f112..9a7f7cac 100644 --- a/src/pulsecore/log.c +++ b/src/pulsecore/log.c @@ -47,6 +47,7 @@ #include <pulsecore/core-util.h> #include <pulsecore/rtclock.h> #include <pulsecore/once.h> +#include <pulsecore/ratelimit.h> #include "log.h" @@ -375,3 +376,10 @@ void pa_log_level(pa_log_level_t level, const char *format, ...) { pa_log_levelv_meta(level, NULL, 0, NULL, format, ap); va_end(ap); } + +pa_bool_t pa_log_ratelimit(void) { + /* Not more than 10 messages every 5s */ + static PA_DEFINE_RATELIMIT(ratelimit, 5 * PA_USEC_PER_SEC, 10); + + return pa_ratelimit_test(&ratelimit); +} |