From 4c2b6c7c9199fd4fad4a70e05c5e6de483d2e995 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 6 Jun 2019 15:12:59 +0200 Subject: [PATCH] log: add log level option --- spa/include/spa/support/log.h | 1 + spa/plugins/support/logger.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/spa/include/spa/support/log.h b/spa/include/spa/support/log.h index 4346b9ae3..74a2fef10 100644 --- a/spa/include/spa/support/log.h +++ b/spa/include/spa/support/log.h @@ -163,6 +163,7 @@ static inline void spa_log_trace_fp (struct spa_log *l, const char *format, ...) #endif /** keys can be given when initializing the logger handle */ +#define SPA_KEY_LOG_LEVEL "log.level" /**< the default log level */ #define SPA_KEY_LOG_COLORS "log.colors" /**< enable colors in the logger */ #define SPA_KEY_LOG_FILE "log.file" /**< log to the specified file instead of * stderr. */ diff --git a/spa/plugins/support/logger.c b/spa/plugins/support/logger.c index 18561837f..839f2da20 100644 --- a/spa/plugins/support/logger.c +++ b/spa/plugins/support/logger.c @@ -228,6 +228,8 @@ impl_init(const struct spa_handle_factory *factory, if (info) { if ((str = spa_dict_lookup(info, SPA_KEY_LOG_COLORS)) != NULL) this->colors = (strcmp(str, "true") == 0 || atoi(str) == 1); + if ((str = spa_dict_lookup(info, SPA_KEY_LOG_LEVEL)) != NULL) + this->log.level = atoi(str); if ((str = spa_dict_lookup(info, SPA_KEY_LOG_FILE)) != NULL) { this->file = fopen(str, "w"); if (this->file == NULL)