Add log level argument to ratelimit_test function

If a log message is rate limited, we only need to know about it if we
are actually interested in that log level. We therefore add an argument
to the ratelimit_test function to set the log level of the message
printed if a message is skipped

Change-Id: I5ccd4a78bf7e972fe8b0e7133cd7e08c1e38835f
This commit is contained in:
Torkel Niklasson 2021-08-12 16:56:10 +02:00 committed by Wim Taymans
parent be6824cb15
commit eff67c3c03
3 changed files with 5 additions and 5 deletions

View file

@ -81,11 +81,11 @@ struct ratelimit {
unsigned n_printed, n_missed;
};
static inline bool ratelimit_test(struct ratelimit *r, uint64_t now)
static inline bool ratelimit_test(struct ratelimit *r, uint64_t now, enum spa_log_level level)
{
if (r->begin + r->interval < now) {
if (r->n_missed)
pw_log_warn("%u events suppressed", r->n_missed);
pw_log(level, "%u events suppressed", r->n_missed);
r->begin = now;
r->n_printed = 0;
r->n_missed = 0;