Merge pull request #728 from deklov/master

Add get_log_level() to encapsulate v (current log level)
master
Drew DeVault 9 years ago committed by GitHub
commit b5d778dd82

@ -12,9 +12,9 @@
#include <string.h> #include <string.h>
#include <stringop.h> #include <stringop.h>
int colored = 1; static int colored = 1;
log_importance_t loglevel_default = L_ERROR; static log_importance_t loglevel_default = L_ERROR;
log_importance_t v = L_SILENT; static log_importance_t v = L_SILENT;
static const char *verbosity_colors[] = { static const char *verbosity_colors[] = {
[L_SILENT] = "", [L_SILENT] = "",
@ -38,6 +38,10 @@ void set_log_level(log_importance_t verbosity) {
v = verbosity; v = verbosity;
} }
log_importance_t get_log_level(void) {
return v;
}
void reset_log_level(void) { void reset_log_level(void) {
v = loglevel_default; v = loglevel_default;
} }

@ -11,6 +11,7 @@ typedef enum {
void init_log(log_importance_t verbosity); void init_log(log_importance_t verbosity);
void set_log_level(log_importance_t verbosity); void set_log_level(log_importance_t verbosity);
log_importance_t get_log_level(void);
void reset_log_level(void); void reset_log_level(void);
// returns whether debug logging is on after switching. // returns whether debug logging is on after switching.
bool toggle_debug_logging(void); bool toggle_debug_logging(void);

@ -12,8 +12,6 @@
#include <stringop.h> #include <stringop.h>
#include "workspace.h" #include "workspace.h"
extern log_importance_t v;
/* XXX:DEBUG:XXX */ /* XXX:DEBUG:XXX */
static void container_log(const swayc_t *c, int depth) { static void container_log(const swayc_t *c, int depth) {
fprintf(stderr, "focus:%c", 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); fprintf(stderr, "name:%.16s\n", c->name);
} }
void layout_log(const swayc_t *c, int depth) { 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 i, d;
int e = c->children ? c->children->length : 0; int e = c->children ? c->children->length : 0;
container_log(c, depth); container_log(c, depth);

Loading…
Cancel
Save