aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-02-01 15:43:37 -0500
committerNick Mathewson <nickm@torproject.org>2013-02-01 15:43:37 -0500
commita141430ec3f344d4f021f614942ff5b769b8c900 (patch)
tree9ede2df8d618be4a055b6beacdff7b44c6aa836d /src
parentabb5519d93d56c2859e147fef2fbf0f9e96d5b9c (diff)
downloadtor-a141430ec3f344d4f021f614942ff5b769b8c900.tar
tor-a141430ec3f344d4f021f614942ff5b769b8c900.tar.gz
Rename log() to tor_log() for logging
This is meant to avoid conflict with the built-in log() function in math.h. It resolves ticket 7599. First reported by dhill. This was generated with the following perl script: #!/usr/bin/perl -w -i -p s/\blog\(LOG_(ERR|WARN|NOTICE|INFO|DEBUG)\s*,\s*/log_\L$1\(/g; s/\blog\(/tor_log\(/g;
Diffstat (limited to 'src')
-rw-r--r--src/common/address.c4
-rw-r--r--src/common/compat_libevent.c18
-rw-r--r--src/common/crypto.c8
-rw-r--r--src/common/procmon.c2
-rw-r--r--src/common/torlog.h2
-rw-r--r--src/common/tortls.c20
-rw-r--r--src/common/util.c4
-rw-r--r--src/ext/eventdns.c112
-rw-r--r--src/or/buffers.c6
-rw-r--r--src/or/channel.c66
-rw-r--r--src/or/circuitlist.c6
-rw-r--r--src/or/config.c36
-rw-r--r--src/or/connection.c10
-rw-r--r--src/or/connection_or.c4
-rw-r--r--src/or/control.c2
-rw-r--r--src/or/directory.c2
-rw-r--r--src/or/dirserv.c2
-rw-r--r--src/or/dirvote.c2
-rw-r--r--src/or/dns.c16
-rw-r--r--src/or/main.c34
-rw-r--r--src/or/networkstatus.c8
-rw-r--r--src/or/nodelist.c4
-rw-r--r--src/or/policies.c4
-rw-r--r--src/or/relay.c2
-rw-r--r--src/or/rendservice.c6
-rw-r--r--src/or/rephist.c8
-rw-r--r--src/or/router.c36
-rw-r--r--src/or/routerlist.c2
-rw-r--r--src/or/routerparse.c2
-rw-r--r--src/or/routerset.c2
-rw-r--r--src/or/status.c2
-rw-r--r--src/tools/tor-gencert.c4
32 files changed, 218 insertions, 218 deletions
diff --git a/src/common/address.c b/src/common/address.c
index 3529b10c1..6fc9fb3c4 100644
--- a/src/common/address.c
+++ b/src/common/address.c
@@ -1270,14 +1270,14 @@ get_interface_addresses_raw(int severity)
/* This interface, AFAICT, only supports AF_INET addresses */
fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
- log(severity, LD_NET, "socket failed: %s", strerror(errno));
+ tor_log(severity, LD_NET, "socket failed: %s", strerror(errno));
goto done;
}
/* Guess how much space we need. */
ifc.ifc_len = sz = 15*1024;
ifc.ifc_ifcu.ifcu_req = tor_malloc(sz);
if (ioctl(fd, SIOCGIFCONF, &ifc) < 0) {
- log(severity, LD_NET, "ioctl failed: %s", strerror(errno));
+ tor_log(severity, LD_NET, "ioctl failed: %s", strerror(errno));
close(fd);
goto done;
}
diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c
index 8cbb0db8e..200a7c65f 100644
--- a/src/common/compat_libevent.c
+++ b/src/common/compat_libevent.c
@@ -76,19 +76,19 @@ libevent_logging_callback(int severity, const char *msg)
}
switch (severity) {
case _EVENT_LOG_DEBUG:
- log(LOG_DEBUG, LD_NOCB|LD_NET, "Message from libevent: %s", buf);
+ log_debug(LD_NOCB|LD_NET, "Message from libevent: %s", buf);
break;
case _EVENT_LOG_MSG:
- log(LOG_INFO, LD_NOCB|LD_NET, "Message from libevent: %s", buf);
+ log_info(LD_NOCB|LD_NET, "Message from libevent: %s", buf);
break;
case _EVENT_LOG_WARN:
- log(LOG_WARN, LD_NOCB|LD_GENERAL, "Warning from libevent: %s", buf);
+ log_warn(LD_NOCB|LD_GENERAL, "Warning from libevent: %s", buf);
break;
case _EVENT_LOG_ERR:
- log(LOG_ERR, LD_NOCB|LD_GENERAL, "Error from libevent: %s", buf);
+ log_err(LD_NOCB|LD_GENERAL, "Error from libevent: %s", buf);
break;
default:
- log(LOG_WARN, LD_NOCB|LD_GENERAL, "Message [%d] from libevent: %s",
+ log_warn(LD_NOCB|LD_GENERAL, "Message [%d] from libevent: %s",
severity, buf);
break;
}
@@ -261,13 +261,13 @@ tor_libevent_initialize(tor_libevent_cfg *torcfg)
#if defined(HAVE_EVENT_GET_VERSION) && defined(HAVE_EVENT_GET_METHOD)
/* Making this a NOTICE for now so we can link bugs to a libevent versions
* or methods better. */
- log(LOG_INFO, LD_GENERAL,
+ log_info(LD_GENERAL,
"Initialized libevent version %s using method %s. Good.",
event_get_version(), tor_libevent_get_method());
#else
- log(LOG_NOTICE, LD_GENERAL,
+ log_notice(LD_GENERAL,
"Initialized old libevent (version 1.0b or earlier).");
- log(LOG_WARN, LD_GENERAL,
+ log_warn(LD_GENERAL,
"You have a *VERY* old version of libevent. It is likely to be buggy; "
"please build Tor with a more recent version.");
#endif
@@ -440,7 +440,7 @@ tor_check_libevent_header_compatibility(void)
verybad = compat1 != compat2;
- log(verybad ? LOG_WARN : LOG_NOTICE,
+ tor_log(verybad ? LOG_WARN : LOG_NOTICE,
LD_GENERAL, "We were compiled with headers from version %s "
"of Libevent, but we're using a Libevent library that says it's "
"version %s.", HEADER_VERSION, event_get_version());
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 7c73f79cf..7cfe2a837 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -151,10 +151,10 @@ crypto_log_errors(int severity, const char *doing)
if (!lib) lib = "(null)";
if (!func) func = "(null)";
if (doing) {
- log(severity, LD_CRYPTO, "crypto error while %s: %s (in %s:%s)",
+ tor_log(severity, LD_CRYPTO, "crypto error while %s: %s (in %s:%s)",
doing, msg, lib, func);
} else {
- log(severity, LD_CRYPTO, "crypto error: %s (in %s:%s)", msg, lib, func);
+ tor_log(severity, LD_CRYPTO, "crypto error: %s (in %s:%s)", msg, lib, func);
}
}
}
@@ -168,10 +168,10 @@ log_engine(const char *fn, ENGINE *e)
const char *name, *id;
name = ENGINE_get_name(e);
id = ENGINE_get_id(e);
- log(LOG_NOTICE, LD_CRYPTO, "Using OpenSSL engine %s [%s] for %s",
+ log_notice(LD_CRYPTO, "Using OpenSSL engine %s [%s] for %s",
name?name:"?", id?id:"?", fn);
} else {
- log(LOG_INFO, LD_CRYPTO, "Using default implementation for %s", fn);
+ log_info(LD_CRYPTO, "Using default implementation for %s", fn);
}
}
#endif
diff --git a/src/common/procmon.c b/src/common/procmon.c
index efb39e5bb..0a49689e3 100644
--- a/src/common/procmon.c
+++ b/src/common/procmon.c
@@ -321,7 +321,7 @@ tor_process_monitor_poll_cb(evutil_socket_t unused1, short unused2,
its_dead_jim = its_dead_jim && (errno == ESRCH);
#endif
- log(its_dead_jim ? LOG_NOTICE : LOG_INFO,
+ tor_log(its_dead_jim ? LOG_NOTICE : LOG_INFO,
procmon->log_domain, "Monitored process "PID_T_FORMAT" is %s.",
procmon->pid,
its_dead_jim ? "dead" : "still alive");
diff --git a/src/common/torlog.h b/src/common/torlog.h
index 97271fa81..b487e0e69 100644
--- a/src/common/torlog.h
+++ b/src/common/torlog.h
@@ -153,7 +153,7 @@ void set_log_time_granularity(int granularity_msec);
void tor_log(int severity, log_domain_mask_t domain, const char *format, ...)
CHECK_PRINTF(3,4);
-#define log tor_log /* hack it so we don't conflict with log() as much */
+#define log tor_log /* hack it so we don't conflict with tor_log() as much */
#if defined(__GNUC__) || defined(RUNNING_DOXYGEN)
extern int log_global_min_severity_;
diff --git a/src/common/tortls.c b/src/common/tortls.c
index 6151d3fde..94cedba24 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -334,11 +334,11 @@ tor_tls_log_one_error(tor_tls_t *tls, unsigned long err,
if (!lib) lib = "(null)";
if (!func) func = "(null)";
if (doing) {
- log(severity, domain, "TLS error while %s%s%s: %s (in %s:%s:%s)",
+ tor_log(severity, domain, "TLS error while %s%s%s: %s (in %s:%s:%s)",
doing, addr?" with ":"", addr?addr:"",
msg, lib, func, state);
} else {
- log(severity, domain, "TLS error%s%s: %s (in %s:%s:%s)",
+ tor_log(severity, domain, "TLS error%s%s: %s (in %s:%s:%s)",
addr?" with ":"", addr?addr:"",
msg, lib, func, state);
}
@@ -427,12 +427,12 @@ tor_tls_get_error(tor_tls_t *tls, int r, int extra,
if (extra&CATCH_SYSCALL)
return TOR_TLS_SYSCALL_;
if (r == 0) {
- log(severity, LD_NET, "TLS error: unexpected close while %s (%s)",
+ tor_log(severity, LD_NET, "TLS error: unexpected close while %s (%s)",
doing, SSL_state_string_long(tls->ssl));
tor_error = TOR_TLS_ERROR_IO;
} else {
int e = tor_socket_errno(tls->socket);
- log(severity, LD_NET,
+ tor_log(severity, LD_NET,
"TLS error: <syscall error while %s> (errno=%d: %s; state=%s)",
doing, e, tor_socket_strerror(e),
SSL_state_string_long(tls->ssl));
@@ -443,7 +443,7 @@ tor_tls_get_error(tor_tls_t *tls, int r, int extra,
case SSL_ERROR_ZERO_RETURN:
if (extra&CATCH_ZERO)
return TOR_TLS_ZERORETURN_;
- log(severity, LD_NET, "TLS connection closed while %s in state %s",
+ tor_log(severity, LD_NET, "TLS connection closed while %s in state %s",
doing, SSL_state_string_long(tls->ssl));
tls_log_errors(tls, severity, domain, doing);
return TOR_TLS_CLOSE;
@@ -1224,7 +1224,7 @@ tor_tls_context_new(crypto_pk_t *identity, unsigned int key_lifetime,
authcert = tor_tls_create_certificate(rsa_auth, identity, nickname, nn2,
key_lifetime);
if (!cert || !idcert || !authcert) {
- log(LOG_WARN, LD_CRYPTO, "Error creating certificate");
+ log_warn(LD_CRYPTO, "Error creating certificate");
goto error;
}
}
@@ -2272,7 +2272,7 @@ tor_tls_shutdown(tor_tls_t *tls)
*/
if (tls->state == TOR_TLS_ST_GOTCLOSE ||
tls->state == TOR_TLS_ST_SENTCLOSE) {
- log(LOG_WARN, LD_NET,
+ log_warn(LD_NET,
"TLS returned \"half-closed\" value while already half-closed");
return TOR_TLS_ERROR_MISC;
}
@@ -2322,7 +2322,7 @@ log_cert_lifetime(int severity, const X509 *cert, const char *problem)
struct tm tm;
if (problem)
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
"Certificate %s. Either their clock is set wrong, or your clock "
"is wrong.",
problem);
@@ -2347,7 +2347,7 @@ log_cert_lifetime(int severity, const X509 *cert, const char *problem)
strftime(mytime, 32, "%b %d %H:%M:%S %Y UTC", tor_gmtime_r(&now, &tm));
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
"(certificate lifetime runs from %s through %s. Your time is %s.)",
s1,s2,mytime);
@@ -2568,7 +2568,7 @@ check_no_tls_errors_(const char *fname, int line)
{
if (ERR_peek_error() == 0)
return;
- log(LOG_WARN, LD_CRYPTO, "Unhandled OpenSSL errors found at %s:%d: ",
+ log_warn(LD_CRYPTO, "Unhandled OpenSSL errors found at %s:%d: ",
tor_fix_source_file(fname), line);
tls_log_errors(NULL, LOG_WARN, LD_NET, NULL);
}
diff --git a/src/common/util.c b/src/common/util.c
index 49ec75dc4..414efce5f 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -324,12 +324,12 @@ tor_log_mallinfo(int severity)
/**
* Returns the natural logarithm of d base 2. We define this wrapper here so
- * as to make it easier not to conflict with Tor's log() macro.
+ * as to make it easier not to conflict with Tor's tor_log() macro.
*/
double
tor_mathlog(double d)
{
- return log(d);
+ return tor_log(d);
}
/** Return the long integer closest to <b>d</b>. We define this wrapper
diff --git a/src/ext/eventdns.c b/src/ext/eventdns.c
index b1f586b2f..5316338dc 100644
--- a/src/ext/eventdns.c
+++ b/src/ext/eventdns.c
@@ -534,7 +534,7 @@ nameserver_probe_failed(struct nameserver *const ns) {
ns->failed_times++;
if (add_timeout_event(ns, (struct timeval *) timeout) < 0) {
- log(EVDNS_LOG_WARN,
+ tor_log(EVDNS_LOG_WARN,
"Error from libevent when adding timer event for %s",
debug_ntop((struct sockaddr *)&ns->address));
/* ???? Do more? */
@@ -550,19 +550,19 @@ nameserver_failed(struct nameserver *const ns, const char *msg) {
/* then don't do anything */
if (!ns->state) return;
- log(EVDNS_LOG_WARN, "Nameserver %s has failed: %s",
+ tor_log(EVDNS_LOG_WARN, "Nameserver %s has failed: %s",
debug_ntop((struct sockaddr *)&ns->address), msg);
global_good_nameservers--;
assert(global_good_nameservers >= 0);
if (global_good_nameservers == 0) {
- log(EVDNS_LOG_WARN, "All nameservers have failed");
+ tor_log(EVDNS_LOG_WARN, "All nameservers have failed");
}
ns->state = 0;
ns->failed_times = 1;
if (add_timeout_event(ns, (struct timeval *) &global_nameserver_timeouts[0]) < 0) {
- log(EVDNS_LOG_WARN,
+ tor_log(EVDNS_LOG_WARN,
"Error from libevent when adding timer event for %s",
debug_ntop((struct sockaddr *)&ns->address));
/* ???? Do more? */
@@ -593,7 +593,7 @@ nameserver_failed(struct nameserver *const ns, const char *msg) {
static void
nameserver_up(struct nameserver *const ns) {
if (ns->state) return;
- log(EVDNS_LOG_WARN, "Nameserver %s is back up",
+ tor_log(EVDNS_LOG_WARN, "Nameserver %s is back up",
debug_ntop((struct sockaddr *)&ns->address));
del_timeout_event(ns);
ns->state = 1;
@@ -624,7 +624,7 @@ request_finished(struct evdns_request *const req, struct evdns_request **head) {
}
}
- log(EVDNS_LOG_DEBUG, "Removing timeout for request %lx",
+ tor_log(EVDNS_LOG_DEBUG, "Removing timeout for request %lx",
(unsigned long) req);
del_timeout_event(req);
@@ -776,7 +776,7 @@ reply_handle(struct evdns_request *const req, u16 flags, u32 ttl, struct reply *
* confusing." Treat this as a timeout, not a failure.
*/
/*XXXX refactor the parts of */
- log(EVDNS_LOG_DEBUG, "Got a SERVERFAILED from nameserver %s; "
+ tor_log(EVDNS_LOG_DEBUG, "Got a SERVERFAILED from nameserver %s; "
"will allow the request to time out.",
debug_ntop((struct sockaddr *)&req->ns->address));
break;
@@ -1268,7 +1268,7 @@ nameserver_read(struct nameserver *ns) {
}
/* XXX Match port too? */
if (!sockaddr_eq(sa, (struct sockaddr*)&ns->address, 0)) {
- log(EVDNS_LOG_WARN,
+ tor_log(EVDNS_LOG_WARN,
"Address mismatch on received DNS packet. Address was %s",
debug_ntop(sa));
return;
@@ -1294,7 +1294,7 @@ server_port_read(struct evdns_server_port *s) {
if (r < 0) {
int err = last_error(s->socket);
if (error_is_eagain(err)) return;
- log(EVDNS_LOG_WARN, "Error %s (%d) while reading request.",
+ tor_log(EVDNS_LOG_WARN, "Error %s (%d) while reading request.",
tor_socket_strerror(err), err);
return;
}
@@ -1314,7 +1314,7 @@ server_port_flush(struct evdns_server_port *port)
int err = last_error(port->socket);
if (error_is_eagain(err))
return;
- log(EVDNS_LOG_WARN, "Error %s (%d) while writing response to port; dropping", tor_socket_strerror(err), err);
+ tor_log(EVDNS_LOG_WARN, "Error %s (%d) while writing response to port; dropping", tor_socket_strerror(err), err);
}
if (server_request_free(req)) {
/* we released the last reference to req->port. */
@@ -1331,7 +1331,7 @@ server_port_flush(struct evdns_server_port *port)
event_set(&port->event, port->socket, EV_READ | EV_PERSIST,
server_port_ready_callback, port);
if (event_add(&port->event, NULL) < 0) {
- log(EVDNS_LOG_WARN, "Error from libevent when adding event for DNS server.");
+ tor_log(EVDNS_LOG_WARN, "Error from libevent when adding event for DNS server.");
/* ???? Do more? */
}
}
@@ -1349,7 +1349,7 @@ nameserver_write_waiting(struct nameserver *ns, char waiting) {
event_set(&ns->event, ns->socket, EV_READ | (waiting ? EV_WRITE : 0) | EV_PERSIST,
nameserver_ready_callback, ns);
if (event_add(&ns->event, NULL) < 0) {
- log(EVDNS_LOG_WARN, "Error from libevent when adding event for %s",
+ tor_log(EVDNS_LOG_WARN, "Error from libevent when adding event for %s",
debug_ntop((struct sockaddr *)&ns->address));
/* ???? Do more? */
}
@@ -1859,7 +1859,7 @@ evdns_server_request_respond(struct evdns_server_request *_req, int err)
event_set(&port->event, port->socket, (port->closing?0:EV_READ) | EV_WRITE | EV_PERSIST, server_port_ready_callback, port);
if (event_add(&port->event, NULL) < 0) {
- log(EVDNS_LOG_WARN, "Error from libevent when adding event for DNS server");
+ tor_log(EVDNS_LOG_WARN, "Error from libevent when adding event for DNS server");
}
}
@@ -1995,7 +1995,7 @@ evdns_request_timeout_callback(int fd, short events, void *arg) {
(void) fd;
(void) events;
- log(EVDNS_LOG_DEBUG, "Request %lx timed out", (unsigned long) arg);
+ tor_log(EVDNS_LOG_DEBUG, "Request %lx timed out", (unsigned long) arg);
req->ns->timedout++;
if (req->ns->timedout > global_max_nameserver_timeout) {
@@ -2074,11 +2074,11 @@ evdns_request_transmit(struct evdns_request *req) {
* and make us retransmit the request anyway. */
default:
/* transmitted; we need to check for timeout. */
- log(EVDNS_LOG_DEBUG,
+ tor_log(EVDNS_LOG_DEBUG,
"Setting timeout for request %lx", (unsigned long) req);
if (add_timeout_event(req, &global_timeout) < 0) {
- log(EVDNS_LOG_WARN,
+ tor_log(EVDNS_LOG_WARN,
"Error from libevent when adding timer for request %lx",
(unsigned long) req);
/* ???? Do more? */
@@ -2126,7 +2126,7 @@ nameserver_send_probe(struct nameserver *const ns) {
addr = mm_malloc(sizeof(struct sockaddr_storage));
memcpy(addr, &ns->address, sizeof(struct sockaddr_storage));
- log(EVDNS_LOG_DEBUG, "Sending probe to %s", debug_ntop((struct sockaddr *)&ns->address));
+ tor_log(EVDNS_LOG_DEBUG, "Sending probe to %s", debug_ntop((struct sockaddr *)&ns->address));
req = request_new(TYPE_A, "www.google.com", DNS_QUERY_NO_SEARCH, nameserver_probe_callback, addr);
if (!req) {
@@ -2282,14 +2282,14 @@ _evdns_nameserver_add_impl(const struct sockaddr *address,
if (server) {
do {
if (sockaddr_eq(address, (struct sockaddr *)&server->address, 1)) {
- log(EVDNS_LOG_DEBUG, "Duplicate nameserver.");
+ tor_log(EVDNS_LOG_DEBUG, "Duplicate nameserver.");
return 3;
}
server = server->next;
} while (server != started_at);
}
if (addrlen > (int)sizeof(ns->address)) {
- log(EVDNS_LOG_DEBUG, "Addrlen %d too long.", (int)addrlen);
+ tor_log(EVDNS_LOG_DEBUG, "Addrlen %d too long.", (int)addrlen);
return 2;
}
@@ -2315,14 +2315,14 @@ _evdns_nameserver_add_impl(const struct sockaddr *address,
!sockaddr_is_loopback((struct sockaddr*)&global_bind_address)) {
if (bind(ns->socket, (struct sockaddr *)&global_bind_address,
global_bind_addrlen) < 0) {
- log(EVDNS_LOG_DEBUG, "Couldn't bind to outgoing address.");
+ tor_log(EVDNS_LOG_DEBUG, "Couldn't bind to outgoing address.");
err = 2;
goto out2;
}
}
if (connect(ns->socket, address, addrlen) != 0) {
- log(EVDNS_LOG_DEBUG, "Couldn't open socket to nameserver.");
+ tor_log(EVDNS_LOG_DEBUG, "Couldn't open socket to nameserver.");
err = 2;
goto out2;
}
@@ -2331,12 +2331,12 @@ _evdns_nameserver_add_impl(const struct sockaddr *address,
ns->state = 1;
event_set(&ns->event, ns->socket, EV_READ | EV_PERSIST, nameserver_ready_callback, ns);
if (event_add(&ns->event, NULL) < 0) {
- log(EVDNS_LOG_DEBUG, "Couldn't add event for nameserver.");
+ tor_log(EVDNS_LOG_DEBUG, "Couldn't add event for nameserver.");
err = 2;
goto out2;
}
- log(EVDNS_LOG_DEBUG, "Added nameserver %s", debug_ntop(address));
+ tor_log(EVDNS_LOG_DEBUG, "Added nameserver %s", debug_ntop(address));
/* insert this nameserver into the list of them */
if (!server_head) {
@@ -2360,7 +2360,7 @@ out2:
out1:
CLEAR(ns);
mm_free(ns);
- log(EVDNS_LOG_WARN, "Unable to add nameserver %s: error %d", debug_ntop(address), err);
+ tor_log(EVDNS_LOG_WARN, "Unable to add nameserver %s: error %d", debug_ntop(address), err);
return err;
}
@@ -2393,18 +2393,18 @@ evdns_nameserver_ip_add(const char *ip_as_string) {
* ipv4
*/
- log(EVDNS_LOG_DEBUG, "Trying to add nameserver <%s>", ip_as_string);
+ tor_log(EVDNS_LOG_DEBUG, "Trying to add nameserver <%s>", ip_as_string);
cp = strchr(ip_as_string, ':');
if (*ip_as_string == '[') {
size_t len;
if (!(cp = strchr(ip_as_string, ']'))) {
- log(EVDNS_LOG_DEBUG, "Nameserver missing closing ]");
+ tor_log(EVDNS_LOG_DEBUG, "Nameserver missing closing ]");
return 4;
}
len = cp-(ip_as_string + 1);
if (len > sizeof(buf)-1) {
- log(EVDNS_LOG_DEBUG, "[Nameserver] does not fit in buffer.");
+ tor_log(EVDNS_LOG_DEBUG, "[Nameserver] does not fit in buffer.");
return 4;
}
memcpy(buf, ip_as_string+1, len);
@@ -2422,7 +2422,7 @@ evdns_nameserver_ip_add(const char *ip_as_string) {
} else if (cp) {
is_ipv6 = 0;
if (cp - ip_as_string > (int)sizeof(buf)-1) {
- log(EVDNS_LOG_DEBUG, "Nameserver does not fit in buffer.");
+ tor_log(EVDNS_LOG_DEBUG, "Nameserver does not fit in buffer.");
return 4;
}
memcpy(buf, ip_as_string, cp-ip_as_string);
@@ -2440,7 +2440,7 @@ evdns_nameserver_ip_add(const char *ip_as_string) {
} else {
port = strtoint(port_part);
if (port <= 0 || port > 65535) {
- log(EVDNS_LOG_DEBUG, "Nameserver port <%s> out of range",
+ tor_log(EVDNS_LOG_DEBUG, "Nameserver port <%s> out of range",
port_part);
return 4;
}
@@ -2457,7 +2457,7 @@ evdns_nameserver_ip_add(const char *ip_as_string) {
sin6.sin6_family = AF_INET6;
sin6.sin6_port = htons(port);
if (1 != tor_inet_pton(AF_INET6, addr_part, &sin6.sin6_addr)) {
- log(EVDNS_LOG_DEBUG, "inet_pton(%s) failed", addr_part);
+ tor_log(EVDNS_LOG_DEBUG, "inet_pton(%s) failed", addr_part);
return 4;
}
return _evdns_nameserver_add_impl((struct sockaddr*)&sin6,
@@ -2471,7 +2471,7 @@ evdns_nameserver_ip_add(const char *ip_as_string) {
sin.sin_family = AF_INET;
sin.sin_port = htons(port);
if (!inet_aton(addr_part, &sin.sin_addr)) {
- log(EVDNS_LOG_DEBUG, "inet_pton(%s) failed", addr_part);
+ tor_log(EVDNS_LOG_DEBUG, "inet_pton(%s) failed", addr_part);
return 4;
}
return _evdns_nameserver_add_impl((struct sockaddr*)&sin,
@@ -2594,7 +2594,7 @@ request_submit(struct evdns_request *const req) {
/* exported function */
int evdns_resolve_ipv4(const char *name, int flags,
evdns_callback_type callback, void *ptr) {
- log(EVDNS_LOG_DEBUG, "Resolve requested for %s", name);
+ tor_log(EVDNS_LOG_DEBUG, "Resolve requested for %s", name);
if (flags & DNS_QUERY_NO_SEARCH) {
struct evdns_request *const req =
request_new(TYPE_A, name, flags, callback, ptr);
@@ -2610,7 +2610,7 @@ int evdns_resolve_ipv4(const char *name, int flags,
/* exported function */
int evdns_resolve_ipv6(const char *name, int flags,
evdns_callback_type callback, void *ptr) {
- log(EVDNS_LOG_DEBUG, "Resolve requested for %s", name);
+ tor_log(EVDNS_LOG_DEBUG, "Resolve requested for %s", name);
if (flags & DNS_QUERY_NO_SEARCH) {
struct evdns_request *const req =
request_new(TYPE_AAAA, name, flags, callback, ptr);
@@ -2634,7 +2634,7 @@ int evdns_resolve_reverse(const struct in_addr *in, int flags, evdns_callback_ty
(int)(u8)((a>>8 )&0xff),
(int)(u8)((a>>16)&0xff),
(int)(u8)((a>>24)&0xff));
- log(EVDNS_LOG_DEBUG, "Resolve requested for %s (reverse)", buf);
+ tor_log(EVDNS_LOG_DEBUG, "Resolve requested for %s (reverse)", buf);
req = request_new(TYPE_PTR, buf, flags, callback, ptr);
if (!req) return 1;
request_submit(req);
@@ -2658,7 +2658,7 @@ int evdns_resolve_reverse_ipv6(const struct in6_addr *in, int flags, evdns_callb
}
assert(cp + strlen("ip6.arpa") < buf+sizeof(buf));
memcpy(cp, "ip6.arpa", strlen("ip6.arpa")+1);
- log(EVDNS_LOG_DEBUG, "Resolve requested for %s (reverse)", buf);
+ tor_log(EVDNS_LOG_DEBUG, "Resolve requested for %s (reverse)", buf);
req = request_new(TYPE_PTR, buf, flags, callback, ptr);
if (!req) return 1;
request_submit(req);
@@ -2874,7 +2874,7 @@ search_try_next(struct evdns_request *const req) {
if (string_num_dots(req->search_origname) < req->search_state->ndots) {
/* yep, we need to try it raw */
struct evdns_request *const newreq = request_new(req->request_type, req->search_origname, req->search_flags, req->user_callback, req->user_pointer);
- log(EVDNS_LOG_DEBUG, "Search: trying raw query %s", req->search_origname);
+ tor_log(EVDNS_LOG_DEBUG, "Search: trying raw query %s", req->search_origname);
if (newreq) {
request_submit(newreq);
return 0;
@@ -2885,7 +2885,7 @@ search_try_next(struct evdns_request *const req) {
new_name = search_make_new(req->search_state, req->search_index, req->search_origname);
if (!new_name) return 1;
- log(EVDNS_LOG_DEBUG, "Search: now trying %s (%d)", new_name, req->search_index);
+ tor_log(EVDNS_LOG_DEBUG, "Search: now trying %s (%d)", new_name, req->search_index);
newreq = request_new(req->request_type, new_name, req->search_flags, req->user_callback, req->user_pointer);
mm_free(new_name);
if (!newreq) return 1;
@@ -2955,7 +2955,7 @@ evdns_set_option(const char *option, const char *val, int flags)
const int ndots = strtoint(val);
if (ndots == -1) return -1;
if (!(flags & DNS_OPTION_SEARCH)) return 0;
- log(EVDNS_LOG_DEBUG, "Setting ndots to %d", ndots);
+ tor_log(EVDNS_LOG_DEBUG, "Setting ndots to %d", ndots);
if (!global_search_state) global_search_state = search_state_new();
if (!global_search_state) return -1;
global_search_state->ndots = ndots;
@@ -2963,20 +2963,20 @@ evdns_set_option(const char *option, const char *val, int flags)
const int timeout = strtoint(val);
if (timeout == -1) return -1;
if (!(flags & DNS_OPTION_MISC)) return 0;
- log(EVDNS_LOG_DEBUG, "Setting timeout to %d", timeout);
+ tor_log(EVDNS_LOG_DEBUG, "Setting timeout to %d", timeout);
global_timeout.tv_sec = timeout;
} else if (!strncmp(option, "max-timeouts:", 12)) {
const int maxtimeout = strtoint_clipped(val, 1, 255);
if (maxtimeout == -1) return -1;
if (!(flags & DNS_OPTION_MISC)) return 0;
- log(EVDNS_LOG_DEBUG, "Setting maximum allowed timeouts to %d",
+ tor_log(EVDNS_LOG_DEBUG, "Setting maximum allowed timeouts to %d",
maxtimeout);
global_max_nameserver_timeout = maxtimeout;
} else if (!strncmp(option, "max-inflight:", 13)) {
const int maxinflight = strtoint_clipped(val, 1, 65000);
if (maxinflight == -1) return -1;
if (!(flags & DNS_OPTION_MISC)) return 0;
- log(EVDNS_LOG_DEBUG, "Setting maximum inflight requests to %d",
+ tor_log(EVDNS_LOG_DEBUG, "Setting maximum inflight requests to %d",
maxinflight);
global_max_requests_inflight = maxinflight;
} else if (!strncmp(option, "attempts:", 9)) {
@@ -2984,12 +2984,12 @@ evdns_set_option(const char *option, const char *val, int flags)
if (retries == -1) return -1;
if (retries > 255) retries = 255;
if (!(flags & DNS_OPTION_MISC)) return 0;
- log(EVDNS_LOG_DEBUG, "Setting retries to %d", retries);
+ tor_log(EVDNS_LOG_DEBUG, "Setting retries to %d", retries);
global_max_retransmits = retries;
} else if (!strncmp(option, "randomize-case:", 15)) {
int randcase = strtoint(val);
if (!(flags & DNS_OPTION_MISC)) return 0;
- log(EVDNS_LOG_DEBUG, "Setting randomize_case to %d", randcase);
+ tor_log(EVDNS_LOG_DEBUG, "Setting randomize_case to %d", randcase);
global_randomize_case = randcase;
}
return 0;
@@ -3047,7 +3047,7 @@ evdns_resolv_conf_parse(int flags, const char *const filename) {
char *start;
int err = 0;
- log(EVDNS_LOG_DEBUG, "Parsing resolv.conf file %s", filename);
+ tor_log(EVDNS_LOG_DEBUG, "Parsing resolv.conf file %s", filename);
fd = tor_open_cloexec(filename, O_RDONLY, 0);
if (fd < 0) {
@@ -3146,13 +3146,13 @@ load_nameservers_with_getnetworkparams(void)
GetNetworkParams_fn_t fn;
if (!(handle = load_windows_system_library(TEXT("iphlpapi.dll")))) {
- log(EVDNS_LOG_WARN, "Could not open iphlpapi.dll");
+ tor_log(EVDNS_LOG_WARN, "Could not open iphlpapi.dll");
/* right now status = 0, doesn't that mean "good" - mikec */
status = -1;
goto done;
}
if (!(fn = (GetNetworkParams_fn_t) GetProcAddress(handle, TEXT("GetNetworkParams")))) {
- log(EVDNS_LOG_WARN, "Could not get address of function.");
+ tor_log(EVDNS_LOG_WARN, "Could not get address of function.");
/* same as above */
status = -1;
goto done;
@@ -3173,7 +3173,7 @@ load_nameservers_with_getnetworkparams(void)
fixed = buf;
r = fn(fixed, &size);
if (r != ERROR_SUCCESS) {
- log(EVDNS_LOG_DEBUG, "fn() failed.");
+ tor_log(EVDNS_LOG_DEBUG, "fn() failed.");
status = -1;
goto done;
}
@@ -3185,12 +3185,12 @@ load_nameservers_with_getnetworkparams(void)
while (ns) {
r = evdns_nameserver_ip_add_line(ns->IpAddress.String);
if (r) {
- log(EVDNS_LOG_DEBUG,"Could not add nameserver %s to list, "
+ tor_log(EVDNS_LOG_DEBUG,"Could not add nameserver %s to list, "
"error: %d; status: %d",
(ns->IpAddress.String),(int)GetLastError(), r);
status = r;
} else {
- log(EVDNS_LOG_DEBUG,"Successfully added %s as nameserver",ns->IpAddress.String);
+ tor_log(EVDNS_LOG_DEBUG,"Successfully added %s as nameserver",ns->IpAddress.String);
added_any++;
}
@@ -3198,7 +3198,7 @@ load_nameservers_with_getnetworkparams(void)
}
if (!added_any) {
- log(EVDNS_LOG_DEBUG, "No nameservers added.");
+ tor_log(EVDNS_LOG_DEBUG, "No nameservers added.");
if (status == 0)
status = -1;
} else {
@@ -3254,10 +3254,10 @@ load_nameservers_from_registry(void)
#define TRY(k, name) \
if (!found && config_nameserver_from_reg_key(k,TEXT(name)) == 0) { \
- log(EVDNS_LOG_DEBUG,"Found nameservers in %s/%s",#k,name); \
+ tor_log(EVDNS_LOG_DEBUG,"Found nameservers in %s/%s",#k,name); \
found = 1; \
} else if (!found) { \
- log(EVDNS_LOG_DEBUG,"Didn't find nameservers in %s/%s", \
+ tor_log(EVDNS_LOG_DEBUG,"Didn't find nameservers in %s/%s", \
#k,#name); \
}
@@ -3266,14 +3266,14 @@ load_nameservers_from_registry(void)
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0,
KEY_READ, &nt_key) != ERROR_SUCCESS) {
- log(EVDNS_LOG_DEBUG,"Couldn't open nt key, %d",(int)GetLastError());
+ tor_log(EVDNS_LOG_DEBUG,"Couldn't open nt key, %d",(int)GetLastError());
return -1;
}
r = RegOpenKeyEx(nt_key, TEXT("Interfaces"), 0,
KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS,
&interfaces_key);
if (r != ERROR_SUCCESS) {
- log(EVDNS_LOG_DEBUG,"Couldn't open interfaces key, %d",(int)GetLastError());
+ tor_log(EVDNS_LOG_DEBUG,"Couldn't open interfaces key, %d",(int)GetLastError());
return -1;
}
TRY(nt_key, "NameServer");
@@ -3286,7 +3286,7 @@ load_nameservers_from_registry(void)
HKEY win_key = 0;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_9X_KEY, 0,
KEY_READ, &win_key) != ERROR_SUCCESS) {
- log(EVDNS_LOG_DEBUG, "Couldn't open registry key, %d", (int)GetLastError());
+ tor_log(EVDNS_LOG_DEBUG, "Couldn't open registry key, %d", (int)GetLastError());
return -1;
}
TRY(win_key, "NameServer");
@@ -3294,7 +3294,7 @@ load_nameservers_from_registry(void)
}
if (found == 0) {
- log(EVDNS_LOG_WARN,"Didn't find any nameservers.");
+ tor_log(EVDNS_LOG_WARN,"Didn't find any nameservers.");
}
return found ? 0 : -1;
diff --git a/src/or/buffers.c b/src/or/buffers.c
index 7868a4548..e5fac9172 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -335,11 +335,11 @@ buf_dump_freelist_sizes(int severity)
{
#ifdef ENABLE_BUF_FREELISTS
int i;
- log(severity, LD_MM, "====== Buffer freelists:");
+ tor_log(severity, LD_MM, "====== Buffer freelists:");
for (i = 0; freelists[i].alloc_size; ++i) {
uint64_t total = ((uint64_t)freelists[i].cur_length) *
freelists[i].alloc_size;
- log(severity, LD_MM,
+ tor_log(severity, LD_MM,
U64_FORMAT" bytes in %d %d-byte chunks ["U64_FORMAT
" misses; "U64_FORMAT" frees; "U64_FORMAT" hits]",
U64_PRINTF_ARG(total),
@@ -348,7 +348,7 @@ buf_dump_freelist_sizes(int severity)
U64_PRINTF_ARG(freelists[i].n_free),
U64_PRINTF_ARG(freelists[i].n_hit));
}
- log(severity, LD_MM, U64_FORMAT" allocations in non-freelist sizes",
+ tor_log(severity, LD_MM, U64_FORMAT" allocations in non-freelist sizes",
U64_PRINTF_ARG(n_freelist_miss));
#else
(void)severity;
diff --git a/src/or/channel.c b/src/or/channel.c
index b30e5483c..104b018cf 100644
--- a/src/or/channel.c
+++ b/src/or/channel.c
@@ -2636,10 +2636,10 @@ void
channel_dumpstats(int severity)
{
if (all_channels && smartlist_len(all_channels) > 0) {
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
"Dumping statistics about %d channels:",
smartlist_len(all_channels));
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
"%d are active, and %d are done and waiting for cleanup",
(active_channels != NULL) ?
smartlist_len(active_channels) : 0,
@@ -2649,10 +2649,10 @@ channel_dumpstats(int severity)
SMARTLIST_FOREACH(all_channels, channel_t *, chan,
channel_dump_statistics(chan, severity));
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
"Done spamming about channels now");
} else {
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
"No channels to dump");
}
}
@@ -2668,10 +2668,10 @@ void
channel_listener_dumpstats(int severity)
{
if (all_listeners && smartlist_len(all_listeners) > 0) {
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
"Dumping statistics about %d channel listeners:",
smartlist_len(all_listeners));
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
"%d are active and %d are done and waiting for cleanup",
(active_listeners != NULL) ?
smartlist_len(active_listeners) : 0,
@@ -2681,10 +2681,10 @@ channel_listener_dumpstats(int severity)
SMARTLIST_FOREACH(all_listeners, channel_listener_t *, chan_l,
channel_listener_dump_statistics(chan_l, severity));
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
"Done spamming about channel listeners now");
} else {
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
"No channel listeners to dump");
}
}
@@ -3139,13 +3139,13 @@ channel_dump_statistics(channel_t *chan, int severity)
age = (double)(now - chan->timestamp_created);
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
"Channel " U64_FORMAT " (at %p) with transport %s is in state "
"%s (%d)",
U64_PRINTF_ARG(chan->global_identifier), chan,
channel_describe_transport(chan),
channel_state_to_string(chan->state), chan->state);
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel " U64_FORMAT " was created at " U64_FORMAT
" (" U64_FORMAT " seconds ago) "
"and last active at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
@@ -3158,14 +3158,14 @@ channel_dump_statistics(channel_t *chan, int severity)
/* Handle digest and nickname */
if (!tor_digest_is_zero(chan->identity_digest)) {
if (chan->nickname) {
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel " U64_FORMAT " says it is connected "
"to an OR with digest %s and nickname %s",
U64_PRINTF_ARG(chan->global_identifier),
hex_str(chan->identity_digest, DIGEST_LEN),
chan->nickname);
} else {
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel " U64_FORMAT " says it is connected "
"to an OR with digest %s and no known nickname",
U64_PRINTF_ARG(chan->global_identifier),
@@ -3173,13 +3173,13 @@ channel_dump_statistics(channel_t *chan, int severity)
}
} else {
if (chan->nickname) {
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel " U64_FORMAT " does not know the digest"
" of the OR it is connected to, but reports its nickname is %s",
U64_PRINTF_ARG(chan->global_identifier),
chan->nickname);
} else {
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel " U64_FORMAT " does not know the digest"
" or the nickname of the OR it is connected to",
U64_PRINTF_ARG(chan->global_identifier));
@@ -3191,7 +3191,7 @@ channel_dump_statistics(channel_t *chan, int severity)
if (have_remote_addr) {
char *actual = tor_strdup(channel_get_actual_remote_descr(chan));
remote_addr_str = tor_dup_addr(&remote_addr);
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel " U64_FORMAT " says its remote address"
" is %s, and gives a canonical description of \"%s\" and an "
"actual description of \"%s\"",
@@ -3203,7 +3203,7 @@ channel_dump_statistics(channel_t *chan, int severity)
tor_free(actual);
} else {
char *actual = tor_strdup(channel_get_actual_remote_descr(chan));
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel " U64_FORMAT " does not know its remote "
"address, but gives a canonical description of \"%s\" and an "
"actual description of \"%s\"",
@@ -3214,7 +3214,7 @@ channel_dump_statistics(channel_t *chan, int severity)
}
/* Handle marks */
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel " U64_FORMAT " has these marks: %s %s %s "
"%s %s %s",
U64_PRINTF_ARG(chan->global_identifier),
@@ -3233,7 +3233,7 @@ channel_dump_statistics(channel_t *chan, int severity)
"incoming" : "outgoing");
/* Describe queues */
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel " U64_FORMAT " has %d queued incoming cells"
" and %d queued outgoing cells",
U64_PRINTF_ARG(chan->global_identifier),
@@ -3241,7 +3241,7 @@ channel_dump_statistics(channel_t *chan, int severity)
chan_cell_queue_len(&chan->outgoing_queue));
/* Describe circuits */
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel " U64_FORMAT " has %d active circuits out of"
" %d in total",
U64_PRINTF_ARG(chan->global_identifier),
@@ -3251,25 +3251,25 @@ channel_dump_statistics(channel_t *chan, int severity)
circuitmux_num_circuits(chan->cmux) : 0);
/* Describe timestamps */
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel " U64_FORMAT " was last used by a "
"client at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
U64_PRINTF_ARG(chan->global_identifier),
U64_PRINTF_ARG(chan->timestamp_client),
U64_PRINTF_ARG(now - chan->timestamp_client));
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel " U64_FORMAT " was last drained at "
U64_FORMAT " (" U64_FORMAT " seconds ago)",
U64_PRINTF_ARG(chan->global_identifier),
U64_PRINTF_ARG(chan->timestamp_drained),
U64_PRINTF_ARG(now - chan->timestamp_drained));
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel " U64_FORMAT " last received a cell "
"at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
U64_PRINTF_ARG(chan->global_identifier),
U64_PRINTF_ARG(chan->timestamp_recv),
U64_PRINTF_ARG(now - chan->timestamp_recv));
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel " U64_FORMAT " last trasmitted a cell "
"at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
U64_PRINTF_ARG(chan->global_identifier),
@@ -3277,7 +3277,7 @@ channel_dump_statistics(channel_t *chan, int severity)
U64_PRINTF_ARG(now - chan->timestamp_xmit));
/* Describe counters and rates */
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel " U64_FORMAT " has received "
U64_FORMAT " cells and transmitted " U64_FORMAT,
U64_PRINTF_ARG(chan->global_identifier),
@@ -3288,13 +3288,13 @@ channel_dump_statistics(channel_t *chan, int severity)
if (chan->n_cells_recved > 0) {
avg = (double)(chan->n_cells_recved) / age;
if (avg >= 1.0) {
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel " U64_FORMAT " has averaged %f "
"cells received per second",
U64_PRINTF_ARG(chan->global_identifier), avg);
} else if (avg >= 0.0) {
interval = 1.0 / avg;
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel " U64_FORMAT " has averaged %f "
"seconds between received cells",
U64_PRINTF_ARG(chan->global_identifier), interval);
@@ -3303,13 +3303,13 @@ channel_dump_statistics(channel_t *chan, int severity)
if (chan->n_cells_xmitted > 0) {
avg = (double)(chan->n_cells_xmitted) / age;
if (avg >= 1.0) {
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel " U64_FORMAT " has averaged %f "
"cells transmitted per second",
U64_PRINTF_ARG(chan->global_identifier), avg);
} else if (avg >= 0.0) {
interval = 1.0 / avg;
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel " U64_FORMAT " has averaged %f "
"seconds between transmitted cells",
U64_PRINTF_ARG(chan->global_identifier), interval);
@@ -3337,13 +3337,13 @@ channel_listener_dump_statistics(channel_listener_t *chan_l, int severity)
age = (double)(now - chan_l->timestamp_created);
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
"Channel listener " U64_FORMAT " (at %p) with transport %s is in "
"state %s (%d)",
U64_PRINTF_ARG(chan_l->global_identifier), chan_l,
channel_listener_describe_transport(chan_l),
channel_listener_state_to_string(chan_l->state), chan_l->state);
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel listener " U64_FORMAT " was created at " U64_FORMAT
" (" U64_FORMAT " seconds ago) "
"and last active at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
@@ -3353,7 +3353,7 @@ channel_listener_dump_statistics(channel_listener_t *chan_l, int severity)
U64_PRINTF_ARG(chan_l->timestamp_active),
U64_PRINTF_ARG(now - chan_l->timestamp_active));
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel listener " U64_FORMAT " last accepted an incoming "
"channel at " U64_FORMAT " (" U64_FORMAT " seconds ago) "
"and has accepted " U64_FORMAT " channels in total",
@@ -3371,13 +3371,13 @@ channel_listener_dump_statistics(channel_listener_t *chan_l, int severity)
chan_l->n_accepted > 0) {
avg = (double)(chan_l->n_accepted) / age;
if (avg >= 1.0) {
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel listener " U64_FORMAT " has averaged %f incoming "
"channels per second",
U64_PRINTF_ARG(chan_l->global_identifier), avg);
} else if (avg >= 0.0) {
interval = 1.0 / avg;
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" * Channel listener " U64_FORMAT " has averaged %f seconds "
"between incoming channels",
U64_PRINTF_ARG(chan_l->global_identifier), interval);
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index b8f71bd34..8a378c0a0 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -783,7 +783,7 @@ circuit_dump_conn_details(int severity,
int this_circid,
int other_circid)
{
- log(severity, LD_CIRC, "Conn %d has %s circuit: circID %d (other side %d), "
+ tor_log(severity, LD_CIRC, "Conn %d has %s circuit: circID %d (other side %d), "
"state %d (%s), born %ld:",
conn_array_index, type, this_circid, other_circid, circ->state,
circuit_state_to_string(circ->state),
@@ -846,7 +846,7 @@ circuit_dump_chan_details(int severity,
int this_circid,
int other_circid)
{
- log(severity, LD_CIRC, "Conn %p has %s circuit: circID %d (other side %d), "
+ tor_log(severity, LD_CIRC, "Conn %p has %s circuit: circID %d (other side %d), "
"state %d (%s), born %ld:",
chan, type, this_circid, other_circid, circ->state,
circuit_state_to_string(circ->state),
@@ -1343,7 +1343,7 @@ circuit_mark_for_close_(circuit_t *circ, int reason, int line,
tor_assert(file);
if (circ->marked_for_close) {
- log(LOG_WARN,LD_BUG,
+ log_warn(LD_BUG,
"Duplicate call to circuit_mark_for_close at %s:%d"
" (first at %s:%d)", file, line,
circ->marked_for_close_file, circ->marked_for_close);
diff --git a/src/or/config.c b/src/or/config.c
index dcd053ff6..74b635e85 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1092,7 +1092,7 @@ options_act_reversible(const or_options_t *old_options, char **msg)
mark_logs_temp(); /* Close current logs once new logs are open. */
logs_marked = 1;
- if (options_init_logs(options, 0)<0) { /* Configure the log(s) */
+ if (options_init_logs(options, 0)<0) { /* Configure the tor_log(s) */
*msg = tor_strdup("Failed to init Log options. See logs for details.");
goto rollback;
}
@@ -1268,7 +1268,7 @@ options_act(const or_options_t *old_options)
return -1;
#ifdef NON_ANONYMOUS_MODE_ENABLED
- log(LOG_WARN, LD_GENERAL, "This copy of Tor was compiled to run in a "
+ log_warn(LD_GENERAL, "This copy of Tor was compiled to run in a "
"non-anonymous mode. It will provide NO ANONYMITY.");
#endif
@@ -1770,7 +1770,7 @@ config_get_commandlines(int argc, char **argv, config_line_t **result)
(*new)->value = want_arg ? tor_strdup(argv[i+1]) : tor_strdup("");
(*new)->command = command;
(*new)->next = NULL;
- log(LOG_DEBUG, LD_CONFIG, "command line: parsed keyword '%s', value '%s'",
+ log_debug(LD_CONFIG, "command line: parsed keyword '%s', value '%s'",
(*new)->key, (*new)->value);
new = &((*new)->next);
@@ -2218,7 +2218,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
int n_ports=0;
#define REJECT(arg) \
STMT_BEGIN *msg = tor_strdup(arg); return -1; STMT_END
-#define COMPLAIN(arg) STMT_BEGIN log(LOG_WARN, LD_CONFIG, arg); STMT_END
+#define COMPLAIN(arg) STMT_BEGIN log_warn(LD_CONFIG, arg); STMT_END
tor_assert(msg);
*msg = NULL;
@@ -2227,7 +2227,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
(!strcmpstart(uname, "Windows 95") ||
!strcmpstart(uname, "Windows 98") ||
!strcmpstart(uname, "Windows Me"))) {
- log(LOG_WARN, LD_CONFIG, "Tor is running as a server, but you are "
+ log_warn(LD_CONFIG, "Tor is running as a server, but you are "
"running %s; this probably won't work. See "
"https://wiki.torproject.org/TheOnionRouter/TorFAQ#ServerOS "
"for details.", uname);
@@ -2256,7 +2256,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
}
if (server_mode(options) && !options->ContactInfo)
- log(LOG_NOTICE, LD_CONFIG, "Your ContactInfo config option is not set. "
+ log_notice(LD_CONFIG, "Your ContactInfo config option is not set. "
"Please consider setting it, so we can contact you if your server is "
"misconfigured or something else goes wrong.");
@@ -2268,7 +2268,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
config_line_append(&options->Logs, "Log", "warn stdout");
}
- if (options_init_logs(options, 1)<0) /* Validate the log(s) */
+ if (options_init_logs(options, 1)<0) /* Validate the tor_log(s) */
REJECT("Failed to validate Log options. See logs for details.");
if (authdir_mode(options)) {
@@ -2286,7 +2286,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
/* XXXX require that the only port not be DirPort? */
/* XXXX require that at least one port be listened-upon. */
if (n_ports == 0 && !options->RendConfigLines)
- log(LOG_WARN, LD_CONFIG,
+ log_warn(LD_CONFIG,
"SocksPort, TransPort, NATDPort, DNSPort, and ORPort are all "
"undefined, and there aren't any hidden services configured. "
"Tor will still run, but probably won't do anything.");
@@ -2446,7 +2446,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
});
new_line->value = smartlist_join_strings(instead,",",0,NULL);
/* These have been deprecated since 0.1.1.5-alpha-cvs */
- log(LOG_NOTICE, LD_CONFIG,
+ log_notice(LD_CONFIG,
"Converting FascistFirewall and FirewallPorts "
"config options to new format: \"ReachableAddresses %s\"",
new_line->value);
@@ -2461,7 +2461,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
new_line->key = tor_strdup("ReachableDirAddresses");
new_line->value = tor_strdup("*:80");
options->ReachableDirAddresses = new_line;
- log(LOG_NOTICE, LD_CONFIG, "Converting FascistFirewall config option "
+ log_notice(LD_CONFIG, "Converting FascistFirewall config option "
"to new format: \"ReachableDirAddresses *:80\"");
}
if (!options->ReachableORAddresses) {
@@ -2469,7 +2469,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
new_line->key = tor_strdup("ReachableORAddresses");
new_line->value = tor_strdup("*:443");
options->ReachableORAddresses = new_line;
- log(LOG_NOTICE, LD_CONFIG, "Converting FascistFirewall config option "
+ log_notice(LD_CONFIG, "Converting FascistFirewall config option "
"to new format: \"ReachableORAddresses *:443\"");
}
}
@@ -3423,7 +3423,7 @@ find_torrc_filename(int argc, char **argv,
for (i = 1; i < argc; ++i) {
if (i < argc-1 && !strcmp(argv[i],fname_opt)) {
if (fname) {
- log(LOG_WARN, LD_CONFIG, "Duplicate %s options on command line.",
+ log_warn(LD_CONFIG, "Duplicate %s options on command line.",
fname_opt);
tor_free(fname);
}
@@ -3486,7 +3486,7 @@ load_torrc_from_disk(int argc, char **argv, int defaults_file)
fname = find_torrc_filename(argc, argv, defaults_file,
&using_default_torrc, &ignore_missing_torrc);
tor_assert(fname);
- log(LOG_DEBUG, LD_CONFIG, "Opening config file \"%s\"", fname);
+ log_debug(LD_CONFIG, "Opening config file \"%s\"", fname);
tor_free(*fname_var);
*fname_var = fname;
@@ -3496,18 +3496,18 @@ load_torrc_from_disk(int argc, char **argv, int defaults_file)
!(cf = read_file_to_str(fname,0,NULL))) {
if (using_default_torrc == 1 || ignore_missing_torrc) {
if (!defaults_file)
- log(LOG_NOTICE, LD_CONFIG, "Configuration file \"%s\" not present, "
+ log_notice(LD_CONFIG, "Configuration file \"%s\" not present, "
"using reasonable defaults.", fname);
tor_free(fname); /* sets fname to NULL */
*fname_var = NULL;
cf = tor_strdup("");
} else {
- log(LOG_WARN, LD_CONFIG,
+ log_warn(LD_CONFIG,
"Unable to open configuration file \"%s\".", fname);
goto err;
}
} else {
- log(LOG_NOTICE, LD_CONFIG, "Read configuration file \"%s\".", fname);
+ log_notice(LD_CONFIG, "Read configuration file \"%s\".", fname);
}
return cf;
@@ -3599,7 +3599,7 @@ options_init_from_torrc(int argc, char **argv)
tor_free(cf);
tor_free(cf_defaults);
if (errmsg) {
- log(LOG_WARN,LD_CONFIG,"%s", errmsg);
+ log_warn(LD_CONFIG,"%s", errmsg);
tor_free(errmsg);
}
return retval < 0 ? -1 : 0;
@@ -5383,7 +5383,7 @@ check_server_ports(const smartlist_t *ports,
}
if (n_low_port && options->AccountingMax) {
- log(LOG_WARN, LD_CONFIG,
+ log_warn(LD_CONFIG,
"You have set AccountingMax to use hibernation. You have also "
"chosen a low DirPort or OrPort. This combination can make Tor stop "
"working when it tries to re-attach the port after a period of "
diff --git a/src/or/connection.c b/src/or/connection.c
index b3719151f..c1cfbd61f 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -731,7 +731,7 @@ connection_mark_for_close_internal_(connection_t *conn,
tor_assert(file);
if (conn->marked_for_close) {
- log(LOG_WARN,LD_BUG,"Duplicate call to connection_mark_for_close at %s:%d"
+ log_warn(LD_BUG,"Duplicate call to connection_mark_for_close at %s:%d"
" (first at %s:%d)", file, line, conn->marked_for_close_file,
conn->marked_for_close);
tor_fragile_assert();
@@ -2530,7 +2530,7 @@ connection_bucket_refill_helper(int *bucket, int rate, int burst,
*bucket = burst;
}
}
- log(LOG_DEBUG, LD_NET,"%s now %d.", name, *bucket);
+ log_debug(LD_NET,"%s now %d.", name, *bucket);
}
}
@@ -3897,7 +3897,7 @@ client_check_address_changed(tor_socket_t sock)
} else {
/* The interface changed. We're a client, so we need to regenerate our
* keys. First, reset the state. */
- log(LOG_NOTICE, LD_NET, "Our IP address has changed. Rotating keys...");
+ log_notice(LD_NET, "Our IP address has changed. Rotating keys...");
tor_addr_copy(*last_interface_ip_ptr, &iface_addr);
SMARTLIST_FOREACH(outgoing_addrs, tor_addr_t*, a_ptr, tor_free(a_ptr));
smartlist_clear(outgoing_addrs);
@@ -4109,14 +4109,14 @@ connection_dump_buffer_mem_stats(int severity)
total_alloc += alloc_by_type[i];
}
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
"In buffers for %d connections: "U64_FORMAT" used/"U64_FORMAT" allocated",
smartlist_len(conns),
U64_PRINTF_ARG(total_used), U64_PRINTF_ARG(total_alloc));
for (i=CONN_TYPE_MIN_; i <= CONN_TYPE_MAX_; ++i) {
if (!n_conns_by_type[i])
continue;
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
" For %d %s connections: "U64_FORMAT" used/"U64_FORMAT" allocated",
n_conns_by_type[i], conn_type_to_string(i),
U64_PRINTF_ARG(used_by_type[i]), U64_PRINTF_ARG(alloc_by_type[i]));
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 872decba1..5ec32d632 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -295,13 +295,13 @@ connection_or_report_broken_states(int severity, int domain)
smartlist_sort(items, broken_state_count_compare);
- log(severity, domain, "%d connections have failed%s", total,
+ tor_log(severity, domain, "%d connections have failed%s", total,
smartlist_len(items) > MAX_REASONS_TO_REPORT ? ". Top reasons:" : ":");
SMARTLIST_FOREACH_BEGIN(items, const broken_state_count_t *, c) {
if (c_sl_idx > MAX_REASONS_TO_REPORT)
break;
- log(severity, domain,
+ tor_log(severity, domain,
" %d connections died in state %s", (int)c->count, c->state);
} SMARTLIST_FOREACH_END(c);
diff --git a/src/or/control.c b/src/or/control.c
index 54e5c597a..9ab0dafb7 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -4663,7 +4663,7 @@ control_event_bootstrap(bootstrap_status_t status, int progress)
if (status > bootstrap_percent ||
(progress && progress > bootstrap_percent)) {
bootstrap_status_to_string(status, &tag, &summary);
- log(status ? LOG_NOTICE : LOG_INFO, LD_CONTROL,
+ tor_log(status ? LOG_NOTICE : LOG_INFO, LD_CONTROL,
"Bootstrapped %d%%: %s.", progress ? progress : status, summary);
tor_snprintf(buf, sizeof(buf),
"BOOTSTRAP PROGRESS=%d TAG=%s SUMMARY=\"%s\"",
diff --git a/src/or/directory.c b/src/or/directory.c
index c68a4e3b2..c10141844 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1860,7 +1860,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
const char *flavname = conn->requested_resource;
if (status_code != 200) {
int severity = (status_code == 304) ? LOG_INFO : LOG_WARN;
- log(severity, LD_DIR,
+ tor_log(severity, LD_DIR,
"Received http status code %d (%s) from server "
"'%s:%d' while fetching consensus directory.",
status_code, escaped(reason), conn->base_.address,
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 8af848ca0..e2cd7cfd2 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -2017,7 +2017,7 @@ dirserv_compute_performance_thresholds(routerlist_t *rl)
median_uint32(bandwidths_excluding_exits, n_active_nonexit);
}
- log(LOG_INFO, LD_DIRSERV,
+ log_info(LD_DIRSERV,
"Cutoffs: For Stable, %lu sec uptime, %lu sec MTBF. "
"For Fast: %lu bytes/sec. "
"For Guard: WFU %.03f%%, time-known %lu sec, "
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index 0731426d9..aee9a6edf 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -2288,7 +2288,7 @@ networkstatus_add_detached_signatures(networkstatus_t *target,
if (sig->good_signature || !old_sig || old_sig->bad_signature) {
log_info(LD_DIR, "Adding signature from %s with %s", voter_identity,
algorithm);
- log(severity, LD_DIR, "Added a signature for %s from %s.",
+ tor_log(severity, LD_DIR, "Added a signature for %s from %s.",
target_voter->nickname, source);
++r;
if (old_sig) {
diff --git a/src/or/dns.c b/src/or/dns.c
index 68309a80d..edcf92e5b 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -262,7 +262,7 @@ evdns_log_cb(int warn, const char *msg)
int severity = warn ? LOG_WARN : LOG_INFO;
if (!strcmpstart(msg, "Resolve requested for") &&
get_options()->SafeLogging) {
- log(LOG_INFO, LD_EXIT, "eventdns: Resolve requested.");
+ log_info(LD_EXIT, "eventdns: Resolve requested.");
return;
} else if (!strcmpstart(msg, "Search: ")) {
return;
@@ -291,7 +291,7 @@ evdns_log_cb(int warn, const char *msg)
control_event_server_status(LOG_WARN, "NAMESERVER_ALL_DOWN");
all_down = 1;
}
- log(severity, LD_EXIT, "eventdns: %s", msg);
+ tor_log(severity, LD_EXIT, "eventdns: %s", msg);
}
/** Helper: passed to eventdns.c as a callback so it can generate random
@@ -835,7 +835,7 @@ dns_resolve_impl(edge_connection_t *exitconn, int is_resolve,
return -1;
if (address_is_invalid_destination(exitconn->base_.address, 0)) {
- log(LOG_PROTOCOL_WARN, LD_EXIT,
+ tor_log(LOG_PROTOCOL_WARN, LD_EXIT,
"Rejecting invalid destination address %s",
escaped_safe_str(exitconn->base_.address));
return -1;
@@ -1844,7 +1844,7 @@ wildcard_increment_answer(const char *id)
if (*ip > 5 && n_wildcard_requests > 10) {
if (!dns_wildcard_list) dns_wildcard_list = smartlist_new();
if (!smartlist_contains_string(dns_wildcard_list, id)) {
- log(dns_wildcard_notice_given ? LOG_INFO : LOG_NOTICE, LD_EXIT,
+ tor_log(dns_wildcard_notice_given ? LOG_INFO : LOG_NOTICE, LD_EXIT,
"Your DNS provider has given \"%s\" as an answer for %d different "
"invalid addresses. Apparently they are hijacking DNS failures. "
"I'll try to correct for this by treating future occurrences of "
@@ -1876,7 +1876,7 @@ add_wildcarded_test_address(const char *address)
smartlist_add(dns_wildcarded_test_address_list, tor_strdup(address));
n = smartlist_len(dns_wildcarded_test_address_list);
if (n > n_test_addrs/2) {
- log(dns_wildcarded_test_address_notice_given ? LOG_INFO : LOG_NOTICE,
+ tor_log(dns_wildcarded_test_address_notice_given ? LOG_INFO : LOG_NOTICE,
LD_EXIT, "Your DNS provider tried to redirect \"%s\" to a junk "
"address. It has done this with %d test addresses so far. I'm "
"going to stop being an exit node for now, since our DNS seems so "
@@ -1920,7 +1920,7 @@ evdns_wildcard_check_callback(int result, char type, int count, int ttl,
}
}
- log(dns_wildcard_one_notice_given ? LOG_INFO : LOG_NOTICE, LD_EXIT,
+ tor_log(dns_wildcard_one_notice_given ? LOG_INFO : LOG_NOTICE, LD_EXIT,
"Your DNS provider gave an answer for \"%s\", which "
"is not supposed to exist. Apparently they are hijacking "
"DNS failures. Trying to correct for this. We've noticed %d "
@@ -2151,8 +2151,8 @@ dump_dns_mem_usage(int severity)
/* Print out the count and estimated size of our &cache_root. It undercounts
hostnames in cached reverse resolves.
*/
- log(severity, LD_MM, "Our DNS cache has %d entries.", hash_count);
- log(severity, LD_MM, "Our DNS cache size is approximately %u bytes.",
+ tor_log(severity, LD_MM, "Our DNS cache has %d entries.", hash_count);
+ tor_log(severity, LD_MM, "Our DNS cache size is approximately %u bytes.",
(unsigned)hash_mem);
}
diff --git a/src/or/main.c b/src/or/main.c
index 3cdfe8acf..79b0f2577 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -973,7 +973,7 @@ directory_info_has_arrived(time_t now, int from_cache)
if (!router_have_minimum_dir_info()) {
int quiet = from_cache ||
directory_too_idle_to_fetch_descriptors(options, now);
- log(quiet ? LOG_INFO : LOG_NOTICE, LD_DIR,
+ tor_log(quiet ? LOG_INFO : LOG_NOTICE, LD_DIR,
"I learned some more directory information, but not enough to "
"build a circuit: %s", get_dir_info_status_string());
update_all_descriptor_downloads(now);
@@ -1201,7 +1201,7 @@ run_scheduled_events(time_t now)
* eventually. */
if (signewnym_is_pending &&
time_of_last_signewnym + MAX_SIGNEWNYM_RATE <= now) {
- log(LOG_INFO, LD_CONTROL, "Honoring delayed NEWNYM request");
+ log_info(LD_CONTROL, "Honoring delayed NEWNYM request");
signewnym_impl(now);
}
@@ -2083,7 +2083,7 @@ process_signal(uintptr_t sig)
time_t now = time(NULL);
if (time_of_last_signewnym + MAX_SIGNEWNYM_RATE > now) {
signewnym_is_pending = 1;
- log(LOG_NOTICE, LD_CONTROL,
+ log_notice(LD_CONTROL,
"Rate limiting NEWNYM request: delaying by %d second(s)",
(int)(MAX_SIGNEWNYM_RATE+time_of_last_signewnym-now));
} else {
@@ -2115,7 +2115,7 @@ static void
dumpmemusage(int severity)
{
connection_dump_buffer_mem_stats(severity);
- log(severity, LD_GENERAL, "In rephist: "U64_FORMAT" used by %d Tors.",
+ tor_log(severity, LD_GENERAL, "In rephist: "U64_FORMAT" used by %d Tors.",
U64_PRINTF_ARG(rephist_total_alloc), rephist_total_num);
dump_routerlist_mem_usage(severity);
dump_cell_pool_usage(severity);
@@ -2133,27 +2133,27 @@ dumpstats(int severity)
time_t elapsed;
size_t rbuf_cap, wbuf_cap, rbuf_len, wbuf_len;
- log(severity, LD_GENERAL, "Dumping stats:");
+ tor_log(severity, LD_GENERAL, "Dumping stats:");
SMARTLIST_FOREACH_BEGIN(connection_array, connection_t *, conn) {
int i = conn_sl_idx;
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
"Conn %d (socket %d) type %d (%s), state %d (%s), created %d secs ago",
i, (int)conn->s, conn->type, conn_type_to_string(conn->type),
conn->state, conn_state_to_string(conn->type, conn->state),
(int)(now - conn->timestamp_created));
if (!connection_is_listener(conn)) {
- log(severity,LD_GENERAL,
+ tor_log(severity,LD_GENERAL,
"Conn %d is to %s:%d.", i,
safe_str_client(conn->address),
conn->port);
- log(severity,LD_GENERAL,
+ tor_log(severity,LD_GENERAL,
"Conn %d: %d bytes waiting on inbuf (len %d, last read %d secs ago)",
i,
(int)connection_get_inbuf_len(conn),
(int)buf_allocation(conn->inbuf),
(int)(now - conn->timestamp_lastread));
- log(severity,LD_GENERAL,
+ tor_log(severity,LD_GENERAL,
"Conn %d: %d bytes waiting on outbuf "
"(len %d, last written %d secs ago)",i,
(int)connection_get_outbuf_len(conn),
@@ -2164,7 +2164,7 @@ dumpstats(int severity)
if (or_conn->tls) {
tor_tls_get_buffer_sizes(or_conn->tls, &rbuf_cap, &rbuf_len,
&wbuf_cap, &wbuf_len);
- log(severity, LD_GENERAL,
+ tor_log(severity, LD_GENERAL,
"Conn %d: %d/%d bytes used on OpenSSL read buffer; "
"%d/%d bytes used on write buffer.",
i, (int)rbuf_len, (int)rbuf_cap, (int)wbuf_len, (int)wbuf_cap);
@@ -2178,7 +2178,7 @@ dumpstats(int severity)
channel_dumpstats(severity);
channel_listener_dumpstats(severity);
- log(severity, LD_NET,
+ tor_log(severity, LD_NET,
"Cells processed: "U64_FORMAT" padding\n"
" "U64_FORMAT" create\n"
" "U64_FORMAT" created\n"
@@ -2194,11 +2194,11 @@ dumpstats(int severity)
U64_PRINTF_ARG(stats_n_relay_cells_delivered),
U64_PRINTF_ARG(stats_n_destroy_cells_processed));
if (stats_n_data_cells_packaged)
- log(severity,LD_NET,"Average packaged cell fullness: %2.3f%%",
+ tor_log(severity,LD_NET,"Average packaged cell fullness: %2.3f%%",
100*(U64_TO_DBL(stats_n_data_bytes_packaged) /
U64_TO_DBL(stats_n_data_cells_packaged*RELAY_PAYLOAD_SIZE)) );
if (stats_n_data_cells_received)
- log(severity,LD_NET,"Average delivered cell fullness: %2.3f%%",
+ tor_log(severity,LD_NET,"Average delivered cell fullness: %2.3f%%",
100*(U64_TO_DBL(stats_n_data_bytes_received) /
U64_TO_DBL(stats_n_data_cells_received*RELAY_PAYLOAD_SIZE)) );
@@ -2211,19 +2211,19 @@ dumpstats(int severity)
elapsed = 0;
if (elapsed) {
- log(severity, LD_NET,
+ tor_log(severity, LD_NET,
"Average bandwidth: "U64_FORMAT"/%d = %d bytes/sec reading",
U64_PRINTF_ARG(stats_n_bytes_read),
(int)elapsed,
(int) (stats_n_bytes_read/elapsed));
- log(severity, LD_NET,
+ tor_log(severity, LD_NET,
"Average bandwidth: "U64_FORMAT"/%d = %d bytes/sec writing",
U64_PRINTF_ARG(stats_n_bytes_written),
(int)elapsed,
(int) (stats_n_bytes_written/elapsed));
}
- log(severity, LD_NET, "--------------- Dumping memory information:");
+ tor_log(severity, LD_NET, "--------------- Dumping memory information:");
dumpmemusage(severity);
rep_hist_dump_stats(now,severity);
@@ -2364,7 +2364,7 @@ tor_init(int argc, char *argv[])
}
#ifdef NON_ANONYMOUS_MODE_ENABLED
- log(LOG_WARN, LD_GENERAL, "This copy of Tor was compiled to run in a "
+ log_warn(LD_GENERAL, "This copy of Tor was compiled to run in a "
"non-anonymous mode. It will provide NO ANONYMITY.");
#endif
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 79dd706c4..b45d402ba 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -561,7 +561,7 @@ networkstatus_check_consensus_signature(networkstatus_t *consensus,
if (warn >= 0) {
SMARTLIST_FOREACH(unrecognized, networkstatus_voter_info_t *, voter,
{
- log(severity, LD_DIR, "Consensus includes unrecognized authority "
+ tor_log(severity, LD_DIR, "Consensus includes unrecognized authority "
"'%s' at %s:%d (contact %s; identity %s)",
voter->nickname, voter->address, (int)voter->dir_port,
voter->contact?voter->contact:"n/a",
@@ -569,7 +569,7 @@ networkstatus_check_consensus_signature(networkstatus_t *consensus,
});
SMARTLIST_FOREACH(need_certs_from, networkstatus_voter_info_t *, voter,
{
- log(severity, LD_DIR, "Looks like we need to download a new "
+ tor_log(severity, LD_DIR, "Looks like we need to download a new "
"certificate from authority '%s' at %s:%d (contact %s; "
"identity %s)",
voter->nickname, voter->address, (int)voter->dir_port,
@@ -578,7 +578,7 @@ networkstatus_check_consensus_signature(networkstatus_t *consensus,
});
SMARTLIST_FOREACH(missing_authorities, dir_server_t *, ds,
{
- log(severity, LD_DIR, "Consensus does not include configured "
+ tor_log(severity, LD_DIR, "Consensus does not include configured "
"authority '%s' at %s:%d (identity %s)",
ds->nickname, ds->address, (int)ds->dir_port,
hex_str(ds->v3_identity_digest, DIGEST_LEN));
@@ -614,7 +614,7 @@ networkstatus_check_consensus_signature(networkstatus_t *consensus,
"because we were missing the keys.", n_missing_key);
}
joined = smartlist_join_strings(sl, " ", 0, NULL);
- log(severity, LD_DIR, "%s", joined);
+ tor_log(severity, LD_DIR, "%s", joined);
tor_free(joined);
SMARTLIST_FOREACH(sl, char *, c, tor_free(c));
smartlist_free(sl);
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index c2eb670e4..9f77dcafe 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -1463,14 +1463,14 @@ update_router_have_minimum_dir_info(void)
done:
if (res && !have_min_dir_info) {
- log(LOG_NOTICE, LD_DIR,
+ log_notice(LD_DIR,
"We now have enough directory information to build circuits.");
control_event_client_status(LOG_NOTICE, "ENOUGH_DIR_INFO");
control_event_bootstrap(BOOTSTRAP_STATUS_CONN_OR, 0);
}
if (!res && have_min_dir_info) {
int quiet = directory_too_idle_to_fetch_descriptors(options, now);
- log(quiet ? LOG_INFO : LOG_NOTICE, LD_DIR,
+ tor_log(quiet ? LOG_INFO : LOG_NOTICE, LD_DIR,
"Our directory information is no longer up-to-date "
"enough to build circuits: %s", dir_info_status);
diff --git a/src/or/policies.c b/src/or/policies.c
index f9a03aef2..9696b8123 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -881,7 +881,7 @@ exit_policy_remove_redundancies(smartlist_t *dest)
char p1[POLICY_BUF_LEN], p2[POLICY_BUF_LEN];
policy_write_item(p1, sizeof(p1), tmp, 0);
policy_write_item(p2, sizeof(p2), ap, 0);
- log(LOG_DEBUG, LD_CONFIG, "Removing exit policy %s (%d). It is made "
+ log_debug(LD_CONFIG, "Removing exit policy %s (%d). It is made "
"redundant by %s (%d).", p1, j, p2, i);
smartlist_del_keeporder(dest, j--);
addr_policy_free(tmp);
@@ -910,7 +910,7 @@ exit_policy_remove_redundancies(smartlist_t *dest)
char p1[POLICY_BUF_LEN], p2[POLICY_BUF_LEN];
policy_write_item(p1, sizeof(p1), ap, 0);
policy_write_item(p2, sizeof(p2), tmp, 0);
- log(LOG_DEBUG, LD_CONFIG, "Removing exit policy %s. It is already "
+ log_debug(LD_CONFIG, "Removing exit policy %s. It is already "
"covered by %s.", p1, p2);
smartlist_del_keeporder(dest, i--);
addr_policy_free(ap);
diff --git a/src/or/relay.c b/src/or/relay.c
index f711eae92..66b3089d6 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -2023,7 +2023,7 @@ dump_cell_pool_usage(int severity)
n_cells += TO_OR_CIRCUIT(c)->p_chan_cells.n;
++n_circs;
}
- log(severity, LD_MM, "%d cells allocated on %d circuits. %d cells leaked.",
+ tor_log(severity, LD_MM, "%d cells allocated on %d circuits. %d cells leaked.",
n_cells, n_circs, total_cells_allocated - n_cells);
mp_pool_log_status(cell_pool, severity);
}
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index f115d8bfc..f85ac2c03 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -3304,7 +3304,7 @@ rend_service_dump_stats(int severity)
for (i=0; i < smartlist_len(rend_service_list); ++i) {
service = smartlist_get(rend_service_list, i);
- log(severity, LD_GENERAL, "Service configured in \"%s\":",
+ tor_log(severity, LD_GENERAL, "Service configured in \"%s\":",
service->directory);
for (j=0; j < smartlist_len(service->intro_nodes); ++j) {
intro = smartlist_get(service->intro_nodes, j);
@@ -3312,11 +3312,11 @@ rend_service_dump_stats(int severity)
circ = find_intro_circuit(intro, service->pk_digest);
if (!circ) {
- log(severity, LD_GENERAL, " Intro point %d at %s: no circuit",
+ tor_log(severity, LD_GENERAL, " Intro point %d at %s: no circuit",
j, safe_name);
continue;
}
- log(severity, LD_GENERAL, " Intro point %d at %s: circuit is %s",
+ tor_log(severity, LD_GENERAL, " Intro point %d at %s: circuit is %s",
j, safe_name, circuit_state_to_string(circ->base_.state));
}
}
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 74d459f8a..925ca8815 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -648,7 +648,7 @@ rep_hist_dump_stats(time_t now, int severity)
rep_history_clean(now - get_options()->RephistTrackTime);
- log(severity, LD_HIST, "--------------- Dumping history information:");
+ tor_log(severity, LD_HIST, "--------------- Dumping history information:");
for (orhist_it = digestmap_iter_init(history_map);
!digestmap_iter_done(orhist_it);
@@ -673,7 +673,7 @@ rep_hist_dump_stats(time_t now, int severity)
} else {
uptime=1.0;
}
- log(severity, LD_HIST,
+ tor_log(severity, LD_HIST,
"OR %s [%s]: %ld/%ld good connections; uptime %ld/%ld sec (%.2f%%); "
"wmtbf %lu:%02lu:%02lu",
name1, hexdigest1,
@@ -707,7 +707,7 @@ rep_hist_dump_stats(time_t now, int severity)
else
len += ret;
}
- log(severity, LD_HIST, "%s", buffer);
+ tor_log(severity, LD_HIST, "%s", buffer);
}
}
}
@@ -2042,7 +2042,7 @@ note_crypto_pk_op(pk_op_t operation)
void
dump_pk_ops(int severity)
{
- log(severity, LD_HIST,
+ tor_log(severity, LD_HIST,
"PK operations: %lu directory objects signed, "
"%lu directory objects verified, "
"%lu routerdescs signed, "
diff --git a/src/or/router.c b/src/or/router.c
index c584d6277..69d346f5b 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -391,14 +391,14 @@ init_key_from_file(const char *fname, int generate, int severity)
crypto_pk_t *prkey = NULL;
if (!(prkey = crypto_pk_new())) {
- log(severity, LD_GENERAL,"Error constructing key");
+ tor_log(severity, LD_GENERAL,"Error constructing key");
goto error;
}
switch (file_status(fname)) {
case FN_DIR:
case FN_ERROR:
- log(severity, LD_FS,"Can't read key from \"%s\"", fname);
+ tor_log(severity, LD_FS,"Can't read key from \"%s\"", fname);
goto error;
case FN_NOENT:
if (generate) {
@@ -406,7 +406,7 @@ init_key_from_file(const char *fname, int generate, int severity)
if (try_locking(get_options(), 0)<0) {
/* Make sure that --list-fingerprint only creates new keys
* if there is no possibility for a deadlock. */
- log(severity, LD_FS, "Another Tor process has locked \"%s\". Not "
+ tor_log(severity, LD_FS, "Another Tor process has locked \"%s\". Not "
"writing any new keys.", fname);
/*XXXX The 'other process' might make a key in a second or two;
* maybe we should wait for it. */
@@ -416,16 +416,16 @@ init_key_from_file(const char *fname, int generate, int severity)
log_info(LD_GENERAL, "No key found in \"%s\"; generating fresh key.",
fname);
if (crypto_pk_generate_key(prkey)) {
- log(severity, LD_GENERAL,"Error generating onion key");
+ tor_log(severity, LD_GENERAL,"Error generating onion key");
goto error;
}
if (crypto_pk_check_key(prkey) <= 0) {
- log(severity, LD_GENERAL,"Generated key seems invalid");
+ tor_log(severity, LD_GENERAL,"Generated key seems invalid");
goto error;
}
log_info(LD_GENERAL, "Generated key seems valid");
if (crypto_pk_write_private_key_to_filename(prkey, fname)) {
- log(severity, LD_FS,
+ tor_log(severity, LD_FS,
"Couldn't write generated key to \"%s\".", fname);
goto error;
}
@@ -435,7 +435,7 @@ init_key_from_file(const char *fname, int generate, int severity)
return prkey;
case FN_FILE:
if (crypto_pk_read_private_key_from_filename(prkey, fname)) {
- log(severity, LD_GENERAL,"Error loading private key.");
+ tor_log(severity, LD_GENERAL,"Error loading private key.");
goto error;
}
return prkey;
@@ -465,7 +465,7 @@ init_curve25519_keypair_from_file(curve25519_keypair_t *keys_out,
switch (file_status(fname)) {
case FN_DIR:
case FN_ERROR:
- log(severity, LD_FS,"Can't read key from \"%s\"", fname);
+ tor_log(severity, LD_FS,"Can't read key from \"%s\"", fname);
goto error;
case FN_NOENT:
if (generate) {
@@ -473,7 +473,7 @@ init_curve25519_keypair_from_file(curve25519_keypair_t *keys_out,
if (try_locking(get_options(), 0)<0) {
/* Make sure that --list-fingerprint only creates new keys
* if there is no possibility for a deadlock. */
- log(severity, LD_FS, "Another Tor process has locked \"%s\". Not "
+ tor_log(severity, LD_FS, "Another Tor process has locked \"%s\". Not "
"writing any new keys.", fname);
/*XXXX The 'other process' might make a key in a second or two;
* maybe we should wait for it. */
@@ -485,7 +485,7 @@ init_curve25519_keypair_from_file(curve25519_keypair_t *keys_out,
if (curve25519_keypair_generate(keys_out, 1) < 0)
goto error;
if (curve25519_keypair_write_to_file(keys_out, fname, tag)<0) {
- log(severity, LD_FS,
+ tor_log(severity, LD_FS,
"Couldn't write generated key to \"%s\".", fname);
memset(keys_out, 0, sizeof(*keys_out));
goto error;
@@ -498,12 +498,12 @@ init_curve25519_keypair_from_file(curve25519_keypair_t *keys_out,
{
char *tag_in=NULL;
if (curve25519_keypair_read_from_file(keys_out, &tag_in, fname) < 0) {
- log(severity, LD_GENERAL,"Error loading private key.");
+ tor_log(severity, LD_GENERAL,"Error loading private key.");
tor_free(tag_in);
goto error;
}
if (!tag_in || strcmp(tag_in, tag)) {
- log(severity, LD_GENERAL,"Unexpected tag %s on private key.",
+ tor_log(severity, LD_GENERAL,"Unexpected tag %s on private key.",
escaped(tag_in));
tor_free(tag_in);
goto error;
@@ -631,13 +631,13 @@ v3_authority_check_key_expiry(void)
return;
if (time_left <= 0) {
- log(badness, LD_DIR, "Your v3 authority certificate has expired."
+ tor_log(badness, LD_DIR, "Your v3 authority certificate has expired."
" Generate a new one NOW.");
} else if (time_left <= 24*60*60) {
- log(badness, LD_DIR, "Your v3 authority certificate expires in %d hours;"
+ tor_log(badness, LD_DIR, "Your v3 authority certificate expires in %d hours;"
" Generate a new one NOW.", time_left/(60*60));
} else {
- log(badness, LD_DIR, "Your v3 authority certificate expires in %d days;"
+ tor_log(badness, LD_DIR, "Your v3 authority certificate expires in %d days;"
" Generate a new one soon.", time_left/(24*60*60));
}
last_warned = now;
@@ -902,7 +902,7 @@ init_keys(void)
tor_free(cp);
tor_free(keydir);
- log(LOG_NOTICE, LD_GENERAL,
+ log_notice(LD_GENERAL,
"Your Tor server's identity key fingerprint is '%s %s'",
options->Nickname, fingerprint);
if (!authdir_mode(options))
@@ -1062,10 +1062,10 @@ decide_to_advertise_dirport(const or_options_t *options, uint16_t dir_port)
if (advertising != new_choice) {
if (new_choice == 1) {
- log(LOG_NOTICE, LD_DIR, "Advertising DirPort as %d", dir_port);
+ log_notice(LD_DIR, "Advertising DirPort as %d", dir_port);
} else {
tor_assert(reason);
- log(LOG_NOTICE, LD_DIR, "Not advertising DirPort (Reason: %s)", reason);
+ log_notice(LD_DIR, "Not advertising DirPort (Reason: %s)", reason);
}
advertising = new_choice;
}
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 5dd1a55dc..3034f91f0 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -2647,7 +2647,7 @@ dump_routerlist_mem_usage(int severity)
SMARTLIST_FOREACH(routerlist->old_routers, signed_descriptor_t *, sd,
olddescs += sd->signed_descriptor_len);
- log(severity, LD_DIR,
+ tor_log(severity, LD_DIR,
"In %d live descriptors: "U64_FORMAT" bytes. "
"In %d old descriptors: "U64_FORMAT" bytes.",
smartlist_len(routerlist->routers), U64_PRINTF_ARG(livedescs),
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index b945ea6aa..eaf015c0b 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -1029,7 +1029,7 @@ dump_distinct_digest_count(int severity)
#ifdef COUNT_DISTINCT_DIGESTS
if (!verified_digests)
verified_digests = digestmap_new();
- log(severity, LD_GENERAL, "%d *distinct* router digests verified",
+ tor_log(severity, LD_GENERAL, "%d *distinct* router digests verified",
digestmap_size(verified_digests));
#else
(void)severity; /* suppress "unused parameter" warning */
diff --git a/src/or/routerset.c b/src/or/routerset.c
index 5154e2808..3a8cabacd 100644
--- a/src/or/routerset.c
+++ b/src/or/routerset.c
@@ -95,7 +95,7 @@ routerset_refresh_countries(routerset_t *target)
tor_assert(cc < target->n_countries);
bitarray_set(target->countries, cc);
} else {
- log(LOG_WARN, LD_CONFIG, "Country code '%s' is not recognized.",
+ log_warn(LD_CONFIG, "Country code '%s' is not recognized.",
country);
}
} SMARTLIST_FOREACH_END(country);
diff --git a/src/or/status.c b/src/or/status.c
index 97d0e49e0..126167dcb 100644
--- a/src/or/status.c
+++ b/src/or/status.c
@@ -108,7 +108,7 @@ log_heartbeat(time_t now)
uptime, count_circuits(),bw_sent,bw_rcvd);
if (stats_n_data_cells_packaged)
- log(LOG_NOTICE, LD_HEARTBEAT, "Average packaged cell fullness: %2.3f%%",
+ log_notice(LD_HEARTBEAT, "Average packaged cell fullness: %2.3f%%",
100*(U64_TO_DBL(stats_n_data_bytes_packaged) /
U64_TO_DBL(stats_n_data_cells_packaged*RELAY_PAYLOAD_SIZE)) );
diff --git a/src/tools/tor-gencert.c b/src/tools/tor-gencert.c
index c68aaa747..d2057ea92 100644
--- a/src/tools/tor-gencert.c
+++ b/src/tools/tor-gencert.c
@@ -82,10 +82,10 @@ crypto_log_errors(int severity, const char *doing)
if (!lib) lib = "(null)";
if (!func) func = "(null)";
if (doing) {
- log(severity, LD_CRYPTO, "crypto error while %s: %s (in %s:%s)",
+ tor_log(severity, LD_CRYPTO, "crypto error while %s: %s (in %s:%s)",
doing, msg, lib, func);
} else {
- log(severity, LD_CRYPTO, "crypto error: %s (in %s:%s)", msg, lib, func);
+ tor_log(severity, LD_CRYPTO, "crypto error: %s (in %s:%s)", msg, lib, func);
}
}
}