all: Silence nearly all DEBUG outputs unless DYESUB_DEBUG is set in the

environment.
This commit is contained in:
Solomon Peachy 2013-12-21 22:15:18 -05:00
parent 138d10551b
commit 875ebd2d76
9 changed files with 91 additions and 62 deletions

View File

@ -386,7 +386,7 @@ static int canonselphy_early_parse(void *vctx, int data_fd)
else
ctx->paper_code = -1;
DEBUG("%sFile intended for a '%s' printer\n", ctx->bw_mode? "B/W " : "", ctx->printer->model);
INFO("%sFile intended for a '%s' printer\n", ctx->bw_mode? "B/W " : "", ctx->printer->model);
return printer_type;
}
@ -437,7 +437,8 @@ static int canonselphy_main_loop(void *vctx, int copies) {
top:
if (state != last_state) {
DEBUG("last_state %d new %d\n", last_state, state);
if (dyesub_debug)
DEBUG("last_state %d new %d\n", last_state, state);
}
/* Do it twice to clear initial state */
@ -454,11 +455,13 @@ top:
if (memcmp(rdbuf, rdbuf2, READBACK_LEN)) {
int i;
DEBUG("readback: ");
for (i = 0 ; i < num ; i++) {
DEBUG2("%02x ", rdbuf[i]);
if (dyesub_debug) {
DEBUG("<- ");
for (i = 0 ; i < num ; i++) {
DEBUG2("%02x ", rdbuf[i]);
}
DEBUG2("\n");
}
DEBUG2("\n");
memcpy(rdbuf2, rdbuf, READBACK_LEN);
} else if (state == last_state) {
sleep(1);
@ -549,7 +552,7 @@ top:
state = S_FINISHED;
/* Intentional Fallthrough */
case S_FINISHED:
DEBUG("All data sent to printer!\n");
INFO("All data sent to printer!\n");
break;
}
if (state != S_FINISHED)
@ -604,7 +607,7 @@ top:
struct dyesub_backend canonselphy_backend = {
.name = "Canon SELPHY CP/ES",
.version = "0.61",
.version = "0.62",
.uri_prefix = "canonselphy",
.init = canonselphy_init,
.attach = canonselphy_attach,

View File

@ -27,7 +27,7 @@
#include "backend_common.h"
#define BACKEND_VERSION "0.27"
#define BACKEND_VERSION "0.28"
#ifndef URI_PREFIX
#error "Must Define URI_PREFIX"
#endif
@ -90,7 +90,7 @@ int send_data(struct libusb_device_handle *dev, uint8_t endp,
{
int num = 0;
if (getenv("DYESUB_DEBUG")) {
if (dyesub_debug) {
DEBUG("Sending %d bytes to printer\n", len);
}
@ -100,7 +100,7 @@ int send_data(struct libusb_device_handle *dev, uint8_t endp,
buf, len2,
&num, 5000);
if (getenv("DYESUB_DEBUG")) {
if (dyesub_debug) {
int i;
DEBUG("-> ");
for (i = 0 ; i < len2; i++) {
@ -206,9 +206,10 @@ static int print_scan_output(struct libusb_device *device,
sprintf((char*)serial, "NONE_B%03d_D%03d", bus_num, port_num);
}
DEBUG("%sVID: %04X PID: %04X Manuf: '%s' Product: '%s' Serial: '%s'\n",
match ? "MATCH: " : "",
desc->idVendor, desc->idProduct, manuf, product, serial);
if (dyesub_debug)
DEBUG("%sVID: %04X PID: %04X Manuf: '%s' Product: '%s' Serial: '%s'\n",
match ? "MATCH: " : "",
desc->idVendor, desc->idProduct, manuf, product, serial);
if (scan_only) {
@ -356,6 +357,9 @@ static struct dyesub_backend *find_backend(char *uri_prefix)
return NULL;
}
/* Debug flag */
int dyesub_debug = 0;
/* MAIN */
int main (int argc, char **argv)
@ -387,6 +391,9 @@ int main (int argc, char **argv)
int query_only = 0;
int printer_type = P_ANY;
if (getenv("DYESUB_DEBUG"))
dyesub_debug = 1;
DEBUG("Multi-Call Gutenprint DyeSub CUPS Backend version %s\n",
BACKEND_VERSION);
DEBUG("Copyright 2007-2013 Solomon Peachy\n");
@ -536,8 +543,8 @@ int main (int argc, char **argv)
signal(SIGTERM, sigterm_handler);
/* Initialize backend */
INFO("Initializing '%s' backend (version %s)\n",
backend->name, backend->version);
DEBUG("Initializing '%s' backend (version %s)\n",
backend->name, backend->version);
backend_ctx = backend->init();
/* Parse printjob if necessary */

View File

@ -133,6 +133,7 @@ int send_data(struct libusb_device_handle *dev, uint8_t endp,
/* Exported data */
extern int terminate;
extern int dyesub_debug;
/* External data */
extern struct dyesub_backend updr150_backend;

View File

@ -209,7 +209,7 @@ static uint8_t * dnpds40_resp_cmd(struct dnpds40_ctx *ctx,
return NULL;
}
if (getenv("DYESUB_DEBUG")) {
if (dyesub_debug) {
DEBUG("<- ");
for (i = 0 ; i < num; i++) {
DEBUG2("%02x ", tmp[i]);
@ -228,7 +228,7 @@ static uint8_t * dnpds40_resp_cmd(struct dnpds40_ctx *ctx,
&num,
5000);
if (getenv("DYESUB_DEBUG")) {
if (dyesub_debug) {
DEBUG("<- ");
for (i = 0 ; i < num; i++) {
DEBUG2("%02x ", respbuf[i]);

View File

@ -366,7 +366,8 @@ static int kodak1400_main_loop(void *vctx, int copies) {
top:
if (state != last_state) {
DEBUG("last_state %d new %d\n", last_state, state);
if (dyesub_debug)
DEBUG("last_state %d new %d\n", last_state, state);
}
/* Send Status Query */
@ -392,11 +393,13 @@ top:
if (memcmp(rdbuf, rdbuf2, READBACK_LEN)) {
int i;
DEBUG("readback: ");
for (i = 0 ; i < num ; i++) {
DEBUG2("%02x ", rdbuf[i]);
if (dyesub_debug) {
DEBUG("<- ");
for (i = 0 ; i < num ; i++) {
DEBUG2("%02x ", rdbuf[i]);
}
DEBUG2("\n");
}
DEBUG2("\n");
memcpy(rdbuf2, rdbuf, READBACK_LEN);
} else if (state == last_state) {
sleep(1);
@ -567,7 +570,7 @@ top:
struct dyesub_backend kodak1400_backend = {
.name = "Kodak 1400/805",
.version = "0.23",
.version = "0.24",
.uri_prefix = "kodak1400",
.cmdline_usage = kodak1400_cmdline,
.cmdline_arg = kodak1400_cmdline_arg,

View File

@ -184,7 +184,8 @@ static int kodak605_main_loop(void *vctx, int copies) {
top:
if (state != last_state) {
DEBUG("last_state %d new %d\n", last_state, state);
if (dyesub_debug)
DEBUG("last_state %d new %d\n", last_state, state);
}
if (pending)
@ -223,11 +224,13 @@ skip_query:
}
if (memcmp(rdbuf, rdbuf2, READBACK_LEN)) {
DEBUG("readback: ");
for (i = 0 ; i < num ; i++) {
DEBUG2("%02x ", rdbuf[i]);
if (dyesub_debug) {
DEBUG("<- ");
for (i = 0 ; i < num ; i++) {
DEBUG2("%02x ", rdbuf[i]);
}
DEBUG2("\n");
}
DEBUG2("\n");
memcpy(rdbuf2, rdbuf, READBACK_LEN);
} else if (state == last_state) {
sleep(1);
@ -504,7 +507,7 @@ static int kodak605_cmdline_arg(void *vctx, int run, char *arg1, char *arg2)
/* Exported */
struct dyesub_backend kodak605_backend = {
.name = "Kodak 605",
.version = "0.09",
.version = "0.10",
.uri_prefix = "kodak605",
.cmdline_usage = kodak605_cmdline,
.cmdline_arg = kodak605_cmdline_arg,

View File

@ -154,7 +154,8 @@ static int mitsu70x_main_loop(void *vctx, int copies) {
top:
if (state != last_state) {
DEBUG("last_state %d new %d\n", last_state, state);
if (dyesub_debug)
DEBUG("last_state %d new %d\n", last_state, state);
}
if (pending)
@ -196,11 +197,13 @@ skip_query:
}
if (memcmp(rdbuf, rdbuf2, READBACK_LEN)) {
DEBUG("readback: ");
for (i = 0 ; i < num ; i++) {
DEBUG2("%02x ", rdbuf[i]);
if(dyesub_debug) {
DEBUG("<- ");
for (i = 0 ; i < num ; i++) {
DEBUG2("%02x ", rdbuf[i]);
}
DEBUG2("\n");
}
DEBUG2("\n");
memcpy(rdbuf2, rdbuf, READBACK_LEN);
} else if (state == last_state) {
sleep(1);
@ -302,21 +305,23 @@ static int mitsu70x_get_status(struct mitsu70x_ctx *ctx)
sizeof(resp),
&num,
5000);
DEBUG("Status Dump:\n");
for (i = 0 ; i < sizeof(resp.unk) ; i++) {
DEBUG2("%02x ", resp.unk[i]);
if (dyesub_debug) {
DEBUG("Status Dump:\n");
for (i = 0 ; i < sizeof(resp.unk) ; i++) {
DEBUG2("%02x ", resp.unk[i]);
}
DEBUG2("\n");
DEBUG("Lower Deck:\n");
for (i = 0 ; i < sizeof(resp.lower.unk) ; i++) {
DEBUG2("%02x ", resp.lower.unk[i]);
}
DEBUG2("\n");
DEBUG("Upper Deck:\n");
for (i = 0 ; i < sizeof(resp.upper.unk) ; i++) {
DEBUG2("%02x ", resp.upper.unk[i]);
}
DEBUG2("\n");
}
DEBUG("\n");
DEBUG("Lower Deck:\n");
for (i = 0 ; i < sizeof(resp.lower.unk) ; i++) {
DEBUG2("%02x ", resp.lower.unk[i]);
}
DEBUG("\n");
DEBUG("Upper Deck:\n");
for (i = 0 ; i < sizeof(resp.upper.unk) ; i++) {
DEBUG2("%02x ", resp.upper.unk[i]);
}
DEBUG("\n");
INFO("Prints remaining: Lower: %d Upper: %d\n",
resp.lower.unk[23], resp.upper.unk[23]);
@ -347,7 +352,7 @@ static int mitsu70x_cmdline_arg(void *vctx, int run, char *arg1, char *arg2)
/* Exported */
struct dyesub_backend mitsu70x_backend = {
.name = "Mitsubishi CP-D70/D707",
.version = "0.05",
.version = "0.06",
.uri_prefix = "mitsu70x",
.cmdline_usage = mitsu70x_cmdline,
.cmdline_arg = mitsu70x_cmdline_arg,

View File

@ -1481,9 +1481,10 @@ static int shinkos2145_main_loop(void *vctx, int copies) {
struct s2145_print_cmd *print = (struct s2145_print_cmd *) cmdbuf;
struct s2145_status_resp *sts = (struct s2145_status_resp *) rdbuf;
top:
top:
if (state != last_state) {
DEBUG("last_state %d new %d\n", last_state, state);
if (dyesub_debug)
DEBUG("last_state %d new %d\n", last_state, state);
}
/* Send Status Query */
@ -1500,11 +1501,13 @@ top:
}
if (memcmp(rdbuf, rdbuf2, READBACK_LEN)) {
DEBUG("readback: ");
for (i = 0 ; i < num ; i++) {
DEBUG2("%02x ", rdbuf[i]);
if (dyesub_debug) {
DEBUG("<- ");
for (i = 0 ; i < num ; i++) {
DEBUG2("%02x ", rdbuf[i]);
}
DEBUG2("\n");
}
DEBUG2("\n");
memcpy(rdbuf2, rdbuf, READBACK_LEN);
INFO("Printer Status: 0x%02x (%s)\n",
@ -1660,7 +1663,7 @@ static int shinkos2145_query_serno(struct libusb_device_handle *dev, uint8_t end
struct dyesub_backend shinkos2145_backend = {
.name = "Shinko/Sinfonia CHC-S2145 (S2)",
.version = "0.23",
.version = "0.24",
.uri_prefix = "shinkos2145",
.cmdline_usage = shinkos2145_cmdline,
.cmdline_arg = shinkos2145_cmdline_arg,

View File

@ -124,21 +124,25 @@ top:
case 0xeb:
case 0xfa:
case 0xf3:
DEBUG("Block ID '%x' (len %d)\n", *ptr, 0);
if(dyesub_debug)
DEBUG("Block ID '%x' (len %d)\n", *ptr, 0);
break;
case 0xef:
case 0xf5:
DEBUG("Block ID '%x' (len %d)\n", *ptr, 4);
if(dyesub_debug)
DEBUG("Block ID '%x' (len %d)\n", *ptr, 4);
i += 4;
break;
default:
DEBUG("Unknown block ID '%x'\n", *ptr);
if(dyesub_debug)
DEBUG("Unknown block ID '%x'\n", *ptr);
break;
}
} else {
uint32_t len = le32_to_cpu(*((uint32_t*)ptr));
DEBUG("Sending %d bytes to printer\n", len);
if (dyesub_debug)
DEBUG("Sending %d bytes to printer\n", len);
if ((ret = send_data(ctx->dev, ctx->endp_down,
ctx->databuf + i, len)))
return ret;
@ -165,7 +169,7 @@ top:
struct dyesub_backend updr150_backend = {
.name = "Sony UP-DR150",
.version = "0.06",
.version = "0.07",
.uri_prefix = "sonyupdr150",
.init = updr150_init,
.attach = updr150_attach,