From b374c35758777f98e5ddbe4b0dc43bd7c80f36d7 Mon Sep 17 00:00:00 2001 From: Zandr Martin Date: Thu, 1 Sep 2016 21:39:08 -0500 Subject: refactor commands.c --- sway/commands/debuglog.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 sway/commands/debuglog.c (limited to 'sway/commands/debuglog.c') diff --git a/sway/commands/debuglog.c b/sway/commands/debuglog.c new file mode 100644 index 00000000..55749797 --- /dev/null +++ b/sway/commands/debuglog.c @@ -0,0 +1,26 @@ +#include +#include "commands.h" +#include "log.h" + +struct cmd_results *cmd_debuglog(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "debuglog", EXPECTED_EQUAL_TO, 1))) { + return error; + } else if (strcasecmp(argv[0], "toggle") == 0) { + if (config->reading) { + return cmd_results_new(CMD_FAILURE, "debuglog toggle", "Can't be used in config file."); + } + if (toggle_debug_logging()) { + sway_log(L_DEBUG, "Debuglog turned on."); + } + } else if (strcasecmp(argv[0], "on") == 0) { + set_log_level(L_DEBUG); + sway_log(L_DEBUG, "Debuglog turned on."); + } else if (strcasecmp(argv[0], "off") == 0) { + reset_log_level(); + } else { + return cmd_results_new(CMD_FAILURE, "debuglog", "Expected 'debuglog on|off|toggle'"); + } + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} + -- cgit v1.2.3 From 65ace5dec5c24695501056376e227fb9b1f84a3a Mon Sep 17 00:00:00 2001 From: Zandr Martin Date: Fri, 2 Sep 2016 14:11:48 -0500 Subject: merge in latest commits --- sway/commands/debuglog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sway/commands/debuglog.c') diff --git a/sway/commands/debuglog.c b/sway/commands/debuglog.c index 55749797..76192fb0 100644 --- a/sway/commands/debuglog.c +++ b/sway/commands/debuglog.c @@ -1,5 +1,5 @@ #include -#include "commands.h" +#include "sway/commands.h" #include "log.h" struct cmd_results *cmd_debuglog(int argc, char **argv) { -- cgit v1.2.3