[or-cvs] Migrate a few more files to domained logging

Nick Mathewson nickm at seul.org
Tue Oct 18 22:21:32 UTC 2005


Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv9530/src/or

Modified Files:
	buffers.c control.c or.h 
Log Message:
Migrate a few more files to domained logging

Index: buffers.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/buffers.c,v
retrieving revision 1.174
retrieving revision 1.175
diff -u -d -r1.174 -r1.175
--- buffers.c	14 Oct 2005 02:26:12 -0000	1.174
+++ buffers.c	18 Oct 2005 22:21:29 -0000	1.175
@@ -12,6 +12,7 @@
  * memory, file descriptors, or TLS connections.
  **/
 
+#define NEW_LOG_INTERFACE
 #include "or.h"
 
 #define SENTINELS
@@ -86,7 +87,7 @@
   } else {
     char *newmem, *oldmem;
     size_t sz = (buf->mem+buf->len)-buf->cur;
-    log_fn(LOG_WARN, "Unexpected non-normalized buffer.");
+    warn(LD_GENERAL, "Unexpected non-normalized buffer.");
     newmem = GUARDED_MEM(tor_malloc(ALLOC_LEN(buf->len)));
     SET_GUARDS(newmem, buf->len);
     memcpy(newmem, buf->cur, sz);
@@ -259,8 +260,8 @@
   while (new_len < capacity)
     new_len *= 2;
   /* Resize the buffer. */
-  log_fn(LOG_DEBUG,"Growing buffer from %d to %d bytes.",
-         (int)buf->len, (int)new_len);
+  debug(LD_MM,"Growing buffer from %d to %d bytes.",
+        (int)buf->len, (int)new_len);
   buf_resize(buf,new_len);
   return 0;
 }
@@ -284,7 +285,7 @@
   if (new_len == buf->len)
     return;
 
-  log_fn(LOG_DEBUG,"Shrinking buffer from %d to %d bytes.",
+  debug(LD_MM,"Shrinking buffer from %d to %d bytes.",
          (int)buf->len, (int)new_len);
   buf_resize(buf, new_len);
 }
