diff --git a/cmdline/scan.c b/cmdline/scan.c index 6a0f6750..62e51517 100644 --- a/cmdline/scan.c +++ b/cmdline/scan.c @@ -2066,7 +2066,7 @@ static int state_diffscan(struct snapraid_state* state, int is_diff) msg_status("No differences\n"); } if (state->unsynced_blocks != 0) - log_error(EUSER, "The last sync was interrupted. Run it again!\n"); + log_info(EUSER, "The last sync was interrupted. Run it again!\n"); if (state->unsynced_blocks != 0) { log_tag("summary:exit:unsynced\n"); diff --git a/cmdline/state.c b/cmdline/state.c index bc6b27c1..6fdebb86 100644 --- a/cmdline/state.c +++ b/cmdline/state.c @@ -471,11 +471,11 @@ static void state_config_check(struct snapraid_state* state, const char* path, t #endif if (state->raid_mode == RAID_MODE_CAUCHY && !state->opt.no_warnings) { if (state->level == 3) { - log_error(ESOFT, "WARNING! Your CPU doesn't have a fast implementation for triple parity.\n"); - log_error(ESOFT, "WARNING! It's recommended to switch to 'z-parity' instead than '3-parity'.\n"); + log_info(EUSER, "WARNING! Your CPU doesn't have a fast implementation for triple parity.\n"); + log_info(EUSER, "WARNING! It's recommended to switch to 'z-parity' instead than '3-parity'.\n"); } else if (state->level > 3) { - log_error(ESOFT, "WARNING! Your CPU doesn't have a fast implementation beyond triple parity.\n"); - log_error(ESOFT, "WARNING! It's recommended to reduce the parity levels to triple parity.\n"); + log_info(EUSER, "WARNING! Your CPU doesn't have a fast implementation beyond triple parity.\n"); + log_info(EUSER, "WARNING! It's recommended to reduce the parity levels to triple parity.\n"); } } @@ -1766,15 +1766,15 @@ static void state_map(struct snapraid_state* state) if (!state->opt.no_warnings) { /* LCOV_EXCL_START */ if (diskcount >= 36 && state->level < 6) { - log_error(EUSER, "WARNING! For %u disks, it's recommended to use six parity levels.\n", diskcount); + log_info(EUSER, "WARNING! For %u disks, it's recommended to use six parity levels.\n", diskcount); } else if (diskcount >= 29 && state->level < 5) { - log_error(EUSER, "WARNING! For %u disks, it's recommended to use five parity levels.\n", diskcount); + log_info(EUSER, "WARNING! For %u disks, it's recommended to use five parity levels.\n", diskcount); } else if (diskcount >= 22 && state->level < 4) { - log_error(EUSER, "WARNING! For %u disks, it's recommended to use four parity levels.\n", diskcount); + log_info(EUSER, "WARNING! For %u disks, it's recommended to use four parity levels.\n", diskcount); } else if (diskcount >= 15 && state->level < 3) { - log_error(EUSER, "WARNING! For %u disks, it's recommended to use three parity levels.\n", diskcount); + log_info(EUSER, "WARNING! For %u disks, it's recommended to use three parity levels.\n", diskcount); } else if (diskcount >= 5 && state->level < 2) { - log_error(EUSER, "WARNING! For %u disks, it's recommended to use two parity levels.\n", diskcount); + log_info(EUSER, "WARNING! For %u disks, it's recommended to use two parity levels.\n", diskcount); } /* LCOV_EXCL_STOP */ } @@ -2948,7 +2948,7 @@ static void state_read_content(struct snapraid_state* state, const char* path, S /* search by UUID if renamed */ disk = find_disk_by_uuid(state, uuid); if (disk) { - log_error(EUSER, "WARNING! Renaming disk '%s' to '%s'\n", buffer, disk->name); + log_info(EUSER, "WARNING! Renaming disk '%s' to '%s'\n", buffer, disk->name); /* write the new state with the new name */ state->need_write = 1; @@ -3169,7 +3169,7 @@ static void state_read_content(struct snapraid_state* state, const char* path, S } /* otherwise we can drop it */ - log_error(EUSER, "WARNING! Dropping from '%s' unused split '%u'\n", lev_config_name(v_level), s); + log_info(EUSER, "WARNING! Dropping from '%s' unused split '%u'\n", lev_config_name(v_level), s); } else { char parity_name[64]; @@ -4291,7 +4291,7 @@ void state_read(struct snapraid_state* state) /* if not found, assume empty */ if (!f) { - log_error(EUSER, "No content file found. Assuming empty.\n"); + log_info(EUSER, "No content file found. Assuming empty.\n"); /* create the initial mapping */ state_map(state); diff --git a/cmdline/support.c b/cmdline/support.c index 8635d518..0cb0523e 100644 --- a/cmdline/support.c +++ b/cmdline/support.c @@ -418,6 +418,35 @@ void log_error(int err, const char* format, ...) unlock_msg(); } + +void log_info(int err, const char* format, ...) +{ + va_list ap; + + lock_msg(); + + if (stdlog) { + if (is_hw(err)) + fprintf(stdlog, "msg:error_hardware: "); /* we never expect an hardware error */ + else + fprintf(stdlog, "msg:info: "); + + va_start(ap, format); + vfprintf(stdlog, format, ap); + va_end(ap); + + fflush(stdlog); + } else { + va_start(ap, format); + vmsg(stderr, format, ap); + va_end(ap); + + fflush(stderr); + } + + unlock_msg(); +} + void log_expected(int err, const char* format, ...) { va_list ap; diff --git a/cmdline/support.h b/cmdline/support.h index d841a36a..2ff8d17b 100644 --- a/cmdline/support.h +++ b/cmdline/support.h @@ -105,6 +105,15 @@ void log_fatal(int err, const char* format, ...) __attribute__((format(attribute */ void log_error(int err, const char* format, ...) __attribute__((format(attribute_printf, 2, 3))); +/** + * Informational messages. + * + * Messages reporting general status information or warnings that do not indicate failure. + * + * These messages go in the log file if specified, otherwise they go in stderr. + */ +void log_info(int err, const char* format, ...) __attribute__((format(attribute_printf, 2, 3))); + /** * Expected error messages, without fallback to stderr. *