aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorCalvin Lee <cyrus296@gmail.com>2017-12-31 14:29:05 -0700
committerCalvin Lee <cyrus296@gmail.com>2017-12-31 14:50:19 -0700
commit5a26ed645abd1b1f2582c42e017cf2b043fdb0c3 (patch)
treef6a6e82ee67e59abc1005c3582e8873f02b2fcff /util
parent80ed4d4d20807f021c473b77d44ce6b464afc0c7 (diff)
Allow configurable verbosity
Diffstat (limited to 'util')
-rw-r--r--util/log.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/util/log.c b/util/log.c
index 3661b73c..e0b6a132 100644
--- a/util/log.c
+++ b/util/log.c
@@ -9,6 +9,7 @@
#include <wlr/util/log.h>
static bool colored = true;
+static log_importance_t log_importance = L_ERROR;
static const char *verbosity_colors[] = {
[L_SILENT] = "",
@@ -18,6 +19,9 @@ static const char *verbosity_colors[] = {
};
void wlr_log_stderr(log_importance_t verbosity, const char *fmt, va_list args) {
+ if (verbosity > log_importance) {
+ return;
+ }
// prefix the time to the log message
struct tm result;
time_t t = time(NULL);
@@ -44,8 +48,13 @@ void wlr_log_stderr(log_importance_t verbosity, const char *fmt, va_list args) {
static log_callback_t log_callback = wlr_log_stderr;
-void wlr_log_init(log_callback_t callback) {
- log_callback = callback;
+void wlr_log_init(log_importance_t verbosity, log_callback_t callback) {
+ if (verbosity < L_LAST) {
+ log_importance = verbosity;
+ }
+ if (callback) {
+ log_callback = callback;
+ }
}
void _wlr_vlog(log_importance_t verbosity, const char *fmt, va_list args) {