Convert lots of fprintf(stderr, ...) to glibtop_debug*().

This commit is contained in:
Benoit Dejean
2015-06-21 22:39:11 +02:00
parent 887092a05d
commit 172f0a50ba
10 changed files with 22 additions and 65 deletions

View File

@@ -27,10 +27,8 @@ void
do_output (int s, glibtop_response *resp, off_t offset,
size_t data_size, const void *data)
{
#ifdef LIBGTOP_ENABLE_DEBUG
fprintf (stderr, "Really writing %d bytes at offset %lu.\n",
glibtop_debug ("Really writing %d bytes at offset %lu.",
sizeof (glibtop_response), offset);
#endif
resp->offset = offset;
resp->data_size = data_size;
@@ -44,9 +42,7 @@ do_output (int s, glibtop_response *resp, off_t offset,
}
if (resp->data_size) {
#ifdef LIBGTOP_ENABLE_DEBUG
fprintf (stderr, "Writing %d bytes of data.\n", resp->data_size);
#endif
glibtop_debug ("Writing %d bytes of data.", resp->data_size);
if (s == 0) {
if (write (1, data, resp->data_size) < 0)
@@ -88,10 +84,8 @@ do_read (int s, void *ptr, size_t total_size)
tmp_ptr += nread;
ptr = tmp_ptr;
#ifdef LIBGTOP_ENABLE_DEBUG
fprintf (stderr, "READ (%d): %d - %d - %d\n",
glibtop_debug ("READ (%d): %d - %d - %d",
nread, already_read, remaining, total_size);
#endif
}
return already_read;

View File

@@ -26,9 +26,6 @@
#ifndef PARENT_DEBUG
#define PARENT_DEBUG 1
#endif
#ifndef LIBGTOP_ENABLE_DEBUG
#define LIBGTOP_ENABLE_DEBUG 1
#endif
#endif
void

View File

@@ -41,10 +41,8 @@ handle_slave_connection (int input, int output)
glibtop_send_version (glibtop_global_server, output);
while (do_read (input, cmnd, sizeof (glibtop_command))) {
#ifdef LIBGTOP_ENABLE_DEBUG
fprintf (stderr, "Slave %d received command "
"%llu from client.\n", getpid (), cmnd->command);
#endif
glibtop_debug ("Slave %d received command "
"%llu from client.", getpid (), cmnd->command);
if (cmnd->data_size >= BUFSIZ)
glibtop_error ("Client sent %llu bytes, "
@@ -56,10 +54,8 @@ handle_slave_connection (int input, int output)
memset (parameter, 0, sizeof (parameter));
if (cmnd->data_size) {
#ifdef LIBGTOP_ENABLE_DEBUG
fprintf (stderr, "Client has %llu bytes of data.\n",
glibtop_debug ("Client has %llu bytes of data.",
cmnd->data_size);
#endif
do_read (input, parameter, cmnd->data_size);

View File

@@ -42,9 +42,7 @@ glibtop_send_version (glibtop *server, int fd)
size = strlen (buffer) + 1;
#ifdef LIBGTOP_ENABLE_DEBUG
fprintf (stderr, "SERVER ID: |%s|\n", buffer);
#endif
glibtop_debug ("SERVER ID: |%s|", buffer);
if (fd == 0) {
if (write (1, (const void *) &size, sizeof (size)) < 0)