diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-07-14 11:24:22 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-07-14 20:44:32 -0400 |
commit | b1afcc69fa70c20d815940fc25189063ed59ae0f (patch) | |
tree | b5876df0592a14729b09de80fc7fabfaf01065b4 /sway/main.c | |
parent | dbeb03aa680dde36bd917057a54dc2651b780f27 (diff) |
Add extended debugging flags
We currently have several ways of setting debug flags, including command
line arguments, environment variables, and compile-time macros. This
replaces the lot with command line flags.
Diffstat (limited to 'sway/main.c')
-rw-r--r-- | sway/main.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/sway/main.c b/sway/main.c index c6453226..1d772b48 100644 --- a/sway/main.c +++ b/sway/main.c @@ -251,6 +251,18 @@ static void drop_permissions(bool keep_caps) { #endif } +void enable_debug_flag(const char *flag) { + if (strcmp(flag, "render-tree") == 0) { + enable_debug_tree = true; + } else if (strncmp(flag, "damage=", 7) == 0) { + damage_debug = &flag[7]; + } else if (strcmp(flag, "txn-debug") == 0) { + txn_debug = true; + } else if (strncmp(flag, "txn-timeout=", 12) == 0) { + txn_timeout_ms = atoi(&flag[12]); + } +} + int main(int argc, char **argv) { static int verbose = 0, debug = 0, validate = 0; @@ -290,7 +302,7 @@ int main(int argc, char **argv) { int c; while (1) { int option_index = 0; - c = getopt_long(argc, argv, "hCdDvVc:", long_options, &option_index); + c = getopt_long(argc, argv, "hCdD:vVc:", long_options, &option_index); if (c == -1) { break; } @@ -309,7 +321,7 @@ int main(int argc, char **argv) { debug = 1; break; case 'D': // extended debug options - enable_debug_tree = true; + enable_debug_flag(optarg); break; case 'v': // version fprintf(stdout, "sway version " SWAY_VERSION "\n"); |