diff options
| author | Arnout Engelen <arnout@bzzt.net> | 2022-11-18 00:04:00 +0100 |
|---|---|---|
| committer | Simon Ser <contact@emersion.fr> | 2023-01-03 16:34:53 +0100 |
| commit | d5eb85ba1c0231a8a069215ae3c23d070072f53a (patch) | |
| tree | 2e4ff429a4a9e390738d2fa11b855581dc6dbeb0 /main.c | |
| parent | 84598b08f21ae607810044f39caf9e0569cf2087 (diff) | |
Parse `--debug` parameter before forking
To make sure the backend picks up the loglevel as well
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -1135,8 +1135,34 @@ static void term_in(int fd, short mask, void *data) { state.run_display = false; } -int main(int argc, char **argv) { +// Check for --debug 'early' we also apply the correct loglevel +// to the forked child, without having to first proces all of the +// configuration (including from file) before forking and (in the +// case of the shadow backend) dropping privileges +void log_init(int argc, char **argv) { + static struct option long_options[] = { + {"debug", no_argument, NULL, 'd'}, + {0, 0, 0, 0} + }; + int c; + optind = 1; + while (1) { + int opt_idx = 0; + c = getopt_long(argc, argv, "d", long_options, &opt_idx); + if (c == -1) { + break; + } + switch (c) { + case 'd': + swaylock_log_init(LOG_DEBUG); + return; + } + } swaylock_log_init(LOG_ERROR); +} + +int main(int argc, char **argv) { + log_init(argc, argv); initialize_pw_backend(argc, argv); srand(time(NULL)); |
