Update curses logging to allow LOG_WARNING and LOG_ERR messages to still go through while within the menu, and drop share message to LOG_NOTICE.
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
diff --git a/adl.c b/adl.c
index e5a14a8..2877448 100644
--- a/adl.c
+++ b/adl.c
@@ -1057,8 +1057,10 @@ updated:
wlogprint("Driver reports success but check values below\n");
else
wlogprint("Failed to modify powertune value\n");
- } else
+ } else {
+ clear_logwin();
return;
+ }
sleep(1);
goto updated;
}
diff --git a/main.c b/main.c
index 6ae4329..48d5883 100644
--- a/main.c
+++ b/main.c
@@ -1986,7 +1986,7 @@ void log_curses(int prio, const char *f, va_list ap)
return;
if (curses_active_locked()) {
- if (!opt_loginput) {
+ if (!opt_loginput || prio == LOG_ERR || prio == LOG_WARNING) {
vw_printw(logwin, f, ap);
wrefresh(logwin);
}
@@ -1995,7 +1995,7 @@ void log_curses(int prio, const char *f, va_list ap)
vprintf(f, ap);
}
-static void clear_logwin(void)
+void clear_logwin(void)
{
if (curses_active_locked()) {
wclear(logwin);
@@ -2065,10 +2065,10 @@ static bool submit_upstream_work(const struct work *work)
applog(LOG_DEBUG, "PROOF OF WORK RESULT: true (yay!!!)");
if (!QUIET) {
if (total_pools > 1)
- applog(LOG_WARNING, "Accepted %.8s %sPU %d thread %d pool %d",
+ applog(LOG_NOTICE, "Accepted %.8s %sPU %d thread %d pool %d",
hexstr + 152, cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, thr_id, work->pool->pool_no);
else
- applog(LOG_WARNING, "Accepted %.8s %sPU %d thread %d",
+ applog(LOG_NOTICE, "Accepted %.8s %sPU %d thread %d",
hexstr + 152, cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, thr_id);
}
if (opt_shares && total_accepted >= opt_shares) {
@@ -2084,10 +2084,10 @@ static bool submit_upstream_work(const struct work *work)
applog(LOG_DEBUG, "PROOF OF WORK RESULT: false (booooo)");
if (!QUIET) {
if (total_pools > 1)
- applog(LOG_WARNING, "Rejected %.8s %sPU %d thread %d pool %d",
+ applog(LOG_NOTICE, "Rejected %.8s %sPU %d thread %d pool %d",
hexstr + 152, cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, thr_id, work->pool->pool_no);
else
- applog(LOG_WARNING, "Rejected %.8s %sPU %d thread %d",
+ applog(LOG_NOTICE, "Rejected %.8s %sPU %d thread %d",
hexstr + 152, cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, thr_id);
}
}
@@ -2390,7 +2390,7 @@ static void *submit_work_thread(void *userdata)
pthread_detach(pthread_self());
if (!opt_submit_stale && stale_work(work)) {
- applog(LOG_WARNING, "Stale share detected, discarding");
+ applog(LOG_NOTICE, "Stale share detected, discarding");
total_stale++;
pool->stale_shares++;
goto out;
@@ -2399,7 +2399,7 @@ static void *submit_work_thread(void *userdata)
/* submit solution to bitcoin via JSON-RPC */
while (!submit_upstream_work(work)) {
if (!opt_submit_stale && stale_work(work)) {
- applog(LOG_WARNING, "Stale share detected, discarding");
+ applog(LOG_NOTICE, "Stale share detected, discarding");
total_stale++;
pool->stale_shares++;
break;
@@ -2656,9 +2656,9 @@ static void test_work_current(struct work *work)
if (block_changed != BLOCK_LP && block_changed != BLOCK_FIRST) {
block_changed = BLOCK_DETECT;
if (have_longpoll)
- applog(LOG_WARNING, "New block detected on network before longpoll, waiting on fresh work");
+ applog(LOG_NOTICE, "New block detected on network before longpoll, waiting on fresh work");
else
- applog(LOG_WARNING, "New block detected on network, waiting on fresh work");
+ applog(LOG_NOTICE, "New block detected on network, waiting on fresh work");
} else
block_changed = BLOCK_NONE;
restart_threads();
@@ -2806,8 +2806,8 @@ static void display_pools(void)
opt_loginput = true;
immedok(logwin, true);
-updated:
clear_logwin();
+updated:
for (i = 0; i < total_pools; i++) {
pool = pools[i];
@@ -2921,9 +2921,9 @@ retry:
pool = pools[selected];
display_pool_summary(pool);
goto retry;
- }
+ } else
+ clear_logwin();
- clear_logwin();
immedok(logwin, false);
opt_loginput = false;
}
@@ -2935,8 +2935,8 @@ static void display_options(void)
opt_loginput = true;
immedok(logwin, true);
-retry:
clear_logwin();
+retry:
wlogprint("[N]ormal [C]lear [S]ilent mode (disable all output)\n");
wlogprint("[D]ebug:%s\n[P]er-device:%s\n[Q]uiet:%s\n[V]erbose:%s\n[R]PC debug:%s\n[L]og interval:%d\n",
opt_debug ? "on" : "off",
@@ -2949,40 +2949,40 @@ retry:
input = getch();
if (!strncasecmp(&input, "q", 1)) {
opt_quiet ^= true;
- clear_logwin();
wlogprint("Quiet mode %s\n", opt_quiet ? "enabled" : "disabled");
+ goto retry;
} else if (!strncasecmp(&input, "v", 1)) {
opt_log_output ^= true;
if (opt_log_output)
opt_quiet = false;
- clear_logwin();
wlogprint("Verbose mode %s\n", opt_log_output ? "enabled" : "disabled");
+ goto retry;
} else if (!strncasecmp(&input, "n", 1)) {
opt_log_output = false;
opt_debug = false;
opt_quiet = false;
opt_protocol = false;
want_per_device_stats = false;
- clear_logwin();
wlogprint("Output mode reset to normal\n");
+ goto retry;
} else if (!strncasecmp(&input, "d", 1)) {
opt_debug ^= true;
opt_log_output = opt_debug;
if (opt_debug)
opt_quiet = false;
- clear_logwin();
wlogprint("Debug mode %s\n", opt_debug ? "enabled" : "disabled");
+ goto retry;
} else if (!strncasecmp(&input, "p", 1)) {
want_per_device_stats ^= true;
opt_log_output = want_per_device_stats;
- clear_logwin();
wlogprint("Per-device stats %s\n", want_per_device_stats ? "enabled" : "disabled");
+ goto retry;
} else if (!strncasecmp(&input, "r", 1)) {
opt_protocol ^= true;
if (opt_protocol)
opt_quiet = false;
- clear_logwin();
wlogprint("RPC protocol debugging %s\n", opt_protocol ? "enabled" : "disabled");
+ goto retry;
} else if (!strncasecmp(&input, "c", 1))
clear_logwin();
else if (!strncasecmp(&input, "l", 1)) {
@@ -2992,12 +2992,12 @@ retry:
goto retry;
}
opt_log_interval = selected;
- clear_logwin();
wlogprint("Log interval set to %d seconds\n", opt_log_interval);
+ goto retry;
} else if (!strncasecmp(&input, "s", 1)) {
opt_realquiet = true;
+ } else
clear_logwin();
- } else clear_logwin();
immedok(logwin, false);
opt_loginput = false;
@@ -3010,8 +3010,8 @@ static void set_options(void)
opt_loginput = true;
immedok(logwin, true);
-retry:
clear_logwin();
+retry:
wlogprint("\n[D]ynamic mode: %s\n[L]ongpoll: %s\n",
opt_dynamic ? "On" : "Off", want_longpoll ? "On" : "Off");
if (opt_dynamic)
@@ -3072,9 +3072,9 @@ retry:
}
opt_fail_pause = selected;
goto retry;
- }
+ } else
+ clear_logwin();
- clear_logwin();
immedok(logwin, false);
opt_loginput = false;
}
@@ -3221,9 +3221,9 @@ retry:
goto retry;
}
change_gpusettings(selected);
- }
+ } else
+ clear_logwin();
- clear_logwin();
immedok(logwin, false);
opt_loginput = false;
}
@@ -4367,7 +4367,7 @@ static void *longpoll_thread(void *userdata)
tq_pop(mythr->q, NULL);
if (!pool->hdr_path) {
- applog(LOG_WARNING, "No long-poll found on this server");
+ applog(LOG_NOTICE, "No long-poll found on this server");
goto out;
}
hdr_path = pool->hdr_path;
@@ -4392,7 +4392,7 @@ static void *longpoll_thread(void *userdata)
}
have_longpoll = true;
- applog(LOG_WARNING, "Long-polling activated for %s", lp_url);
+ applog(LOG_NOTICE, "Long-polling activated for %s", lp_url);
while (1) {
struct timeval start, end;
@@ -4407,7 +4407,7 @@ static void *longpoll_thread(void *userdata)
* sure it's only done once per new block */
if (block_changed != BLOCK_DETECT) {
block_changed = BLOCK_LP;
- applog(LOG_WARNING, "LONGPOLL detected new block on network, waiting on fresh work");
+ applog(LOG_NOTICE, "LONGPOLL detected new block on network, waiting on fresh work");
} else {
applog(LOG_INFO, "LONGPOLL received after new block already detected");
block_changed = BLOCK_NONE;
@@ -4891,7 +4891,7 @@ char *curses_input(const char *query)
if (!input)
quit(1, "Failed to malloc input");
leaveok(logwin, false);
- wlogprint("%s: ", query);
+ wlogprint("%s:\n", query);
wgetnstr(logwin, input, 255);
if (!strlen(input))
strcpy(input, "-1");
diff --git a/miner.h b/miner.h
index 12138c3..cfcf83f 100644
--- a/miner.h
+++ b/miner.h
@@ -126,6 +126,7 @@ void *alloca (size_t);
enum {
LOG_ERR,
LOG_WARNING,
+ LOG_NOTICE,
LOG_INFO,
LOG_DEBUG,
};
@@ -477,6 +478,7 @@ extern int curses_int(const char *query);
extern char *curses_input(const char *query);
extern void kill_work(void);
extern void log_curses(int prio, const char *f, va_list ap);
+extern void clear_logwin(void);
extern void vapplog(int prio, const char *fmt, va_list ap);
extern void applog(int prio, const char *fmt, ...);
extern struct thread_q *tq_new(void);
diff --git a/util.c b/util.c
index 1f36450..1fddead 100644
--- a/util.c
+++ b/util.c
@@ -72,7 +72,7 @@ void vapplog(int prio, const char *fmt, va_list ap)
#else
if (0) {}
#endif
- else if (opt_log_output || prio == LOG_WARNING || prio == LOG_ERR) {
+ else if (opt_log_output || prio <= LOG_NOTICE) {
char *f;
int len;
struct timeval tv = { };