From: Alexander Berntsen Date: Wed, 5 Jun 2013 13:06:53 +0000 (+0200) Subject: Implement debuglog command X-Git-Tag: 4.6~8 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=023594909ef74249b8e03bc6f1a3074fba5b8828;p=i3%2Fi3 Implement debuglog command Add debuglog command that takes toggle|on|off. Add get_debug_logging() to be able to toggle. Make t/187-commands-parser.t expect 'debuglog'. Document the debuglog command in userguide. --- diff --git a/docs/userguide b/docs/userguide index 60345bec..aafea440 100644 --- a/docs/userguide +++ b/docs/userguide @@ -1762,6 +1762,8 @@ stack-limit rows 5 image:stacklimit.png[Container limited to two columns] /////////////////////////////////////////////////////////////////////////////// +[[shmlog]] + === Enabling shared memory logging As described in http://i3wm.org/docs/debugging.html, i3 can log to a shared @@ -1787,6 +1789,24 @@ bindsym $mod+x shmlog toggle i3-msg shmlog $((50*1024*1024)) --------------- +=== Enabling debug logging + +The +debuglog+ command allows you to enable or disable debug logging at +runtime. Debug logging is much more verbose than non-debug logging. This +command does not activate shared memory logging (shmlog), and as such is most +likely useful in combination with the above-described <> command. + +*Syntax*: +------------------------ +debuglog +------------------------ + +*Examples*: +------------ +# Enable/disable logging +bindsym $mod+x debuglog toggle +------------ + === Reloading/Restarting/Exiting You can make i3 reload its configuration file with +reload+. You can also diff --git a/include/commands.h b/include/commands.h index a09e7466..21f22389 100644 --- a/include/commands.h +++ b/include/commands.h @@ -277,4 +277,10 @@ void cmd_bar(I3_CMD, char *bar_type, char *bar_value, char *bar_id); */ void cmd_shmlog(I3_CMD, char *argument); +/* + * Implementation of 'debuglog toggle|on|off' + * + */ +void cmd_debuglog(I3_CMD, char *argument); + #endif diff --git a/include/log.h b/include/log.h index c9d1d0cd..c8e3c8ef 100644 --- a/include/log.h +++ b/include/log.h @@ -50,6 +50,12 @@ void open_logbuffer(void); */ void close_logbuffer(void); +/** + * Checks if debug logging is active. + * + */ +bool get_debug_logging(void); + /** * Set debug logging. * diff --git a/parser-specs/commands.spec b/parser-specs/commands.spec index 4407158c..88fbfe61 100644 --- a/parser-specs/commands.spec +++ b/parser-specs/commands.spec @@ -20,6 +20,7 @@ state INITIAL: 'restart' -> call cmd_restart() 'reload' -> call cmd_reload() 'shmlog' -> SHMLOG + 'debuglog' -> DEBUGLOG 'border' -> BORDER 'layout' -> LAYOUT 'append_layout' -> APPEND_LAYOUT @@ -69,6 +70,11 @@ state SHMLOG: argument = string -> call cmd_shmlog($argument) +# debuglog toggle|on|off +state DEBUGLOG: + argument = 'toggle', 'on', 'off' + -> call cmd_debuglog($argument) + # border normal|none|1pixel|toggle|1pixel state BORDER: border_style = 'normal', 'pixel' diff --git a/src/commands.c b/src/commands.c index fbe4b117..07af1404 100644 --- a/src/commands.c +++ b/src/commands.c @@ -2059,3 +2059,23 @@ void cmd_shmlog(I3_CMD, char *argument) { // XXX: default reply for now, make this a better reply ysuccess(true); } + +/* + * Implementation of 'debuglog toggle|on|off' + * + */ +void cmd_debuglog(I3_CMD, char *argument) { + bool logging = get_debug_logging(); + if (!strcmp(argument,"toggle")) { + LOG("%s debug logging\n", logging ? "Disabling" : "Enabling"); + set_debug_logging(!logging); + } else if (!strcmp(argument, "on") && !logging) { + LOG("Enabling debug logging\n"); + set_debug_logging(true); + } else if (!strcmp(argument, "off") && logging) { + LOG("Disabling debug logging\n"); + set_debug_logging(false); + } + // XXX: default reply for now, make this a better reply + ysuccess(true); +} diff --git a/src/log.c b/src/log.c index 68131af8..e0679e15 100644 --- a/src/log.c +++ b/src/log.c @@ -180,6 +180,14 @@ void set_verbosity(bool _verbose) { verbose = _verbose; } +/* + * Get debug logging. + * + */ +bool get_debug_logging(void) { + return debug_logging; +} + /* * Set debug logging. * diff --git a/testcases/t/187-commands-parser.t b/testcases/t/187-commands-parser.t index a6bb1c5a..3e976996 100644 --- a/testcases/t/187-commands-parser.t +++ b/testcases/t/187-commands-parser.t @@ -144,7 +144,7 @@ is(parser_calls("\nworkspace test"), ################################################################################ is(parser_calls('unknown_literal'), - "ERROR: Expected one of these tokens: , '[', 'move', 'exec', 'exit', 'restart', 'reload', 'shmlog', 'border', 'layout', 'append_layout', 'workspace', 'focus', 'kill', 'open', 'fullscreen', 'split', 'floating', 'mark', 'resize', 'rename', 'nop', 'scratchpad', 'mode', 'bar'\n" . + "ERROR: Expected one of these tokens: , '[', 'move', 'exec', 'exit', 'restart', 'reload', 'shmlog', 'debuglog', 'border', 'layout', 'append_layout', 'workspace', 'focus', 'kill', 'open', 'fullscreen', 'split', 'floating', 'mark', 'resize', 'rename', 'nop', 'scratchpad', 'mode', 'bar'\n" . "ERROR: Your command: unknown_literal\n" . "ERROR: ^^^^^^^^^^^^^^^", 'error for unknown literal ok');