diff options
Diffstat (limited to 'sway/log.c')
-rw-r--r-- | sway/log.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -11,6 +11,7 @@ | |||
11 | #include <execinfo.h> | 11 | #include <execinfo.h> |
12 | 12 | ||
13 | int colored = 1; | 13 | int colored = 1; |
14 | log_importance_t loglevel_default = L_ERROR; | ||
14 | log_importance_t v = L_SILENT; | 15 | log_importance_t v = L_SILENT; |
15 | 16 | ||
16 | static const char *verbosity_colors[] = { | 17 | static const char *verbosity_colors[] = { |
@@ -21,11 +22,29 @@ static const char *verbosity_colors[] = { | |||
21 | }; | 22 | }; |
22 | 23 | ||
23 | void init_log(log_importance_t verbosity) { | 24 | void init_log(log_importance_t verbosity) { |
25 | if (verbosity != L_DEBUG) { | ||
26 | // command "debuglog" needs to know the user specified log level when | ||
27 | // turning off debug logging. | ||
28 | loglevel_default = verbosity; | ||
29 | } | ||
24 | v = verbosity; | 30 | v = verbosity; |
25 | signal(SIGSEGV, error_handler); | 31 | signal(SIGSEGV, error_handler); |
26 | signal(SIGABRT, error_handler); | 32 | signal(SIGABRT, error_handler); |
27 | } | 33 | } |
28 | 34 | ||
35 | void set_log_level(log_importance_t verbosity) { | ||
36 | v = verbosity; | ||
37 | } | ||
38 | |||
39 | void reset_log_level(void) { | ||
40 | v = loglevel_default; | ||
41 | } | ||
42 | |||
43 | bool toggle_debug_logging(void) { | ||
44 | v = (v == L_DEBUG) ? loglevel_default : L_DEBUG; | ||
45 | return (v == L_DEBUG); | ||
46 | } | ||
47 | |||
29 | void sway_log_colors(int mode) { | 48 | void sway_log_colors(int mode) { |
30 | colored = (mode == 1) ? 1 : 0; | 49 | colored = (mode == 1) ? 1 : 0; |
31 | } | 50 | } |