Make all applog at least 80 columns wide obviating the need for spaces at the end of select messages to clear the status line.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
diff --git a/main.c b/main.c
index 19ce89b..2b8c0fb 100644
--- a/main.c
+++ b/main.c
@@ -821,7 +821,7 @@ static void *stage_thread(void *userdata)
if (want_longpoll)
applog(LOG_WARNING, "New block detected, possible missed longpoll, flushing work queue");
else
- applog(LOG_WARNING, "New block detected, flushing work queue ");
+ applog(LOG_WARNING, "New block detected, flushing work queue");
/* As we can't flush the work from here, signal
* the wakeup thread to restart all the
* threads */
@@ -1083,7 +1083,7 @@ retry:
goto out;
} else if (localgen) {
localgen = false;
- applog(LOG_WARNING, "Resumed retrieving work from server ");
+ applog(LOG_WARNING, "Resumed retrieving work from server");
}
/* wait for 1st response, or get cached response */
@@ -1576,10 +1576,10 @@ static void *longpoll_thread(void *userdata)
* sure it's only done once per new block */
if (likely(!strncmp(longpoll_block, blank, 36) ||
!strncmp(longpoll_block, current_block, 36))) {
- applog(LOG_WARNING, "LONGPOLL detected new block, flushing work queue ");
+ applog(LOG_WARNING, "LONGPOLL detected new block, flushing work queue");
restart_threads(true);
} else
- applog(LOG_WARNING, "LONGPOLL received - new block detected and work flushed already ");
+ applog(LOG_WARNING, "LONGPOLL received - new block detected and work flushed already");
} else {
if (failures++ < 10) {
sleep(30);
diff --git a/util.c b/util.c
index 8063d7d..52427a0 100644
--- a/util.c
+++ b/util.c
@@ -68,7 +68,7 @@ void vapplog(int prio, const char *fmt, va_list ap)
#endif
else if (opt_log_output || prio == LOG_WARNING || prio == LOG_ERR) {
char *f;
- int len;
+ int len, i, extra = 0;
struct timeval tv = { };
struct tm tm, *tm_p;
@@ -80,8 +80,10 @@ void vapplog(int prio, const char *fmt, va_list ap)
pthread_mutex_unlock(&time_lock);
len = 40 + strlen(fmt) + 2;
- f = alloca(len);
- sprintf(f, "[%d-%02d-%02d %02d:%02d:%02d] %s\n",
+ if (len < 80)
+ extra = 80 - len;
+ f = alloca(len + extra);
+ sprintf(f, "[%d-%02d-%02d %02d:%02d:%02d] %s",
tm.tm_year + 1900,
tm.tm_mon + 1,
tm.tm_mday,
@@ -90,6 +92,9 @@ void vapplog(int prio, const char *fmt, va_list ap)
tm.tm_sec,
fmt);
vfprintf(stderr, f, ap); /* atomic write to stderr */
+ for (i = 0; i < extra; i++)
+ fprintf(stderr, " ");
+ fprintf(stderr, "\n");
fflush(stderr);
}
}