Browse Source

logging - applogsiz() for large messages

nfactor-troky
Kano 11 years ago
parent
commit
0d4edbe9c1
  1. 41
      driver-bflsc.c
  2. 3
      driver-bflsc.h
  3. 10
      logging.h

41
driver-bflsc.c

@ -617,7 +617,8 @@ static bool getinfo(struct cgpu_info *bflsc, int dev)
*lf = '\0'; *lf = '\0';
if (!res || count != 1) { if (!res || count != 1) {
tmp = str_text(items[i]); tmp = str_text(items[i]);
applog(LOG_WARNING, "%s detect (%s) invalid details line: '%s' %d", applogsiz(LOG_WARNING, BFLSC_APPLOGSIZ,
"%s detect (%s) invalid details line: '%s' %d",
bflsc->drv->dname, bflsc->device_path, tmp, count); bflsc->drv->dname, bflsc->device_path, tmp, count);
free(tmp); free(tmp);
dev_error(bflsc, REASON_DEV_COMMS_ERROR); dev_error(bflsc, REASON_DEV_COMMS_ERROR);
@ -631,7 +632,8 @@ static bool getinfo(struct cgpu_info *bflsc, int dev)
sc_dev.engines = atoi(fields[0]); sc_dev.engines = atoi(fields[0]);
if (sc_dev.engines < 1) { if (sc_dev.engines < 1) {
tmp = str_text(items[i]); tmp = str_text(items[i]);
applog(LOG_WARNING, "%s detect (%s) invalid engine count: '%s'", applogsiz(LOG_WARNING, BFLSC_APPLOGSIZ,
"%s detect (%s) invalid engine count: '%s'",
bflsc->drv->dname, bflsc->device_path, tmp); bflsc->drv->dname, bflsc->device_path, tmp);
free(tmp); free(tmp);
goto mata; goto mata;
@ -645,7 +647,8 @@ static bool getinfo(struct cgpu_info *bflsc, int dev)
sc_info->sc_count = atoi(fields[0]); sc_info->sc_count = atoi(fields[0]);
if (sc_info->sc_count < 1 || sc_info->sc_count > 30) { if (sc_info->sc_count < 1 || sc_info->sc_count > 30) {
tmp = str_text(items[i]); tmp = str_text(items[i]);
applog(LOG_WARNING, "%s detect (%s) invalid s-link count: '%s'", applogsiz(LOG_WARNING, BFLSC_APPLOGSIZ,
"%s detect (%s) invalid s-link count: '%s'",
bflsc->drv->dname, bflsc->device_path, tmp); bflsc->drv->dname, bflsc->device_path, tmp);
free(tmp); free(tmp);
goto mata; goto mata;
@ -1211,7 +1214,8 @@ static void process_nonces(struct cgpu_info *bflsc, int dev, char *xlink, char *
if (count < sc_info->que_fld_min) { if (count < sc_info->que_fld_min) {
tmp = str_text(data); tmp = str_text(data);
applog(LOG_INFO, "%s%i:%s work returned too small (%d,%s)", applogsiz(LOG_INFO, BFLSC_APPLOGSIZ,
"%s%i:%s work returned too small (%d,%s)",
bflsc->drv->name, bflsc->device_id, xlink, count, tmp); bflsc->drv->name, bflsc->device_id, xlink, count, tmp);
free(tmp); free(tmp);
inc_hw_errors(bflsc->thr[0]); inc_hw_errors(bflsc->thr[0]);
@ -1219,7 +1223,7 @@ static void process_nonces(struct cgpu_info *bflsc, int dev, char *xlink, char *
} }
if (count > sc_info->que_fld_max) { if (count > sc_info->que_fld_max) {
applog(LOG_INFO, "%s%i:%s work returned too large (%d) processing %d anyway", applogsiz(LOG_INFO, "%s%i:%s work returned too large (%d) processing %d anyway",
bflsc->drv->name, bflsc->device_id, xlink, count, sc_info->que_fld_max); bflsc->drv->name, bflsc->device_id, xlink, count, sc_info->que_fld_max);
count = sc_info->que_fld_max; count = sc_info->que_fld_max;
inc_hw_errors(bflsc->thr[0]); inc_hw_errors(bflsc->thr[0]);
@ -1228,8 +1232,10 @@ static void process_nonces(struct cgpu_info *bflsc, int dev, char *xlink, char *
num = atoi(fields[sc_info->que_noncecount]); num = atoi(fields[sc_info->que_noncecount]);
if (num != count - sc_info->que_fld_min) { if (num != count - sc_info->que_fld_min) {
tmp = str_text(data); tmp = str_text(data);
applog(LOG_INFO, "%s%i:%s incorrect data count (%d) will use %d instead from (%s)", applogsiz(LOG_INFO, BFLSC_APPLOGSIZ,
bflsc->drv->name, bflsc->device_id, xlink, num, count - sc_info->que_fld_max, tmp); "%s%i:%s incorrect data count (%d) will use %d instead from (%s)",
bflsc->drv->name, bflsc->device_id, xlink, num,
count - sc_info->que_fld_max, tmp);
free(tmp); free(tmp);
inc_hw_errors(bflsc->thr[0]); inc_hw_errors(bflsc->thr[0]);
} }
@ -1260,7 +1266,8 @@ static void process_nonces(struct cgpu_info *bflsc, int dev, char *xlink, char *
for (i = sc_info->que_fld_min; i < count; i++) { for (i = sc_info->que_fld_min; i < count; i++) {
if (strlen(fields[i]) != 8) { if (strlen(fields[i]) != 8) {
tmp = str_text(data); tmp = str_text(data);
applog(LOG_INFO, "%s%i:%s invalid nonce (%s) will try to process anyway", applogsiz(LOG_INFO, BFLSC_APPLOGSIZ,
"%s%i:%s invalid nonce (%s) will try to process anyway",
bflsc->drv->name, bflsc->device_id, xlink, tmp); bflsc->drv->name, bflsc->device_id, xlink, tmp);
free(tmp); free(tmp);
} }
@ -1312,7 +1319,8 @@ static int process_results(struct cgpu_info *bflsc, int dev, char *pbuf, int *no
free(buf); free(buf);
if (!res || lines < 1) { if (!res || lines < 1) {
tmp = str_text(pbuf); tmp = str_text(pbuf);
applog(LOG_ERR, "%s%i:%s empty result (%s) ignored", applogsiz(LOG_ERR, BFLSC_APPLOGSIZ,
"%s%i:%s empty result (%s) ignored",
bflsc->drv->name, bflsc->device_id, xlink, tmp); bflsc->drv->name, bflsc->device_id, xlink, tmp);
free(tmp); free(tmp);
goto arigatou; goto arigatou;
@ -1320,7 +1328,8 @@ static int process_results(struct cgpu_info *bflsc, int dev, char *pbuf, int *no
if (lines < QUE_RES_LINES_MIN) { if (lines < QUE_RES_LINES_MIN) {
tmp = str_text(pbuf); tmp = str_text(pbuf);
applog(LOG_ERR, "%s%i:%s result of %d too small (%s) ignored", applogsiz(LOG_ERR, BFLSC_APPLOGSIZ,
"%s%i:%s result of %d too small (%s) ignored",
bflsc->drv->name, bflsc->device_id, xlink, lines, tmp); bflsc->drv->name, bflsc->device_id, xlink, lines, tmp);
free(tmp); free(tmp);
goto arigatou; goto arigatou;
@ -1330,7 +1339,8 @@ static int process_results(struct cgpu_info *bflsc, int dev, char *pbuf, int *no
if (count < 1) { if (count < 1) {
tmp = str_text(pbuf); tmp = str_text(pbuf);
tmp2 = str_text(items[1]); tmp2 = str_text(items[1]);
applog(LOG_ERR, "%s%i:%s empty result count (%s) in (%s) ignoring", applogsiz(LOG_ERR, BFLSC_APPLOGSIZ,
"%s%i:%s empty result count (%s) in (%s) ignoring",
bflsc->drv->name, bflsc->device_id, xlink, tmp2, tmp); bflsc->drv->name, bflsc->device_id, xlink, tmp2, tmp);
free(tmp2); free(tmp2);
free(tmp); free(tmp);
@ -1338,7 +1348,8 @@ static int process_results(struct cgpu_info *bflsc, int dev, char *pbuf, int *no
} else if (count != 1) { } else if (count != 1) {
tmp = str_text(pbuf); tmp = str_text(pbuf);
tmp2 = str_text(items[1]); tmp2 = str_text(items[1]);
applog(LOG_ERR, "%s%i:%s incorrect result count %d (%s) in (%s) will try anyway", applogsiz(LOG_ERR, BFLSC_APPLOGSIZ,
"%s%i:%s incorrect result count %d (%s) in (%s) will try anyway",
bflsc->drv->name, bflsc->device_id, xlink, count, tmp2, tmp); bflsc->drv->name, bflsc->device_id, xlink, count, tmp2, tmp);
free(tmp2); free(tmp2);
free(tmp); free(tmp);
@ -1352,7 +1363,8 @@ static int process_results(struct cgpu_info *bflsc, int dev, char *pbuf, int *no
tmp = str_text(pbuf); tmp = str_text(pbuf);
tmp2 = str_text(items[0]); tmp2 = str_text(items[0]);
applog(LOG_ERR, "%s%i:%s incorrect result count %d (%s) will try %d (%s)", applogsiz(LOG_ERR, BFLSC_APPLOGSIZ,
"%s%i:%s incorrect result count %d (%s) will try %d (%s)",
bflsc->drv->name, bflsc->device_id, xlink, i, tmp2, que, tmp); bflsc->drv->name, bflsc->device_id, xlink, i, tmp2, que, tmp);
free(tmp2); free(tmp2);
free(tmp); free(tmp);
@ -1366,7 +1378,8 @@ static int process_results(struct cgpu_info *bflsc, int dev, char *pbuf, int *no
if (likely(res)) if (likely(res))
process_nonces(bflsc, dev, &(xlink[0]), items[i], count, fields, nonces); process_nonces(bflsc, dev, &(xlink[0]), items[i], count, fields, nonces);
else else
applog(LOG_ERR, "%s%i:%s failed to process nonce %s", applogsiz(LOG_ERR, BFLSC_APPLOGSIZ,
"%s%i:%s failed to process nonce %s",
bflsc->drv->name, bflsc->device_id, xlink, items[i]); bflsc->drv->name, bflsc->device_id, xlink, items[i]);
freebreakdown(&count, &firstname, &fields); freebreakdown(&count, &firstname, &fields);
sc_info->not_first_work = true; sc_info->not_first_work = true;

3
driver-bflsc.h

@ -46,6 +46,9 @@ enum driver_version {
*/ */
#define BFLSC_BUFSIZ (0x1000) #define BFLSC_BUFSIZ (0x1000)
// Should be big enough
#define BFLSC_APPLOGSIZ (0x2000)
#define BFLSC_INFO_TIMEOUT 999 #define BFLSC_INFO_TIMEOUT 999
#define BFLSC_DI_FIRMWARE "FIRMWARE" #define BFLSC_DI_FIRMWARE "FIRMWARE"

10
logging.h

@ -42,6 +42,16 @@ extern void _applog(int prio, const char *str);
} \ } \
} while (0) } while (0)
#define applogsiz(prio, _SIZ, fmt, ...) do { \
if (opt_debug || prio != LOG_DEBUG) { \
if (use_syslog || opt_log_output || prio <= opt_log_level) { \
char tmp42[_SIZ]; \
snprintf(tmp42, sizeof(tmp42), fmt, ##__VA_ARGS__); \
_applog(prio, tmp42); \
} \
} \
} while (0)
#define quit(status, fmt, ...) do { \ #define quit(status, fmt, ...) do { \
if (fmt) { \ if (fmt) { \
char tmp42[LOGBUFSIZ]; \ char tmp42[LOGBUFSIZ]; \

Loading…
Cancel
Save