From 194a090d927792032212a9c353b8260112fba203 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Mon, 1 Apr 2024 16:21:44 +0200 Subject: [PATCH] Add CLI flag for verbose logging --- CHANGELOG.md | 1 + buffyboard/README.md | 1 + buffyboard/command_line.c | 8 +++++++- buffyboard/command_line.h | 2 ++ buffyboard/main.c | 6 ++++++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cec4697..3a717c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ If a change only affects particular applications, they are listed in parentheses - feat(buffyboard): Add fbdev force-refresh quirk via config - feat(buffyboard): Allow disabling input devices via config - feat(buffyboard): Add CLI flags for overriding geometry & DPI +- feat(buffyboard): Add CLI flag for verbose logging - fix(unl0kr): Shutdown message box doesn't close on decline - fix(unl0kr): Shutdown message box buttons and label are unstyled - fix(unl0kr): Build fails when DRM is disabled diff --git a/buffyboard/README.md b/buffyboard/README.md index 648d464..3c47eef 100644 --- a/buffyboard/README.md +++ b/buffyboard/README.md @@ -59,6 +59,7 @@ Mandatory arguments to long options are mandatory for short options too. * 2 - upside down orientation (180 degrees) * 3 - counterclockwise orientation (270 degrees) -h, --help Print this message and exit + -v, --verbose Enable more detailed logging output on STDERR -V, --version Print the buffyboard version and exit ``` diff --git a/buffyboard/command_line.c b/buffyboard/command_line.c index 747aa9c..b849876 100644 --- a/buffyboard/command_line.c +++ b/buffyboard/command_line.c @@ -45,6 +45,7 @@ static void init_opts(bb_cli_opts *opts) { opts->y_offset = 0; opts->dpi = 0; opts->rotation = LV_DISPLAY_ROTATION_0; + opts->verbose = false; } static void print_usage() { @@ -71,6 +72,7 @@ static void print_usage() { " * 2 - upside down orientation (180 degrees)\n" " * 3 - counterclockwise orientation (270 degrees)\n" " -h, --help Print this message and exit\n" + " -v, --verbose Enable more detailed logging output on STDERR\n" " -V, --version Print the buffyboard version and exit\n"); /*-------------------------------- 78 CHARS --------------------------------*/ } @@ -89,13 +91,14 @@ void bb_cli_parse_opts(int argc, char *argv[], bb_cli_opts *opts) { { "dpi", required_argument, NULL, 'd' }, { "rotate", required_argument, NULL, 'r' }, { "help", no_argument, NULL, 'h' }, + { "verbose", no_argument, NULL, 'v' }, { "version", no_argument, NULL, 'V' }, { NULL, 0, NULL, 0 } }; int opt, index = 0; - while ((opt = getopt_long(argc, argv, "C:g:d:r:hV", long_opts, &index)) != -1) { + while ((opt = getopt_long(argc, argv, "C:g:d:r:hvV", long_opts, &index)) != -1) { switch (opt) { case 'C': opts->config_files = realloc(opts->config_files, (opts->num_config_files + 1) * sizeof(char *)); @@ -145,6 +148,9 @@ void bb_cli_parse_opts(int argc, char *argv[], bb_cli_opts *opts) { case 'h': print_usage(); exit(EXIT_SUCCESS); + case 'v': + opts->verbose = true; + break; case 'V': fprintf(stderr, "buffyboard %s\n", BB_VERSION); exit(0); diff --git a/buffyboard/command_line.h b/buffyboard/command_line.h index b8dc399..009b44f 100644 --- a/buffyboard/command_line.h +++ b/buffyboard/command_line.h @@ -29,6 +29,8 @@ typedef struct { int dpi; /* Display rotation */ lv_display_rotation_t rotation; + /* Verbose mode. If true, provide more detailed logging output on STDERR. */ + bool verbose; } bb_cli_opts; /** diff --git a/buffyboard/main.c b/buffyboard/main.c index 1599c03..317445f 100644 --- a/buffyboard/main.c +++ b/buffyboard/main.c @@ -14,6 +14,7 @@ #include "lvgl/lvgl.h" #include "../shared/indev.h" +#include "../shared/log.h" #include "../shared/theme.h" #include "../shared/themes.h" #include "../squeek2lvgl/sq2lv.h" @@ -180,6 +181,11 @@ int main(int argc, char *argv[]) { /* Parse command line options */ bb_cli_parse_opts(argc, argv, &cli_opts); + /* Set up log level */ + if (cli_opts.verbose) { + bbx_log_set_level(BBX_LOG_LEVEL_VERBOSE); + } + /* Parse config files */ bb_config_init_opts(&conf_opts); bb_config_parse_file("/etc/buffyboard.conf", &conf_opts);