Splitted the --gui option in --gui and --gui-verbose to avoid extremely big logs

This commit is contained in:
Andrea Mazzoleni 2026-01-14 10:35:57 +01:00
parent 276b06f0a6
commit 6b79b3157d
6 changed files with 22 additions and 11 deletions

View file

@ -212,7 +212,7 @@ CHECKFLAGS_ALPHA = $(CHECKFLAGS_COMMON) --test-force-order-alpha
CHECKFLAGS_PHYSICAL = $(CHECKFLAGS_COMMON) --test-force-order-physical -q -q -q
# Verbose options
CHECKFLAGS_VERBOSE = $(CHECKFLAGS_ALPHA) -v -G
CHECKFLAGS_VERBOSE = $(CHECKFLAGS_ALPHA) -v --gui
# Quiet options
CHECKFLAGS = $(CHECKFLAGS_ALPHA) -q -q -q

View file

@ -61,7 +61,8 @@ void state_list(struct snapraid_state* state)
++file_count;
file_size += file->size;
log_tag("file:%s:%s:%" PRIu64 ":%" PRIi64 ":%u:%" PRIi64 "\n", disk->name, esc_tag(file->sub, esc_buffer), file->size, file->mtime_sec, file->mtime_nsec, file->inode);
if (state->opt.gui_verbose)
log_tag("file:%s:%s:%" PRIu64 ":%" PRIi64 ":%u:%" PRIi64 "\n", disk->name, esc_tag(file->sub, esc_buffer), file->size, file->mtime_sec, file->mtime_nsec, file->inode);
t = file->mtime_sec;
#if HAVE_LOCALTIME_R
@ -100,7 +101,8 @@ void state_list(struct snapraid_state* state)
++link_count;
log_tag("link_%s:%s:%s:%s\n", type, disk->name, esc_tag(slink->sub, esc_buffer), esc_tag(slink->linkto, esc_buffer_alt));
if (state->opt.gui_verbose)
log_tag("link_%s:%s:%s:%s\n", type, disk->name, esc_tag(slink->sub, esc_buffer), esc_tag(slink->linkto, esc_buffer_alt));
printf("%12s ", type);
printf(" ");

View file

@ -174,7 +174,7 @@ static void scan_link(struct snapraid_scan* scan, int is_diff, const char* sub,
/* it's equal */
++scan->count_equal;
if (state->opt.gui) {
if (state->opt.gui_verbose) {
log_tag("scan:equal:%s:%s\n", disk->name, esc_tag(slink->sub, esc_buffer));
}
} else {
@ -804,7 +804,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
/* otherwise it's equal */
++scan->count_equal;
if (state->opt.gui) {
if (state->opt.gui_verbose) {
log_tag("scan:equal:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer));
}
}
@ -969,7 +969,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
/* meaning, and then we don't even save them */
++scan->count_equal;
if (state->opt.gui) {
if (state->opt.gui_verbose) {
log_tag("scan:equal:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer));
}
}

View file

@ -682,6 +682,8 @@ void config(char* conf, size_t conf_size, const char* argv0)
#define OPT_TEST_SPEED_PERIOD 307
#define OPT_TEST_SPEED_DISKS_NUMBER 308
#define OPT_TEST_SPEED_BLOCKS_SIZE 309
#define OPT_TEST_GUI 310
#define OPT_TEST_GUI_VERBOSE 311
#if HAVE_GETOPT_LONG
static struct option long_options[] = {
@ -717,9 +719,10 @@ static struct option long_options[] = {
{ "gen-conf", 1, 0, 'C' },
{ "verbose", 0, 0, 'v' },
{ "quiet", 0, 0, 'q' },
{ "gui", 0, 0, 'G' }, /* undocumented GUI interface option */
{ "help", 0, 0, 'H' },
{ "version", 0, 0, 'V' },
{ "gui", 0, 0, OPT_TEST_GUI }, /* undocumented GUI interface option (it was also 'G' in the past) */
{ "gui-verbose", 0, 0, OPT_TEST_GUI_VERBOSE }, /* undocumented GUI interface option */
/* The following are test specific options, DO NOT USE! */
@ -866,8 +869,9 @@ static struct option long_options[] = {
* Free letters: gIjJkKMnPQrtuxXWz
*
* The 's' letter is used in main.c
* The 'G' letter is free but only from 13.1
*/
#define OPTIONS "c:f:d:mebp:o:S:B:L:i:l:AZEUDNFRahTC:vqHVGw:"
#define OPTIONS "c:f:d:mebp:o:S:B:L:i:l:AZEUDNFRahTC:vqHVw:"
volatile int global_interrupt = 0;
@ -1181,9 +1185,13 @@ int snapraid_main(int argc, char* argv[])
case 'q' :
--msg_level;
break;
case 'G' :
case OPT_TEST_GUI :
opt.gui = 1;
break;
case OPT_TEST_GUI_VERBOSE :
opt.gui = 1;
opt.gui_verbose = 1;
break;
case 'H' :
usage(conf);
exit(EXIT_SUCCESS);

View file

@ -66,7 +66,8 @@ const char* lev_config_name(unsigned level);
* For all these options a value of 0 means nothing set, and to use the default.
*/
struct snapraid_option {
int gui; /**< Gui output. */
int gui; /**< GUI output. */
int gui_verbose; /**< GUI verbose output. */
int auditonly; /**< In check, checks only the hash and not the parity. */
int badfileonly; /**< In fix, fixes only files marked as bad. */
int badblockonly; /**< In fix, fixes only the blocks marked as bad. */

View file

@ -350,7 +350,7 @@ int state_status(struct snapraid_state* state)
timemap[count++] = scrub_time;
}
if (state->opt.gui) {
if (state->opt.gui_verbose) {
if (info != 0)
log_tag("block:%u:%" PRIu64 ":%s:%s:%s:%s\n", i, (uint64_t)info_get_time(info), one_valid ? "used" : "", one_invalid ? "unsynced" : "", info_get_bad(info) ? "bad" : "", info_get_rehash(info) ? "rehash" : "");
else