aboutsummaryrefslogtreecommitdiffstats
path: root/sway/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/log.c')
-rw-r--r--sway/log.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sway/log.c b/sway/log.c
index 62be73e5..2ad9657d 100644
--- a/sway/log.c
+++ b/sway/log.c
@@ -11,6 +11,7 @@
11#include <execinfo.h> 11#include <execinfo.h>
12 12
13int colored = 1; 13int colored = 1;
14log_importance_t loglevel_default = L_ERROR;
14log_importance_t v = L_SILENT; 15log_importance_t v = L_SILENT;
15 16
16static const char *verbosity_colors[] = { 17static const char *verbosity_colors[] = {
@@ -21,11 +22,29 @@ static const char *verbosity_colors[] = {
21}; 22};
22 23
23void init_log(log_importance_t verbosity) { 24void 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
35void set_log_level(log_importance_t verbosity) {
36 v = verbosity;
37}
38
39void reset_log_level(void) {
40 v = loglevel_default;
41}
42
43bool toggle_debug_logging(void) {
44 v = (v == L_DEBUG) ? loglevel_default : L_DEBUG;
45 return (v == L_DEBUG);
46}
47
29void sway_log_colors(int mode) { 48void sway_log_colors(int mode) {
30 colored = (mode == 1) ? 1 : 0; 49 colored = (mode == 1) ? 1 : 0;
31} 50}