Put some sense into our logging.

Transform our logging severities to something more sensible.
Remove sneaky printf()s.
This commit is contained in:
George Kadianakis 2011-09-12 00:10:07 +02:00
parent d0416ce3ec
commit 2e73f9b3ee
4 changed files with 44 additions and 42 deletions

View File

@ -3230,7 +3230,7 @@ get_string_from_pipe(FILE *stream, char *buf_out, size_t count)
} else {
/* No newline; check whether we overflowed the buffer */
if (!feof(stream))
log_warn(LD_GENERAL,
log_info(LD_GENERAL,
"Line from stream was truncated: %s", buf_out);
/* TODO: What to do with this error? */
}

View File

@ -4694,18 +4694,18 @@ transport_resolve_conflicts(transport_t *t)
return 1;
} else { /* same name but different addrport */
if (t_tmp->marked_for_removal) { /* marked for removal */
log_warn(LD_GENERAL, "You tried to add transport '%s' at '%s:%u' but "
"there was already a transport marked for deletion at "
"'%s:%u'. We deleted the old transport and registered the "
"new one.", t->name, fmt_addr(&t->addr), t->port,
fmt_addr(&t_tmp->addr), t_tmp->port);
log_notice(LD_GENERAL, "You tried to add transport '%s' at '%s:%u' "
"but there was already a transport marked for deletion at "
"'%s:%u'. We deleted the old transport and registered the "
"new one.", t->name, fmt_addr(&t->addr), t->port,
fmt_addr(&t_tmp->addr), t_tmp->port);
smartlist_remove(transport_list, t_tmp);
transport_free(t_tmp);
} else { /* *not* marked for removal */
log_warn(LD_GENERAL, "You tried to add transport '%s' at '%s:%u' "
"which already exists at '%s:%u'. Skipping.", t->name,
fmt_addr(&t->addr), t->port,
fmt_addr(&t_tmp->addr), t_tmp->port);
log_notice(LD_GENERAL, "You tried to add transport '%s' at '%s:%u' "
"which already exists at '%s:%u'. Skipping.", t->name,
fmt_addr(&t->addr), t->port,
fmt_addr(&t_tmp->addr), t_tmp->port);
return -1;
}
}
@ -4753,17 +4753,17 @@ transport_add_from_config(const tor_addr_t *addr, uint16_t port,
switch (r) {
case -1:
default:
log_warn(LD_GENERAL, "Could not add transport %s at %s:%u. Skipping.",
t->name, fmt_addr(&t->addr), t->port);
log_notice(LD_GENERAL, "Could not add transport %s at %s:%u. Skipping.",
t->name, fmt_addr(&t->addr), t->port);
transport_free(t);
return -1;
case 1:
log_warn(LD_GENERAL, "Succesfully registered transport %s at %s:%u.",
log_info(LD_GENERAL, "Succesfully registered transport %s at %s:%u.",
t->name, fmt_addr(&t->addr), t->port);
transport_free(t); /* falling */
return 0;
case 0:
log_warn(LD_GENERAL, "Succesfully registered transport %s at %s:%u.",
log_info(LD_GENERAL, "Succesfully registered transport %s at %s:%u.",
t->name, fmt_addr(&t->addr), t->port);
return 0;
}

View File

@ -4772,8 +4772,8 @@ parse_client_transport_line(const char *line, int validate_only)
if (!validate_only) {
transport_add_from_config(&addr, port, name, socks_ver);
log_debug(LD_DIR, "Transport '%s' found at %s:%d", name,
fmt_addr(&addr), (int)port);
log_info(LD_DIR, "Transport '%s' found at %s:%d", name,
fmt_addr(&addr), (int)port);
}
}
@ -4871,7 +4871,7 @@ parse_server_transport_line(const char *line, int validate_only)
}
if (!validate_only) {
log_warn(LD_DIR, "Transport '%s' at %s:%d.", name,
log_info(LD_DIR, "Server transport '%s' at %s:%d.", name,
fmt_addr(&addr), (int)port);
}
}
@ -5886,11 +5886,11 @@ save_transport_to_state(const char *transport,
/* if transport in state has the same address as this one, life is good */
if (!strcmp(prev_bindaddr, transport_addrport)) {
log_warn(LD_CONFIG, "Transport seems to have spawned on its usual "
log_info(LD_CONFIG, "Transport seems to have spawned on its usual "
"address:port.");
goto done;
} else { /* addrport in state is different than the one we got */
log_warn(LD_CONFIG, "Transport seems to have spawned on different "
log_info(LD_CONFIG, "Transport seems to have spawned on different "
"address:port. Let's update the state file with the new "
"address:port");
tor_free(transport_line->value); /* free the old line */
@ -5899,7 +5899,7 @@ save_transport_to_state(const char *transport,
(int) port); /* replace old addrport line with new line */
}
} else { /* never seen this one before; save it in state for next time */
log_warn(LD_CONFIG, "It's the first time we see this transport. "
log_info(LD_CONFIG, "It's the first time we see this transport. "
"Let's save its address:port");
next = &state->TransportProxies;
/* find the last TransportProxy line in the state and point 'next'

View File

@ -268,7 +268,8 @@ launch_managed_proxy(managed_proxy_t *mp)
&stderr_pipe, (const char **)mp->argv,
(const char **)envp);
if (pid < 0) {
log_warn(LD_GENERAL, "Spawn failed");
log_warn(LD_GENERAL, "Managed proxy at '%s' failed at launch.",
mp->argv[0]);
return -1;
}
@ -280,7 +281,7 @@ launch_managed_proxy(managed_proxy_t *mp)
/* Open the buffered IO streams */
stdout_read = fdopen(stdout_pipe, "r");
log_warn(LD_CONFIG, "The spawn is alive (%d)!", pid);
log_info(LD_CONFIG, "Managed proxy has spawned at PID %d.", pid);
mp->conf_state = PT_PROTO_LAUNCHED;
mp->stdout = stdout_read;
@ -295,8 +296,8 @@ launch_managed_proxy(managed_proxy_t *mp)
void
pt_configure_remaining_proxies(void)
{
log_warn(LD_CONFIG, "We start configuring remaining managed proxies (%d)!",
unconfigured_proxies_n);
log_debug(LD_CONFIG, "Configuring remaining managed proxies (%d)!",
unconfigured_proxies_n);
SMARTLIST_FOREACH_BEGIN(managed_proxy_list, managed_proxy_t *, mp) {
tor_assert(mp->conf_state != PT_PROTO_BROKEN);
@ -306,10 +307,12 @@ pt_configure_remaining_proxies(void)
/* This proxy is marked by a SIGHUP. Check whether we need to
restart it. */
if (proxy_needs_restart(mp)) {
log_info(LD_GENERAL, "Preparing managed proxy for restart.");
proxy_prepare_for_restart(mp);
continue;
} else { /* it doesn't need to be restarted. */
printf("No need for restart; status quo\n");
log_info(LD_GENERAL, "Nothing changed for managed proxy after HUP: "
"not restarting.");
unconfigured_proxies_n--;
tor_assert(unconfigured_proxies_n >= 0);
}
@ -349,11 +352,11 @@ configure_proxy(managed_proxy_t *mp)
} else if (r == IO_STREAM_EAGAIN) { /* check back later */
return;
} else if (r == IO_STREAM_CLOSED || r == IO_STREAM_TERM) { /* snap! */
log_warn(LD_GENERAL, "Managed proxy stream closed. "
"Most probably application stopped running");
log_notice(LD_GENERAL, "Managed proxy stream closed. "
"Most probably application stopped running");
mp->conf_state = PT_PROTO_BROKEN;
} else { /* unknown stream status */
log_warn(LD_GENERAL, "Unknown stream status while configuring proxy.");
log_notice(LD_GENERAL, "Unknown stream status while configuring proxy.");
}
/* if the proxy finished configuring, exit the loop. */
@ -398,15 +401,15 @@ register_client_proxy(managed_proxy_t *mp)
r = transport_add(t);
switch (r) {
case -1:
log_warn(LD_GENERAL, "Could not add transport %s. Skipping.", t->name);
log_notice(LD_GENERAL, "Could not add transport %s. Skipping.", t->name);
transport_free(t);
break;
case 0:
log_warn(LD_GENERAL, "Succesfully registered transport %s", t->name);
log_info(LD_GENERAL, "Succesfully registered transport %s", t->name);
smartlist_add(sm_tmp, tor_strdup(t->name));
break;
case 1:
log_warn(LD_GENERAL, "Succesfully registered transport %s", t->name);
log_info(LD_GENERAL, "Succesfully registered transport %s", t->name);
smartlist_add(sm_tmp, tor_strdup(t->name));
transport_free(t);
break;
@ -431,7 +434,6 @@ register_proxy(managed_proxy_t *mp)
static void
managed_proxy_destroy(managed_proxy_t *mp)
{
printf("Destroying mp %p\n", mp);
if (mp->conf_state != PT_PROTO_COMPLETED)
SMARTLIST_FOREACH(mp->transports, transport_t *, t, transport_free(t));
else
@ -503,10 +505,10 @@ handle_methods_done(const managed_proxy_t *mp)
tor_assert(mp->transports);
if (smartlist_len(mp->transports) == 0)
log_warn(LD_GENERAL, "Proxy was spawned successfully, "
"but it didn't laucn any pluggable transport listeners!");
log_notice(LD_GENERAL, "Proxy was spawned successfully, "
"but it didn't laucn any pluggable transport listeners!");
log_warn(LD_CONFIG, "%s managed proxy configuration completed!",
log_info(LD_CONFIG, "%s managed proxy configuration completed!",
mp->is_server ? "Server" : "Client");
}
@ -515,7 +517,7 @@ handle_methods_done(const managed_proxy_t *mp)
void
handle_proxy_line(const char *line, managed_proxy_t *mp)
{
printf("Judging line: %s\n", line);
log_debug(LD_GENERAL, "Got a line from managed proxy: %s\n", line);
if (strlen(line) < SMALLEST_MANAGED_LINE_SIZE) {
log_warn(LD_GENERAL, "Managed proxy configuration line is too small. "
@ -609,8 +611,8 @@ parse_env_error(const char *line)
/* (Length of the protocol string) plus (a space) and (the first char of
the error message) */
if (strlen(line) < (strlen(PROTO_ENV_ERROR) + 2))
log_warn(LD_CONFIG, "Managed proxy sent us an %s without an error "
"message.", PROTO_ENV_ERROR);
log_notice(LD_CONFIG, "Managed proxy sent us an %s without an error "
"message.", PROTO_ENV_ERROR);
log_warn(LD_CONFIG, "Managed proxy couldn't understand the "
"pluggable transport environment variables. (%s)",
@ -628,8 +630,8 @@ parse_version(const char *line, managed_proxy_t *mp)
return -1;
}
if (strcmp("1", line+strlen(PROTO_NEG_SUCCESS)+1)) {
log_warn(LD_CONFIG, "We don't support version '%s'. "
if (strcmp("1", line+strlen(PROTO_NEG_SUCCESS)+1)) { /* hardcoded temp */
log_warn(LD_CONFIG, "Managed proxy tried to negotiate on version '%s'. "
"We only support version '1'", line+strlen(PROTO_NEG_SUCCESS)+1);
return -1;
}
@ -713,7 +715,7 @@ parse_smethod_line(const char *line, managed_proxy_t *mp)
/* For now, notify the user so that he knows where the server
transport is listening. */
log_warn(LD_CONFIG, "Server transport %s at %s:%d.",
log_info(LD_CONFIG, "Server transport %s at %s:%d.",
method_name, fmt_addr(&addr), (int)port);
r=0;
@ -796,7 +798,7 @@ parse_cmethod_line(const char *line, managed_proxy_t *mp)
smartlist_add(mp->transports, transport);
log_warn(LD_CONFIG, "Transport %s at %s:%d with SOCKS %d. "
log_info(LD_CONFIG, "Transport %s at %s:%d with SOCKS %d. "
"Attached to managed proxy.",
method_name, fmt_addr(&addr), (int)port, socks_ver);