diff options
author | S. Christoffer Eliesen <christoffer@eliesen.no> | 2015-10-26 13:41:45 +0100 |
---|---|---|
committer | S. Christoffer Eliesen <christoffer@eliesen.no> | 2015-10-27 14:37:44 +0100 |
commit | 9f02b0bf16972dfb7a18610e5096d4576e447a48 (patch) | |
tree | b128d385d9c1889a9ad8e57751e3aab66c2994dc /sway/commands.c | |
parent | Merge pull request #204 from sce/misc_stuff (diff) | |
download | sway-9f02b0bf16972dfb7a18610e5096d4576e447a48.tar.gz sway-9f02b0bf16972dfb7a18610e5096d4576e447a48.tar.zst sway-9f02b0bf16972dfb7a18610e5096d4576e447a48.zip |
commands: Learn 'debuglog'.
Replicates i3 option. Verbosity level given as command line argument
becomes default log level, and using 'debuglog toggle' switches back and
forth between default and debug (or L_ERROR and debug if default is also
L_DEBUG).
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sway/commands.c b/sway/commands.c index 0102fc5a..c81379fd 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -30,6 +30,7 @@ struct cmd_handler { | |||
30 | 30 | ||
31 | static sway_cmd cmd_bindsym; | 31 | static sway_cmd cmd_bindsym; |
32 | static sway_cmd cmd_orientation; | 32 | static sway_cmd cmd_orientation; |
33 | static sway_cmd cmd_debuglog; | ||
33 | static sway_cmd cmd_exec; | 34 | static sway_cmd cmd_exec; |
34 | static sway_cmd cmd_exec_always; | 35 | static sway_cmd cmd_exec_always; |
35 | static sway_cmd cmd_exit; | 36 | static sway_cmd cmd_exit; |
@@ -229,6 +230,28 @@ static struct cmd_results *cmd_exec_always(int argc, char **argv) { | |||
229 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 230 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
230 | } | 231 | } |
231 | 232 | ||
233 | static struct cmd_results *cmd_debuglog(int argc, char **argv) { | ||
234 | struct cmd_results *error = NULL; | ||
235 | if ((error = checkarg(argc, "debuglog", EXPECTED_EQUAL_TO, 1))) { | ||
236 | return error; | ||
237 | } else if (strcasecmp(argv[0], "toggle") == 0) { | ||
238 | if (config->reading) { | ||
239 | return cmd_results_new(CMD_FAILURE, "debuglog toggle", "Can't be used in config file."); | ||
240 | } | ||
241 | if (toggle_debug_logging()) { | ||
242 | sway_log(L_DEBUG, "Debuglog turned on."); | ||
243 | } | ||
244 | } else if (strcasecmp(argv[0], "on") == 0) { | ||
245 | set_log_level(L_DEBUG); | ||
246 | sway_log(L_DEBUG, "Debuglog turned on."); | ||
247 | } else if (strcasecmp(argv[0], "off") == 0) { | ||
248 | reset_log_level(); | ||
249 | } else { | ||
250 | return cmd_results_new(CMD_FAILURE, "debuglog", "Expected 'debuglog on|off|toggle'"); | ||
251 | } | ||
252 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
253 | } | ||
254 | |||
232 | static struct cmd_results *cmd_exec(int argc, char **argv) { | 255 | static struct cmd_results *cmd_exec(int argc, char **argv) { |
233 | if (!config->active) return cmd_results_new(CMD_DEFER, "exec", NULL); | 256 | if (!config->active) return cmd_results_new(CMD_DEFER, "exec", NULL); |
234 | if (config->reloading) { | 257 | if (config->reloading) { |
@@ -1162,6 +1185,7 @@ static struct cmd_results *cmd_ws_auto_back_and_forth(int argc, char **argv) { | |||
1162 | /* Keep alphabetized */ | 1185 | /* Keep alphabetized */ |
1163 | static struct cmd_handler handlers[] = { | 1186 | static struct cmd_handler handlers[] = { |
1164 | { "bindsym", cmd_bindsym }, | 1187 | { "bindsym", cmd_bindsym }, |
1188 | { "debuglog", cmd_debuglog }, | ||
1165 | { "default_orientation", cmd_orientation }, | 1189 | { "default_orientation", cmd_orientation }, |
1166 | { "exec", cmd_exec }, | 1190 | { "exec", cmd_exec }, |
1167 | { "exec_always", cmd_exec_always }, | 1191 | { "exec_always", cmd_exec_always }, |