[tor-commits] [tor/master] All loging messages are now sent to stderr.

nickm at torproject.org nickm at torproject.org
Thu Sep 6 14:14:30 UTC 2012


commit e8be040016a279d5cbef38fa5328cc2eb0de2c46
Author: George Kadianakis <desnacked at riseup.net>
Date:   Thu Jun 7 00:59:20 2012 +0300

    All loging messages are now sent to stderr.
    
    stdout should be clean for control messages.
---
 src/tools/tor-fw-helper/tor-fw-helper-natpmp.c |   28 ++++++++++++------------
 src/tools/tor-fw-helper/tor-fw-helper-upnp.c   |    4 +-
 src/tools/tor-fw-helper/tor-fw-helper.c        |   12 +++++-----
 3 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/src/tools/tor-fw-helper/tor-fw-helper-natpmp.c b/src/tools/tor-fw-helper/tor-fw-helper-natpmp.c
index 257ef0d..ee6d5f3 100644
--- a/src/tools/tor-fw-helper/tor-fw-helper-natpmp.c
+++ b/src/tools/tor-fw-helper/tor-fw-helper-natpmp.c
@@ -60,15 +60,15 @@ tor_natpmp_init(tor_fw_options_t *tor_fw_options, void *backend_state)
   state->lease = NATPMP_DEFAULT_LEASE;
 
   if (tor_fw_options->verbose)
-    fprintf(stdout, "V: natpmp init...\n");
+    fprintf(stderr, "V: natpmp init...\n");
 
   r = initnatpmp(&(state->natpmp), 0, 0);
   if (r == 0) {
     state->init = 1;
-    fprintf(stdout, "tor-fw-helper: natpmp initialized...\n");
+    fprintf(stderr, "V: natpmp initialized...\n");
     return r;
   } else {
-    fprintf(stderr, "tor-fw-helper: natpmp failed to initialize...\n");
+    fprintf(stderr, "V: natpmp failed to initialize...\n");
     return r;
   }
 }
@@ -80,10 +80,10 @@ tor_natpmp_cleanup(tor_fw_options_t *tor_fw_options, void *backend_state)
   natpmp_state_t *state = (natpmp_state_t *) backend_state;
   int r = 0;
   if (tor_fw_options->verbose)
-    fprintf(stdout, "V: natpmp cleanup...\n");
+    fprintf(stderr, "V: natpmp cleanup...\n");
   r = closenatpmp(&(state->natpmp));
   if (tor_fw_options->verbose)
-    fprintf(stdout, "V: closing natpmp socket: %d\n", r);
+    fprintf(stderr, "V: closing natpmp socket: %d\n", r);
   return r;
 }
 
