From 40d67b13d9be10bf9adb3db50eec51ecbe56c022 Mon Sep 17 00:00:00 2001 From: David Eklov Date: Mon, 27 Jun 2016 02:29:37 -0500 Subject: [PATCH] Add get_log_level() to encapsulate v (current log level) This patch also makes all global variable in log.c static. --- common/log.c | 10 +++++++--- include/log.h | 1 + sway/debug_log.c | 4 +--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/common/log.c b/common/log.c index 018ba7ac..492ec33d 100644 --- a/common/log.c +++ b/common/log.c @@ -10,9 +10,9 @@ #include #include -int colored = 1; -log_importance_t loglevel_default = L_ERROR; -log_importance_t v = L_SILENT; +static int colored = 1; +static log_importance_t loglevel_default = L_ERROR; +static log_importance_t v = L_SILENT; static const char *verbosity_colors[] = { [L_SILENT] = "", @@ -36,6 +36,10 @@ void set_log_level(log_importance_t verbosity) { v = verbosity; } +log_importance_t get_log_level(void) { + return v; +} + void reset_log_level(void) { v = loglevel_default; } diff --git a/include/log.h b/include/log.h index 266920f5..798cf1df 100644 --- a/include/log.h +++ b/include/log.h @@ -13,6 +13,7 @@ typedef enum { void init_log(log_importance_t verbosity); void set_log_level(log_importance_t verbosity); +log_importance_t get_log_level(void); void reset_log_level(void); // returns whether debug logging is on after switching. bool toggle_debug_logging(void); diff --git a/sway/debug_log.c b/sway/debug_log.c index f804a541..7c988464 100644 --- a/sway/debug_log.c +++ b/sway/debug_log.c @@ -12,8 +12,6 @@ #include #include "workspace.h" -extern log_importance_t v; - /* XXX:DEBUG:XXX */ static void container_log(const swayc_t *c, int depth) { fprintf(stderr, "focus:%c", @@ -49,7 +47,7 @@ static void container_log(const swayc_t *c, int depth) { fprintf(stderr, "name:%.16s\n", c->name); } void layout_log(const swayc_t *c, int depth) { - if (L_DEBUG > v) return; + if (L_DEBUG > get_log_level()) return; int i, d; int e = c->children ? c->children->length : 0; container_log(c, depth);