From bd1ea477f8319b78571c0c8ddbbb29f91c804344 Mon Sep 17 00:00:00 2001 From: Martijn Braam Date: Wed, 14 Feb 2024 14:25:27 +0100 Subject: [PATCH] Add a verbosity flag to getframe --- include/libmegapixels.h | 3 +++ src/log.c | 6 ++++++ util/getframe.c | 10 +++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/libmegapixels.h b/include/libmegapixels.h index 8bfc76f..49307e1 100644 --- a/include/libmegapixels.h +++ b/include/libmegapixels.h @@ -123,6 +123,9 @@ typedef struct _lmp_aaa { EXPORT int libmegapixels_init(libmegapixels_devconfig **config); +EXPORT void +libmegapixels_loglevel(int loglevel); + EXPORT int libmegapixels_load_file(libmegapixels_devconfig *config, const char *file); diff --git a/src/log.c b/src/log.c index c3a85ea..6aa78b7 100644 --- a/src/log.c +++ b/src/log.c @@ -17,6 +17,12 @@ init_log(int level) } } +void +libmegapixels_loglevel(int level) +{ + loglevel = level; +} + void log_error(const char *fmt, ...) { diff --git a/util/getframe.c b/util/getframe.c index eca13f8..ffbf6cb 100644 --- a/util/getframe.c +++ b/util/getframe.c @@ -37,6 +37,7 @@ usage(char *name) fprintf(stderr, " -c camera Use a specific camera number\n"); fprintf(stderr, " -m modenum Use another camera mode than the first\n"); fprintf(stderr, " -o file File to store the frame in\n"); + fprintf(stderr, " -v Show verbose debug info\n"); fprintf(stderr, " -h Display this help text\n"); } @@ -50,8 +51,9 @@ main(int argc, char *argv[]) char *outfile = NULL; int count = 5; int mode_idx = 0; + int verbose = 0; - while ((c = getopt(argc, argv, "hc:n:o:m:")) != -1) { + while ((c = getopt(argc, argv, "hvc:n:o:m:")) != -1) { switch (c) { case 'c': res = strtol(optarg, &end, 10); @@ -84,6 +86,9 @@ main(int argc, char *argv[]) usage(argv[0]); return 0; break; + case 'v': + verbose = 1; + break; case '?': if (optopt == 'd' || optopt == 'l') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); @@ -104,6 +109,9 @@ main(int argc, char *argv[]) int ret = libmegapixels_find_config(configpath); libmegapixels_devconfig *config = {0}; libmegapixels_init(&config); + if (verbose) { + libmegapixels_loglevel(2); + } if (ret) { printf("Using config: %s\n", configpath);