@@ -101,7 +101,7 @@ wait_until_fd_readable(tor_socket_t fd, struct timeval *timeout)
   FD_SET(fd, &fds);
   r = select(fd+1, &fds, NULL, NULL, timeout);
   if (r == -1) {
-    fprintf(stdout, "V: select failed in wait_until_fd_readable: %s\n",
+    fprintf(stderr, "V: select failed in wait_until_fd_readable: %s\n",
             strerror(errno));
     return -1;
   }
@@ -185,7 +185,7 @@ tor_natpmp_fetch_public_ip(tor_fw_options_t *tor_fw_options,
   struct timeval timeout;
 
   r = sendpublicaddressrequest(&(state->natpmp));
-  fprintf(stdout, "tor-fw-helper: NAT-PMP sendpublicaddressrequest returned"
+  fprintf(stderr, "tor-fw-helper: NAT-PMP sendpublicaddressrequest returned"
           " %d (%s)\n", r, r==2?"SUCCESS":"FAILED");
 
   do {
@@ -196,12 +196,12 @@ tor_natpmp_fetch_public_ip(tor_fw_options_t *tor_fw_options,
       return -1;
 
     if (tor_fw_options->verbose)
-      fprintf(stdout, "V: NAT-PMP attempting to read reponse...\n");
+      fprintf(stderr, "V: NAT-PMP attempting to read reponse...\n");
     r = readnatpmpresponseorretry(&(state->natpmp), &(state->response));
     sav_errno = errno;
 
     if (tor_fw_options->verbose)
-      fprintf(stdout, "V: NAT-PMP readnatpmpresponseorretry returned"
+      fprintf(stderr, "V: NAT-PMP readnatpmpresponseorretry returned"
               " %d\n", r);
 
     if ( r < 0 && r != NATPMP_TRYAGAIN) {
@@ -219,15 +219,15 @@ tor_natpmp_fetch_public_ip(tor_fw_options_t *tor_fw_options,
     return r;
   }
 
-  fprintf(stdout, "tor-fw-helper: ExternalIPAddress = %s\n",
+  fprintf(stderr, "tor-fw-helper: ExternalIPAddress = %s\n",
           inet_ntoa((state->response).pnu.publicaddress.addr));
   tor_fw_options->public_ip_status = 1;
 
   if (tor_fw_options->verbose) {
-    fprintf(stdout, "V: result = %u\n", r);
-    fprintf(stdout, "V: type = %u\n", (state->response).type);
-    fprintf(stdout, "V: resultcode = %u\n", (state->response).resultcode);
-    fprintf(stdout, "V: epoch = %u\n", (state->response).epoch);
+    fprintf(stderr, "V: result = %u\n", r);
+    fprintf(stderr, "V: type = %u\n", (state->response).type);
+    fprintf(stderr, "V: resultcode = %u\n", (state->response).resultcode);
+    fprintf(stderr, "V: epoch = %u\n", (state->response).epoch);
   }
 
   return r;
diff --git a/src/tools/tor-fw-helper/tor-fw-helper-upnp.c b/src/tools/tor-fw-helper/tor-fw-helper-upnp.c
index 0977e0d..e5c33db 100644
--- a/src/tools/tor-fw-helper/tor-fw-helper-upnp.c
+++ b/src/tools/tor-fw-helper/tor-fw-helper-upnp.c
@@ -91,7 +91,7 @@ tor_upnp_init(tor_fw_options_t *options, void *backend_state)
   assert(options);
   r = UPNP_GetValidIGD(devlist, &(state->urls), &(state->data),
                        state->lanaddr, UPNP_LANADDR_SZ);
-  fprintf(stdout, "tor-fw-helper: UPnP GetValidIGD returned: %d (%s)\n", r,
+  fprintf(stderr, "tor-fw-helper: UPnP GetValidIGD returned: %d (%s)\n", r,
           r==UPNP_SUCCESS?"SUCCESS":"FAILED");
 
   freeUPNPDevlist(devlist);
@@ -141,7 +141,7 @@ tor_upnp_fetch_public_ip(tor_fw_options_t *options, void *backend_state)
     goto err;
 
   if (externalIPAddress[0]) {
-    fprintf(stdout, "tor-fw-helper: ExternalIPAddress = %s\n",
+    fprintf(stderr, "tor-fw-helper: ExternalIPAddress = %s\n",
             externalIPAddress); tor_upnp_cleanup(options, state);
     options->public_ip_status = 1;
     return UPNP_ERR_SUCCESS;
diff --git a/src/tools/tor-fw-helper/tor-fw-helper.c b/src/tools/tor-fw-helper/tor-fw-helper.c
index 00d2c4e..3263354 100644
--- a/src/tools/tor-fw-helper/tor-fw-helper.c
+++ b/src/tools/tor-fw-helper/tor-fw-helper.c
@@ -125,7 +125,7 @@ log_commandline_options(int argc, char **argv)
     if (retval < 0)
       goto error;
 
-    retval = fprintf(stdout, "ARG: %d: %s\n", i, argv[i]);
+    retval = fprintf(stderr, "ARG: %d: %s\n", i, argv[i]);
     if (retval < 0)
       goto error;
   }
@@ -152,19 +152,19 @@ tor_fw_fetch_public_ip(tor_fw_options_t *tor_fw_options,
   int r = 0;
 
   if (tor_fw_options->verbose)
-    fprintf(stdout, "V: tor_fw_fetch_public_ip\n");
+    fprintf(stderr, "V: tor_fw_fetch_public_ip\n");
 
   for (i=0; i<backends->n_backends; ++i) {
     if (tor_fw_options->verbose) {
-        fprintf(stdout, "V: running backend_state now: %i\n", i);
-        fprintf(stdout, "V: size of backend state: %u\n",
+        fprintf(stderr, "V: running backend_state now: %i\n", i);
+        fprintf(stderr, "V: size of backend state: %u\n",
                 (int)(backends->backend_ops)[i].state_len);
-        fprintf(stdout, "V: backend state name: %s\n",
+        fprintf(stderr, "V: backend state name: %s\n",
                 (char *)(backends->backend_ops)[i].name);
       }
     r = backends->backend_ops[i].fetch_public_ip(tor_fw_options,
                                                  backends->backend_state[i]);
-    fprintf(stdout, "tor-fw-helper: tor_fw_fetch_public_ip backend %s "
+    fprintf(stderr, "tor-fw-helper: tor_fw_fetch_public_ip backend %s "
             " returned: %i\n", (char *)(backends->backend_ops)[i].name, r);
   }
 }





More information about the tor-commits mailing list