Skip to content

Commit

Permalink
Add --debug and --quiet log level flags
Browse files Browse the repository at this point in the history
  • Loading branch information
serebit committed Jul 4, 2024
1 parent a45eaf8 commit 8f494e1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ int32_t run_compositor(const std::vector<std::string>& startup_cmds, std::promis
int32_t main(const int32_t argc, char** argv) {
auto argparser = argparse::ArgumentParser(argv[0], PROJECT_VERSION);

auto& logging_group = argparser.add_mutually_exclusive_group();
logging_group.add_argument("-d", "--debug").help("enable full logging").nargs(0);
logging_group.add_argument("-q", "--quiet").help("suppress informational messages").nargs(0);

auto& subprocess_group = argparser.add_mutually_exclusive_group();
subprocess_group.add_argument("-k", "--kiosk")
.help("specify a single executable whose lifecycle will be adopted, such as a login manager")
Expand Down Expand Up @@ -80,7 +84,13 @@ int32_t main(const int32_t argc, char** argv) {
return 1;
}

wlr_log_init(WLR_INFO, nullptr);
if (argparser.is_used("--debug")) {
wlr_log_init(WLR_DEBUG, nullptr);
} else if (argparser.is_used("--quiet")) {
wlr_log_init(WLR_ERROR, nullptr);
} else {
wlr_log_init(WLR_INFO, nullptr);
}

if (kiosk_cmd.has_value()) {
wlr_log(WLR_INFO, "Running in kiosk mode with command '%s'.", kiosk_cmd->c_str());
Expand Down
4 changes: 2 additions & 2 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ exe = executable(

glxgears = find_program('glxgears', required: false)
if glxgears.found()
test('glxgears', exe, args: ['-k', 'sh -c "timeout 5 glxgears"'])
test('glxgears', exe, args: ['--debug', '--kiosk', 'sh -c "timeout 5 glxgears"'])
endif

vkgears = find_program('vkgears', required: false)
if vkgears.found()
test('vkgears', exe, args: ['-k', 'sh -c "timeout 5 vkgears"'])
test('vkgears', exe, args: ['--debug', '--kiosk', 'sh -c "timeout 5 vkgears"'])
endif

0 comments on commit 8f494e1

Please sign in to comment.