@@ -404,7 +405,7 @@
     }
     return 0; /* would block. */
   } else if (read_result == 0) {
-    log_fn(LOG_DEBUG,"Encountered eof");
+    debug(LD_NET,"Encountered eof");
     *reached_eof = 1;
     return 0;
   } else { /* we read some bytes */
@@ -412,7 +413,7 @@
     buf_total_used += read_result;
     if (buf->datalen > buf->highwater)
       buf->highwater = buf->datalen;
-    log_fn(LOG_DEBUG,"Read %d bytes. %d on inbuf.",read_result,
+    debug(LD_NET,"Read %d bytes. %d on inbuf.",read_result,
            (int)buf->datalen);
     return read_result;
   }
@@ -478,7 +479,7 @@
 {
   int r;
 
-  log_fn(LOG_DEBUG,"before: %d on buf, %d pending, at_most %d.",
+  debug(LD_NET,"before: %d on buf, %d pending, at_most %d.",
          (int)buf_datalen(buf), (int)tor_tls_get_pending_bytes(tls),
          (int)at_most);
   r = tor_tls_read(tls, next, at_most);
@@ -488,7 +489,7 @@
   buf_total_used += r;
   if (buf->datalen > buf->highwater)
     buf->highwater = buf->datalen;
-  log_fn(LOG_DEBUG,"Read %d bytes. %d on inbuf; %d pending",r,
+  debug(LD_NET,"Read %d bytes. %d on inbuf; %d pending",r,
          (int)buf->datalen,(int)tor_tls_get_pending_bytes(tls));
   return r;
 }
@@ -522,7 +523,7 @@
   tor_assert(tls);
   assert_buf_ok(buf);
 
-  log_fn(LOG_DEBUG,"start: %d on buf, %d pending, at_most %d.",
+  debug(LD_NET,"start: %d on buf, %d pending, at_most %d.",
          (int)buf_datalen(buf), (int)tor_tls_get_pending_bytes(tls),
          (int)at_most);
 
@@ -572,7 +573,7 @@
     if (!ERRNO_IS_EAGAIN(e)) { /* it's a real error */
       return -1;
     }
-    log_fn(LOG_DEBUG,"write() would block, returning.");
+    debug(LD_NET,"write() would block, returning.");
     return 0;
   } else {
     *buf_flushlen -= write_result;
@@ -610,7 +611,7 @@
   r = flush_buf_impl(s, buf, flushlen0, buf_flushlen);
   check();
 
-  log_fn(LOG_DEBUG,"%d: flushed %d bytes, %d ready to flush, %d remain.",
+  debug(LD_NET,"%d: flushed %d bytes, %d ready to flush, %d remain.",
            s,r,(int)*buf_flushlen,(int)buf->datalen);
   if (r < 0 || (size_t)r < flushlen0)
     return r; /* Error, or can't flush any more now. */
@@ -620,7 +621,7 @@
     tor_assert(buf->cur == buf->mem);
     r = flush_buf_impl(s, buf, flushlen1, buf_flushlen);
     check();
-    log_fn(LOG_DEBUG,"%d: flushed %d bytes, %d ready to flush, %d remain.",
+    debug(LD_NET,"%d: flushed %d bytes, %d ready to flush, %d remain.",
            s,r,(int)*buf_flushlen,(int)buf->datalen);
     if (r<0)
       return r;
@@ -645,7 +646,7 @@
   }
   *buf_flushlen -= r;
   buf_remove_from_front(buf, r);
-  log_fn(LOG_DEBUG,"flushed %d bytes, %d ready to flush, %d remain.",
+  debug(LD_NET,"flushed %d bytes, %d ready to flush, %d remain.",
          r,(int)*buf_flushlen,(int)buf->datalen);
   return r;
 }
@@ -705,7 +706,7 @@
   assert_buf_ok(buf);
 
   if (buf_ensure_capacity(buf, buf->datalen+string_len)) {
-    log_fn(LOG_WARN, "buflen too small, can't hold %d bytes.", (int)(buf->datalen+string_len));
+    warn(LD_MM, "buflen too small, can't hold %d bytes.", (int)(buf->datalen+string_len));
     return -1;
   }
 
@@ -724,7 +725,7 @@
   }
   if (buf->datalen > buf->highwater)
     buf->highwater = buf->datalen;
-  log_fn(LOG_DEBUG,"added %d bytes to buf (now %d total).",
+  debug(LD_NET,"added %d bytes to buf (now %d total).",
          (int)string_len, (int)buf->datalen);
   check();
   return buf->datalen;
@@ -806,27 +807,27 @@
   buf_normalize(buf);
 
   if (buf_nul_terminate(buf)<0) {
-    log_fn(LOG_WARN,"Couldn't nul-terminate buffer");
+    warn(LD_GENERAL,"Couldn't nul-terminate buffer");
     return -1;
   }
   headers = buf->cur;
   body = strstr(headers,"\r\n\r\n");
   if (!body) {
-    log_fn(LOG_DEBUG,"headers not all here yet.");
+    debug(LD_HTTP,"headers not all here yet.");
     return 0;
   }
   body += 4; /* Skip the the CRLFCRLF */
   headerlen = body-headers; /* includes the CRLFCRLF */
   bodylen = buf->datalen - headerlen;
-  log_fn(LOG_DEBUG,"headerlen %d, bodylen %d.", (int)headerlen, (int)bodylen);
+  debug(LD_HTTP,"headerlen %d, bodylen %d.", (int)headerlen, (int)bodylen);
 
   if (max_headerlen <= headerlen) {
-    log_fn(LOG_WARN,"headerlen %d larger than %d. Failing.", (int)headerlen,
+    warn(LD_HTTP,"headerlen %d larger than %d. Failing.", (int)headerlen,
            (int)max_headerlen-1);
     return -1;
   }
   if (max_bodylen <= bodylen) {
-    log_fn(LOG_WARN,"bodylen %d larger than %d. Failing.", (int)bodylen, (int)max_bodylen-1);
+    warn(LD_HTTP,"bodylen %d larger than %d. Failing.", (int)bodylen, (int)max_bodylen-1);
     return -1;
   }
 
@@ -836,21 +837,21 @@
     int i;
     i = atoi(p+strlen(CONTENT_LENGTH));
     if (i < 0) {
-      log_fn(LOG_WARN, "Content-Length is less than zero; it looks like someone is trying to crash us.");
+      warn(LD_PROTOCOL, "Content-Length is less than zero; it looks like someone is trying to crash us.");
       return -1;
     }
     contentlen = i;
     /* if content-length is malformed, then our body length is 0. fine. */
-    log_fn(LOG_DEBUG,"Got a contentlen of %d.",(int)contentlen);
+    debug(LD_HTTP,"Got a contentlen of %d.",(int)contentlen);
     if (bodylen < contentlen) {
       if (!force_complete) {
-        log_fn(LOG_DEBUG,"body not all here yet.");
+        debug(LD_HTTP,"body not all here yet.");
         return 0; /* not all there yet */
       }
     }
     if (bodylen > contentlen) {
       bodylen = contentlen;
-      log_fn(LOG_DEBUG,"bodylen reduced to %d.",(int)bodylen);
+      debug(LD_HTTP,"bodylen reduced to %d.",(int)bodylen);
     }
   }
   /* all happy. copy into the appropriate places, and return 1 */
@@ -917,7 +918,7 @@
         if (buf->datalen < 2u+nummethods)
           return 0;
         if (!nummethods || !memchr(buf->cur+2, 0, nummethods)) {
-          log_fn(LOG_WARN,"socks5: offered methods don't include 'no auth'. Rejecting.");
+          warn(LD_APP,"socks5: offered methods don't include 'no auth'. Rejecting.");
           req->replylen = 2; /* 2 bytes of response */
           req->reply[0] = 5;
           req->reply[1] = '\xFF'; /* reject all methods */
@@ -929,24 +930,24 @@
         req->reply[0] = 5; /* socks5 reply */
         req->reply[1] = SOCKS5_SUCCEEDED;
         req->socks_version = 5; /* remember that we've already negotiated auth */
-        log_fn(LOG_DEBUG,"socks5: accepted method 0");
+        debug(LD_APP,"socks5: accepted method 0");
         return 0;
       }
       /* we know the method; read in the request */
-      log_fn(LOG_DEBUG,"socks5: checking request");
+      debug(LD_APP,"socks5: checking request");
       if (buf->datalen < 8) /* basic info plus >=2 for addr plus 2 for port */
         return 0; /* not yet */
       req->command = (unsigned char) *(buf->cur+1);
       if (req->command != SOCKS_COMMAND_CONNECT &&
           req->command != SOCKS_COMMAND_RESOLVE) {
         /* not a connect or resolve? we don't support it. */
-        log_fn(LOG_WARN,"socks5: command %d not recognized. Rejecting.",
+        warn(LD_APP,"socks5: command %d not recognized. Rejecting.",
                req->command);
         return -1;
       }
       switch (*(buf->cur+3)) { /* address type */
         case 1: /* IPv4 address */
-          log_fn(LOG_DEBUG,"socks5: ipv4 address type");
+          debug(LD_APP,"socks5: ipv4 address type");
           if (buf->datalen < 10) /* ip/port there? */
             return 0; /* not yet */
 
@@ -954,7 +955,7 @@
           in.s_addr = htonl(destip);
           tor_inet_ntoa(&in,tmpbuf,sizeof(tmpbuf));
           if (strlen(tmpbuf)+1 > MAX_SOCKS_ADDR_LEN) {
-            log_fn(LOG_WARN,"socks5 IP takes %d bytes, which doesn't fit in %d. Rejecting.",
+            warn(LD_APP,"socks5 IP takes %d bytes, which doesn't fit in %d. Rejecting.",
                    (int)strlen(tmpbuf)+1,(int)MAX_SOCKS_ADDR_LEN);
             return -1;
           }
@@ -963,17 +964,17 @@
           buf_remove_from_front(buf, 10);
           if (!address_is_in_virtual_range(req->address) &&
               !have_warned_about_unsafe_socks) {
-            log_fn(LOG_WARN,"Your application (using socks5 on port %d) is giving Tor only an IP address. Applications that do DNS resolves themselves may leak information. Consider using Socks4A (e.g. via privoxy or socat) instead.  For more information, please see http://wiki.noreply.org/noreply/TheOnionRouter/TorFAQ#SOCKSAndDNS", req->port);
+            warn(LD_APP,"Your application (using socks5 on port %d) is giving Tor only an IP address. Applications that do DNS resolves themselves may leak information. Consider using Socks4A (e.g. via privoxy or socat) instead.  For more information, please see http://wiki.noreply.org/noreply/TheOnionRouter/TorFAQ#SOCKSAndDNS", req->port);
 //            have_warned_about_unsafe_socks = 1; // (for now, warn every time)
           }
           return 1;
         case 3: /* fqdn */
-          log_fn(LOG_DEBUG,"socks5: fqdn address type");
+          debug(LD_APP,"socks5: fqdn address type");
           len = (unsigned char)*(buf->cur+4);
           if (buf->datalen < 7u+len) /* addr/port there? */
             return 0; /* not yet */
           if (len+1 > MAX_SOCKS_ADDR_LEN) {
-            log_fn(LOG_WARN,"socks5 hostname is %d bytes, which doesn't fit in %d. Rejecting.",
+            warn(LD_APP,"socks5 hostname is %d bytes, which doesn't fit in %d. Rejecting.",
                    len+1,MAX_SOCKS_ADDR_LEN);
             return -1;
           }
@@ -983,7 +984,7 @@
           buf_remove_from_front(buf, 5+len+2);
           return 1;
         default: /* unsupported */
-          log_fn(LOG_WARN,"socks5: unsupported address type %d. Rejecting.",*(buf->cur+3));
+          warn(LD_APP,"socks5: unsupported address type %d. Rejecting.",*(buf->cur+3));
           return -1;
       }
       tor_assert(0);
@@ -999,7 +1000,7 @@
       if (req->command != SOCKS_COMMAND_CONNECT &&
           req->command != SOCKS_COMMAND_RESOLVE) {
         /* not a connect or resolve? we don't support it. */
-        log_fn(LOG_WARN,"socks4: command %d not recognized. Rejecting.",
+        warn(LD_APP,"socks4: command %d not recognized. Rejecting.",
                req->command);
         return -1;
       }
@@ -1007,26 +1008,26 @@
       req->port = ntohs(*(uint16_t*)(buf->cur+2));
       destip = ntohl(*(uint32_t*)(buf->mem+4));
       if ((!req->port && req->command!=SOCKS_COMMAND_RESOLVE) || !destip) {
-        log_fn(LOG_WARN,"socks4: Port or DestIP is zero. Rejecting.");
+        warn(LD_APP,"socks4: Port or DestIP is zero. Rejecting.");
         return -1;
       }
       if (destip >> 8) {
-        log_fn(LOG_DEBUG,"socks4: destip not in form 0.0.0.x.");
+        debug(LD_APP,"socks4: destip not in form 0.0.0.x.");
         in.s_addr = htonl(destip);
         tor_inet_ntoa(&in,tmpbuf,sizeof(tmpbuf));
         if (strlen(tmpbuf)+1 > MAX_SOCKS_ADDR_LEN) {
-          log_fn(LOG_WARN,"socks4 addr (%d bytes) too long. Rejecting.",
+          debug(LD_APP,"socks4 addr (%d bytes) too long. Rejecting.",
                  (int)strlen(tmpbuf));
           return -1;
         }
-        log_fn(LOG_DEBUG,"socks4: successfully read destip (%s)", safe_str(tmpbuf));
+        debug(LD_APP,"socks4: successfully read destip (%s)", safe_str(tmpbuf));
         socks4_prot = socks4;
       }
 
       next = memchr(buf->cur+SOCKS4_NETWORK_LEN, 0,
                     buf->datalen-SOCKS4_NETWORK_LEN);
       if (!next) {
-        log_fn(LOG_DEBUG,"socks4: Username not here yet.");
+        debug(LD_APP,"socks4: Username not here yet.");
         return 0;
       }
       tor_assert(next < buf->cur+buf->datalen);
@@ -1035,27 +1036,27 @@
       if (socks4_prot != socks4a &&
           !address_is_in_virtual_range(tmpbuf) &&
           !have_warned_about_unsafe_socks) {
-        log_fn(LOG_WARN,"Your application (using socks4 on port %d) is giving Tor only an IP address. Applications that do DNS resolves themselves may leak information. Consider using Socks4A (e.g. via privoxy or socat) instead.", req->port);
+        warn(LD_APP,"Your application (using socks4 on port %d) is giving Tor only an IP address. Applications that do DNS resolves themselves may leak information. Consider using Socks4A (e.g. via privoxy or socat) instead.", req->port);
 //      have_warned_about_unsafe_socks = 1; // (for now, warn every time)
       }
       if (socks4_prot == socks4a) {
         if (next+1 == buf->cur+buf->datalen) {
-          log_fn(LOG_DEBUG,"socks4: No part of destaddr here yet.");
+          debug(LD_APP,"socks4: No part of destaddr here yet.");
           return 0;
         }
         startaddr = next+1;
         next = memchr(startaddr, 0, buf->cur+buf->datalen-startaddr);
         if (!next) {
-          log_fn(LOG_DEBUG,"socks4: Destaddr not all here yet.");
+          debug(LD_APP,"socks4: Destaddr not all here yet.");
           return 0;
         }
         if (MAX_SOCKS_ADDR_LEN <= next-startaddr) {
-          log_fn(LOG_WARN,"socks4: Destaddr too long. Rejecting.");
+          warn(LD_APP,"socks4: Destaddr too long. Rejecting.");
           return -1;
         }
         tor_assert(next < buf->cur+buf->datalen);
       }
-      log_fn(LOG_DEBUG,"socks4: Everything is here. Success.");
+      debug(LD_APP,"socks4: Everything is here. Success.");
       strlcpy(req->address, startaddr ? startaddr : tmpbuf,
               sizeof(req->address));
       buf_remove_from_front(buf, next-buf->cur+1); /* next points to the final \0 on inbuf */
@@ -1089,7 +1090,7 @@
       req->replylen = strlen(req->reply)+1;
       /* fall through */
     default: /* version is not socks4 or socks5 */
-      log_fn(LOG_WARN,"Socks version %d not recognized. (Tor is not an http proxy.)",
+      warn(LD_APP,"Socks version %d not recognized. (Tor is not an http proxy.)",
              *(buf->cur));
       return -1;
   }

Index: control.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/control.c,v
retrieving revision 1.142
retrieving revision 1.143
diff -u -d -r1.142 -r1.143
--- control.c	18 Oct 2005 17:43:54 -0000	1.142
+++ control.c	18 Oct 2005 22:21:29 -0000	1.143
@@ -8,6 +8,7 @@
  * \brief Implementation for Tor's control-socket interface.
  **/
 
+#define NEW_LOG_INTERFACE
 #include "or.h"
 
 #define STATE_IS_OPEN(s) ((s) == CONTROL_CONN_STATE_OPEN_V0 ||       \
@@ -691,7 +692,7 @@
     *outp = '\0';
 
     if (config_get_lines(config, &lines) < 0) {
-      log_fn(LOG_WARN,"Controller gave us config lines we can't parse.");
+      warn(LD_CONTROL,"Controller gave us config lines we can't parse.");
       connection_write_str_to_buf("551 Couldn't parse configuration\r\n", conn);
       tor_free(config);
       return 0;
@@ -699,7 +700,7 @@
     tor_free(config);
   } else {
     if (config_get_lines(body, &lines) < 0) {
-      log_fn(LOG_WARN,"Controller gave us config lines we can't parse.");
+      warn(LD_CONTROL,"Controller gave us config lines we can't parse.");
       send_control0_error(conn, ERR_SYNTAX, "Couldn't parse configuration");
       return 0;
     }
@@ -708,7 +709,7 @@
   if ((r=options_trial_assign(lines, use_defaults, clear_first)) < 0) {
     int v0_err;
     const char *msg;
-    log_fn(LOG_WARN,"Controller gave us config lines that didn't validate.");
+    warn(LD_CONTROL,"Controller gave us config lines that didn't validate.");
     switch (r) {
       case -1:
         v0_err = ERR_UNRECOGNIZED_CONFIG_KEY;
@@ -1003,7 +1004,7 @@
     char expected[S2K_SPECIFIER_LEN+DIGEST_LEN];
     char received[DIGEST_LEN];
     if (decode_hashed_password(expected, options->HashedControlPassword)<0) {
-      log_fn(LOG_WARN,"Couldn't decode HashedControlPassword: invalid base16");
+      warn(LD_CONTROL,"Couldn't decode HashedControlPassword: invalid base16");
       goto err;
     }
     secret_to_key(received,DIGEST_LEN,password,password_len,expected);
@@ -1028,7 +1029,7 @@
   }
   return 0;
  ok:
-  log_fn(LOG_INFO, "Authenticated control connection (%d)", conn->s);
+  info(LD_CONTROL, "Authenticated control connection (%d)", conn->s);
   send_control_done(conn);
   if (STATE_IS_V0(conn->state))
     conn->state = CONTROL_CONN_STATE_OPEN_V0;
@@ -1144,17 +1145,17 @@
       const char *from = smartlist_get(elts,0);
       const char *to = smartlist_get(elts,1);
       if (!is_plausible_address(from)) {
-        log_fn(LOG_WARN,"Skipping invalid argument '%s' in MapAddress msg",from);
+        warn(LD_CONTROL,"Skipping invalid argument '%s' in MapAddress msg",from);
       } else if (!is_plausible_address(to)) {
-        log_fn(LOG_WARN,"Skipping invalid argument '%s' in MapAddress msg",to);
+        warn(LD_CONTROL,"Skipping invalid argument '%s' in MapAddress msg",to);
       } else if (!strcmp(from, ".") || !strcmp(from, "0.0.0.0")) {
         const char *address = addressmap_register_virtual_address(
               !strcmp(from,".") ? RESOLVED_TYPE_HOSTNAME : RESOLVED_TYPE_IPV4,
                tor_strdup(to));
         if (!address) {
-          log_fn(LOG_WARN,
-                 "Unable to allocate address for '%s' in MapAddress msg",
-                 safe_str(line));
+          warn(LD_CONTROL,
+               "Unable to allocate address for '%s' in MapAddress msg",
+               safe_str(line));
         } else {
           size_t anslen = strlen(address)+strlen(to)+8;
           char *ans = tor_malloc(anslen);
@@ -1176,7 +1177,7 @@
         }
       }
     } else {
-      log_fn(LOG_WARN, "Skipping MapAddress line with wrong number of items.");
+      warn(LD_CONTROL, "Skipping MapAddress line with wrong number of items.");
     }
     SMARTLIST_FOREACH(elts, char *, cp, tor_free(cp));
     smartlist_clear(elts);
@@ -1326,7 +1327,7 @@
         case AP_CONN_STATE_OPEN:
           state = "SUCCEEDED"; break;
         default:
-          log_fn(LOG_WARN, "Asked for stream in unknown state %d",
+          warn(LD_GENERAL, "Asked for stream in unknown state %d",
                  conns[i]->state);
           continue;
         }
@@ -1585,7 +1586,7 @@
     if (circ->state == CIRCUIT_STATE_OPEN) {
       circ->state = CIRCUIT_STATE_BUILDING;
       if (circuit_send_next_onion_skin(circ) < 0) {
-        log_fn(LOG_INFO,"send_next_onion_skin failed; circuit marked for closing.");
+        info(LD_CONTROL,"send_next_onion_skin failed; circuit marked for closing.");
         circuit_mark_for_close(circ);
         if (v0)
           send_control0_error(conn, ERR_INTERNAL, "couldn't send onion skin");
@@ -1895,8 +1896,8 @@
         if (!strcasecmp(smartlist_get(args, i), "IfUnused"))
           safe = 1;
         else
-          log_fn(LOG_INFO, "Skipping unknown option %s",
-                 (char*)smartlist_get(args,i));
+          info(LD_CONTROL, "Skipping unknown option %s",
+               (char*)smartlist_get(args,i));
       }
     }
     SMARTLIST_FOREACH(args, char *, cp, tor_free(cp));
@@ -1924,7 +1925,7 @@
 {
   if (command_type == CONTROL0_CMD_FRAGMENTHEADER) {
     if (conn->incoming_cmd) {
-      log_fn(LOG_WARN, "Dropping incomplete fragmented command");
+      warn(LD_CONTROL, "Dropping incomplete fragmented command");
       tor_free(conn->incoming_cmd);
     }
     if (body_len < 6) {
@@ -1976,7 +1977,7 @@
   tor_assert(conn);
   tor_assert(conn->type == CONN_TYPE_CONTROL);
 
-  log_fn(LOG_INFO,"Control connection reached EOF. Closing.");
+  info(LD_CONTROL,"Control connection reached EOF. Closing.");
   connection_mark_for_close(conn);
   return 0;
 }
@@ -2049,10 +2050,6 @@
          && !TOR_ISSPACE(conn->incoming_cmd[cmd_len]))
     ++cmd_len;
 
-  /*
-  log_fn(LOG_NOTICE, "READ A COMMAND FROM THE BUFFER: <%s> [%d]",
-         conn->incoming_cmd, (int)cmd_len);
-  */
   data_len -= cmd_len;
   conn->incoming_cmd[cmd_len]='\0';
   args = conn->incoming_cmd+cmd_len+1;
@@ -2060,10 +2057,6 @@
     ++args;
     --data_len;
   }
-  /*
-  log_fn(LOG_NOTICE, "COMMAND IS: <%s>", conn->incoming_cmd);
-  log_fn(LOG_NOTICE, "ARGS ARE: <%s>", args);
-  */
 
   if (!strcasecmp(conn->incoming_cmd, "QUIT")) {
     connection_write_str_to_buf("250 closing connection\r\n", conn);
@@ -2149,13 +2142,13 @@
     {
     case -2:
       tor_free(body);
-      log_fn(LOG_INFO, "Detected v1 control protocol on connection (fd %d)",
-             conn->s);
+      info(LD_CONTROL, "Detected v1 control protocol on connection (fd %d)",
+           conn->s);
       conn->state = CONTROL_CONN_STATE_NEEDAUTH_V1;
       return connection_control_process_inbuf_v1(conn);
     case -1:
       tor_free(body);
-      log_fn(LOG_WARN, "Error in control command. Failing.");
+      warn(LD_CONTROL, "Error in control command. Failing.");
       return -1;
     case 0:
       /* Control command not all here yet. Wait. */
@@ -2171,8 +2164,8 @@
    * commands will be considered. */
   if (conn->state == CONTROL_CONN_STATE_NEEDAUTH_V0 &&
       command_type != CONTROL0_CMD_AUTHENTICATE) {
-    log_fn(LOG_WARN, "Rejecting '%s' command; authentication needed.",
-           control_cmd_to_string(command_type));
+    info(LD_CONTROL, "Rejecting '%s' command; authentication needed.",
+         control_cmd_to_string(command_type));
     send_control0_error(conn, ERR_UNAUTHORIZED, "Authentication required");
     tor_free(body);
     goto again;
@@ -2191,7 +2184,7 @@
     body = conn->incoming_cmd;
     conn->incoming_cmd = NULL;
   } else if (conn->incoming_cmd) {
-    log_fn(LOG_WARN, "Dropping incomplete fragmented command");
+    warn(LD_CONTROL, "Dropping incomplete fragmented command");
     tor_free(conn->incoming_cmd);
   }
 
@@ -2259,17 +2252,17 @@
     case CONTROL0_CMD_CONFVALUE:
     case CONTROL0_CMD_EVENT:
     case CONTROL0_CMD_INFOVALUE:
-      log_fn(LOG_WARN, "Received client-only '%s' command; ignoring.",
+      warn(LD_CONTROL, "Received client-only '%s' command; ignoring.",
              control_cmd_to_string(command_type));
       send_control0_error(conn, ERR_UNRECOGNIZED_TYPE,
                          "Command type only valid from server to tor client");
       break;
     case CONTROL0_CMD_FRAGMENTHEADER:
     case CONTROL0_CMD_FRAGMENT:
-      log_fn(LOG_WARN, "Recieved command fragment out of order; ignoring.");
+      warn(LD_CONTROL, "Recieved command fragment out of order; ignoring.");
       send_control0_error(conn, ERR_SYNTAX, "Bad fragmentation on command.");
     default:
-      log_fn(LOG_WARN, "Received unrecognized command type %d; ignoring.",
+      warn(LD_CONTROL, "Received unrecognized command type %d; ignoring.",
              (int)command_type);
       send_control0_error(conn, ERR_UNRECOGNIZED_TYPE,
                          "Unrecognized command type");
@@ -2325,7 +2318,7 @@
       case CIRC_EVENT_FAILED: status = "FAILED"; break;
       case CIRC_EVENT_CLOSED: status = "CLOSED"; break;
       default:
-        log_fn(LOG_WARN, "Unrecognized status code %d", (int)tp);
+        warn(LD_GENERAL, "Unrecognized status code %d", (int)tp);
         return 0;
       }
     send_control1_event(EVENT_CIRCUIT_STATUS,
@@ -2396,7 +2389,7 @@
       case STREAM_EVENT_NEW_RESOLVE: status = "NEWRESOLVE"; break;
       case STREAM_EVENT_FAILED_RETRIABLE: status = "DETACHED"; break;
       default:
-        log_fn(LOG_WARN, "Unrecognized status code %d", (int)tp);
+        warn(LD_GENERAL, "Unrecognized status code %d", (int)tp);
         return 0;
       }
     circ = circuit_get_by_edge_conn(conn);
@@ -2438,7 +2431,7 @@
       case OR_CONN_EVENT_FAILED: status = "FAILED"; break;
       case OR_CONN_EVENT_CLOSED: status = "CLOSED"; break;
       default:
-        log_fn(LOG_WARN, "Unrecognized status code %d", (int)tp);
+        warn(LD_GENERAL, "Unrecognized status code %d", (int)tp);
         return 0;
       }
     send_control1_event(EVENT_OR_CONN_STATUS,
@@ -2490,7 +2483,7 @@
 
 /** We got a log message: tell any interested control connections. */
 void
-control_event_logmsg(int severity, const char *msg)
+control_event_logmsg(int severity, int domain, const char *msg)
 {
   int oldlog, event;
 
@@ -2615,7 +2608,7 @@
   authentication_cookie_is_set = 1;
   if (write_bytes_to_file(fname, authentication_cookie,
                           AUTHENTICATION_COOKIE_LEN, 1)) {
-    log_fn(LOG_WARN,"Error writing authentication cookie.");
+    warn(LD_FS,"Error writing authentication cookie.");
     return -1;
   }
 

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.722
retrieving revision 1.723
diff -u -d -r1.722 -r1.723
--- or.h	18 Oct 2005 21:58:19 -0000	1.722
+++ or.h	18 Oct 2005 22:21:29 -0000	1.723
@@ -133,7 +133,9 @@
 
 #include "../common/crypto.h"
 #include "../common/tortls.h"
+#ifndef NEW_LOG_INTERFACE
 #define OLD_LOG_INTERFACE
+#endif
 #include "../common/log.h"
 #include "../common/compat.h"
 #include "../common/container.h"
@@ -1718,7 +1720,7 @@
 int control_event_stream_status(connection_t *conn, stream_status_event_t e);
 int control_event_or_conn_status(connection_t *conn, or_conn_status_event_t e);
 int control_event_bandwidth_used(uint32_t n_read, uint32_t n_written);
-void control_event_logmsg(int severity, const char *msg);
+void control_event_logmsg(int severity, int domain, const char *msg);
 int control_event_descriptors_changed(smartlist_t *routers);
 int control_event_address_mapped(const char *from, const char *to,time_t expires);
 



More information about the tor-commits mailing list