diff options
author | David Eklov <david.eklov@gmail.com> | 2016-06-27 02:29:37 -0500 |
---|---|---|
committer | David Eklov <david.eklov@gmail.com> | 2016-06-27 18:56:50 -0500 |
commit | 26842ff3833c853e3e3cef065a494c05736a53e5 (patch) | |
tree | d576aeed92f5819b1e873539e6151509eeec529d | |
parent | Bug fix: Add missing header file, unistd.h (diff) | |
download | sway-26842ff3833c853e3e3cef065a494c05736a53e5.tar.gz sway-26842ff3833c853e3e3cef065a494c05736a53e5.tar.zst sway-26842ff3833c853e3e3cef065a494c05736a53e5.zip |
Add get_log_level() to encapsulate v (current log level)
This patch also makes all global variable in log.c static.
-rw-r--r-- | common/log.c | 10 | ||||
-rw-r--r-- | include/log.h | 1 | ||||
-rw-r--r-- | sway/debug_log.c | 4 |
3 files changed, 9 insertions, 6 deletions
diff --git a/common/log.c b/common/log.c index ef791bec..56c3834a 100644 --- a/common/log.c +++ b/common/log.c | |||
@@ -12,9 +12,9 @@ | |||
12 | #include <string.h> | 12 | #include <string.h> |
13 | #include <stringop.h> | 13 | #include <stringop.h> |
14 | 14 | ||
15 | int colored = 1; | 15 | static int colored = 1; |
16 | log_importance_t loglevel_default = L_ERROR; | 16 | static log_importance_t loglevel_default = L_ERROR; |
17 | log_importance_t v = L_SILENT; | 17 | static log_importance_t v = L_SILENT; |
18 | 18 | ||
19 | static const char *verbosity_colors[] = { | 19 | static const char *verbosity_colors[] = { |
20 | [L_SILENT] = "", | 20 | [L_SILENT] = "", |
@@ -38,6 +38,10 @@ void set_log_level(log_importance_t verbosity) { | |||
38 | v = verbosity; | 38 | v = verbosity; |
39 | } | 39 | } |
40 | 40 | ||
41 | log_importance_t get_log_level(void) { | ||
42 | return v; | ||
43 | } | ||
44 | |||
41 | void reset_log_level(void) { | 45 | void reset_log_level(void) { |
42 | v = loglevel_default; | 46 | v = loglevel_default; |
43 | } | 47 | } |
diff --git a/include/log.h b/include/log.h index efacf90f..ca8c1fe3 100644 --- a/include/log.h +++ b/include/log.h | |||
@@ -11,6 +11,7 @@ typedef enum { | |||
11 | 11 | ||
12 | void init_log(log_importance_t verbosity); | 12 | void init_log(log_importance_t verbosity); |
13 | void set_log_level(log_importance_t verbosity); | 13 | void set_log_level(log_importance_t verbosity); |
14 | log_importance_t get_log_level(void); | ||
14 | void reset_log_level(void); | 15 | void reset_log_level(void); |
15 | // returns whether debug logging is on after switching. | 16 | // returns whether debug logging is on after switching. |
16 | bool toggle_debug_logging(void); | 17 | 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 @@ | |||
12 | #include <stringop.h> | 12 | #include <stringop.h> |
13 | #include "workspace.h" | 13 | #include "workspace.h" |
14 | 14 | ||
15 | extern log_importance_t v; | ||
16 | |||
17 | /* XXX:DEBUG:XXX */ | 15 | /* XXX:DEBUG:XXX */ |
18 | static void container_log(const swayc_t *c, int depth) { | 16 | static void container_log(const swayc_t *c, int depth) { |
19 | fprintf(stderr, "focus:%c", | 17 | fprintf(stderr, "focus:%c", |
@@ -49,7 +47,7 @@ static void container_log(const swayc_t *c, int depth) { | |||
49 | fprintf(stderr, "name:%.16s\n", c->name); | 47 | fprintf(stderr, "name:%.16s\n", c->name); |
50 | } | 48 | } |
51 | void layout_log(const swayc_t *c, int depth) { | 49 | void layout_log(const swayc_t *c, int depth) { |
52 | if (L_DEBUG > v) return; | 50 | if (L_DEBUG > get_log_level()) return; |
53 | int i, d; | 51 | int i, d; |
54 | int e = c->children ? c->children->length : 0; | 52 | int e = c->children ? c->children->length : 0; |
55 | container_log(c, depth); | 53 | container_log(c, depth); |