Add CLI flag for verbose logging

This commit is contained in:
Johannes Marbach 2024-04-01 16:21:44 +02:00
parent 586b0eec7a
commit 194a090d92
5 changed files with 17 additions and 1 deletions

View file

@ -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): Add fbdev force-refresh quirk via config
- feat(buffyboard): Allow disabling input devices via config - feat(buffyboard): Allow disabling input devices via config
- feat(buffyboard): Add CLI flags for overriding geometry & DPI - 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 doesn't close on decline
- fix(unl0kr): Shutdown message box buttons and label are unstyled - fix(unl0kr): Shutdown message box buttons and label are unstyled
- fix(unl0kr): Build fails when DRM is disabled - fix(unl0kr): Build fails when DRM is disabled

View file

@ -59,6 +59,7 @@ Mandatory arguments to long options are mandatory for short options too.
* 2 - upside down orientation (180 degrees) * 2 - upside down orientation (180 degrees)
* 3 - counterclockwise orientation (270 degrees) * 3 - counterclockwise orientation (270 degrees)
-h, --help Print this message and exit -h, --help Print this message and exit
-v, --verbose Enable more detailed logging output on STDERR
-V, --version Print the buffyboard version and exit -V, --version Print the buffyboard version and exit
``` ```

View file

@ -45,6 +45,7 @@ static void init_opts(bb_cli_opts *opts) {
opts->y_offset = 0; opts->y_offset = 0;
opts->dpi = 0; opts->dpi = 0;
opts->rotation = LV_DISPLAY_ROTATION_0; opts->rotation = LV_DISPLAY_ROTATION_0;
opts->verbose = false;
} }
static void print_usage() { static void print_usage() {
@ -71,6 +72,7 @@ static void print_usage() {
" * 2 - upside down orientation (180 degrees)\n" " * 2 - upside down orientation (180 degrees)\n"
" * 3 - counterclockwise orientation (270 degrees)\n" " * 3 - counterclockwise orientation (270 degrees)\n"
" -h, --help Print this message and exit\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"); " -V, --version Print the buffyboard version and exit\n");
/*-------------------------------- 78 CHARS --------------------------------*/ /*-------------------------------- 78 CHARS --------------------------------*/
} }
@ -89,13 +91,14 @@ void bb_cli_parse_opts(int argc, char *argv[], bb_cli_opts *opts) {
{ "dpi", required_argument, NULL, 'd' }, { "dpi", required_argument, NULL, 'd' },
{ "rotate", required_argument, NULL, 'r' }, { "rotate", required_argument, NULL, 'r' },
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{ "verbose", no_argument, NULL, 'v' },
{ "version", no_argument, NULL, 'V' }, { "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
int opt, index = 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) { switch (opt) {
case 'C': case 'C':
opts->config_files = realloc(opts->config_files, (opts->num_config_files + 1) * sizeof(char *)); 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': case 'h':
print_usage(); print_usage();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
case 'v':
opts->verbose = true;
break;
case 'V': case 'V':
fprintf(stderr, "buffyboard %s\n", BB_VERSION); fprintf(stderr, "buffyboard %s\n", BB_VERSION);
exit(0); exit(0);

View file

@ -29,6 +29,8 @@ typedef struct {
int dpi; int dpi;
/* Display rotation */ /* Display rotation */
lv_display_rotation_t rotation; lv_display_rotation_t rotation;
/* Verbose mode. If true, provide more detailed logging output on STDERR. */
bool verbose;
} bb_cli_opts; } bb_cli_opts;
/** /**

View file

@ -14,6 +14,7 @@
#include "lvgl/lvgl.h" #include "lvgl/lvgl.h"
#include "../shared/indev.h" #include "../shared/indev.h"
#include "../shared/log.h"
#include "../shared/theme.h" #include "../shared/theme.h"
#include "../shared/themes.h" #include "../shared/themes.h"
#include "../squeek2lvgl/sq2lv.h" #include "../squeek2lvgl/sq2lv.h"
@ -180,6 +181,11 @@ int main(int argc, char *argv[]) {
/* Parse command line options */ /* Parse command line options */
bb_cli_parse_opts(argc, argv, &cli_opts); 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 */ /* Parse config files */
bb_config_init_opts(&conf_opts); bb_config_init_opts(&conf_opts);
bb_config_parse_file("/etc/buffyboard.conf", &conf_opts); bb_config_parse_file("/etc/buffyboard.conf", &conf_opts);