console log fixes, version bump

This commit is contained in:
simon987 2021-11-15 20:52:24 -05:00
parent 70cfa8c37c
commit bb91139ffb
7 changed files with 45 additions and 23 deletions

View File

@ -55,10 +55,14 @@ void vsist_logf(const char *filepath, int level, char *format, va_list ap) {
log_len += 1;
}
int ret = write(STDERR_FILENO, log_str, log_len);
if (ret == -1) {
LOG_FATALF("serialize.c", "Could not write index descriptor: %s", strerror(errno))
if (PrintingProgressBar) {
PrintingProgressBar = FALSE;
memmove(log_str + 1, log_str, log_len);
log_str[0] = '\n';
log_len += 1;
}
write(STDERR_FILENO, log_str, log_len);
}
void sist_logf(const char *filepath, int level, char *format, ...) {
@ -104,8 +108,12 @@ void sist_log(const char *filepath, int level, char *str) {
);
}
int ret = write(STDERR_FILENO, log_str, log_len);
if (ret == -1) {
LOG_FATALF("serialize.c", "Could not write index descriptor: %s", strerror(errno));
if (PrintingProgressBar) {
PrintingProgressBar = FALSE;
memmove(log_str + 1, log_str, log_len);
log_str[0] = '\n';
log_len += 1;
}
write(STDERR_FILENO, log_str, log_len);
}

View File

@ -433,7 +433,7 @@ void sist2_index(index_args_t *args) {
cleanup = elastic_cleanup;
}
IndexCtx.pool = tpool_create(args->threads, cleanup, FALSE, TRUE);
IndexCtx.pool = tpool_create(args->threads, cleanup, FALSE, args->print == 0);
tpool_start(IndexCtx.pool);
struct dirent *de;
@ -518,8 +518,8 @@ void sist2_web(web_args_t *args) {
int main(int argc, const char *argv[]) {
// sigsegv_handler = signal(SIGSEGV, sig_handler);
// sigabrt_handler = signal(SIGABRT, sig_handler);
sigsegv_handler = signal(SIGSEGV, sig_handler);
sigabrt_handler = signal(SIGABRT, sig_handler);
setlocale(LC_ALL, "");

View File

@ -53,7 +53,7 @@
#include <ctype.h>
#include "git_hash.h"
#define VERSION "2.11.4"
#define VERSION "2.11.5"
static const char *const Version = VERSION;
#ifndef SIST_PLATFORM

View File

@ -191,7 +191,9 @@ void tpool_wait(tpool_t *pool) {
}
}
}
progress_bar_print(1.0, ScanCtx.stat_tn_size, ScanCtx.stat_index_size);
if (pool->print_progress) {
progress_bar_print(1.0, ScanCtx.stat_tn_size, ScanCtx.stat_index_size);
}
pthread_mutex_unlock(&(pool->work_mutex));
LOG_INFO("tpool.c", "Worker threads finished")

View File

@ -84,6 +84,8 @@ char *expandpath(const char *path) {
return expanded;
}
int PrintingProgressBar = 0;
void progress_bar_print(double percentage, size_t tn_size, size_t index_size) {
static int last_val = -1;
@ -114,13 +116,21 @@ void progress_bar_print(double percentage, size_t tn_size, size_t index_size) {
index_unit = 'M';
}
printf(
"\r%3d%%[%.*s>%*s] TN:%3d%c IDX:%3d%c",
val, lpad, PBSTR, rpad, "",
(int) tn_size, tn_unit,
(int) index_size, index_unit
);
fflush(stdout);
if (tn_size == 0 && index_size == 0) {
fprintf(stderr,
"\r%3d%%[%.*s>%*s]",
val, lpad, PBSTR, rpad, ""
);
} else {
fprintf(stderr,
"\r%3d%%[%.*s>%*s] TN:%3d%c IDX:%3d%c",
val, lpad, PBSTR, rpad, "",
(int) tn_size, tn_unit,
(int) index_size, index_unit
);
}
PrintingProgressBar = TRUE;
}
GHashTable *incremental_get_table() {

View File

@ -19,6 +19,8 @@ char *expandpath(const char *path);
dyn_buffer_t url_escape(char *str);
extern int PrintingProgressBar;
void progress_bar_print(double percentage, size_t tn_size, size_t index_size);
GHashTable *incremental_get_table();

File diff suppressed because one or more lines are too long