diff --git a/common.c b/common.c index 4d85a20..3c51397 100644 --- a/common.c +++ b/common.c @@ -503,7 +503,7 @@ char* sprintaddr(char* buf, size_t size, struct addrinfo *a) cfg.numeric ? NI_NUMERICHOST | NI_NUMERICSERV : 0 ); if (res) { - log_message(LOG_ERR, "sprintaddr:getnameinfo: %s\n", gai_strerror(res)); + print_message(msg_system_error, "sprintaddr:getnameinfo: %s\n", gai_strerror(res)); /* Name resolution failed: do it numerically instead */ res = getnameinfo(a->ai_addr, a->ai_addrlen, host, sizeof(host), @@ -511,7 +511,7 @@ char* sprintaddr(char* buf, size_t size, struct addrinfo *a) NI_NUMERICHOST | NI_NUMERICSERV); /* should not fail but... */ if (res) { - log_message(LOG_ERR, "sprintaddr:getnameinfo(NUM): %s\n", gai_strerror(res)); + print_message(msg_system_error, "sprintaddr:getnameinfo(NUM): %s\n", gai_strerror(res)); strcpy(host, "?"); strcpy(serv, "?"); } @@ -549,7 +549,7 @@ int resolve_split_name(struct addrinfo **out, char* host, char* serv) res = getaddrinfo(host, serv, &hint, out); if (res) - log_message(LOG_ERR, "%s `%s:%s'\n", gai_strerror(res), host, serv); + print_message(msg_system_error, "%s `%s:%s'\n", gai_strerror(res), host, serv); return res; } diff --git a/common.h b/common.h index 9235699..acb1bd3 100644 --- a/common.h +++ b/common.h @@ -47,7 +47,7 @@ #define CHECK_RES_RETURN(res, str, ret) \ if (res == -1) { \ - log_message(LOG_CRIT, "%s:%d:%s:%d:%s\n", __FILE__, __LINE__, str, errno, strerror(errno)); \ + print_message(msg_system_error, "%s:%d:%s:%d:%s\n", __FILE__, __LINE__, str, errno, strerror(errno)); \ return ret; \ } diff --git a/log.c b/log.c index e83465a..00a25a0 100644 --- a/log.c +++ b/log.c @@ -146,24 +146,6 @@ void setup_syslog(const char* bin_name) { } -/* Log to syslog or stderr if foreground */ -void log_message(int type, const char* msg, ...) -{ - va_list ap; - - va_start(ap, msg); - if (cfg.foreground) - vfprintf(stderr, msg, ap); - va_end(ap); - - if (do_syslog) { - va_start(ap, msg); - vsyslog(type, msg, ap); - va_end(ap); - } -} - - /* syslogs who connected to where * desc: string description of the connection. if NULL, log_connection will * manage on its own @@ -181,7 +163,7 @@ void log_connection(struct connection_desc* desc, const struct connection *cnx) get_connection_desc(desc, cnx); } - log_message(LOG_INFO, "%s:connection from %s to %s forwarded from %s to %s\n", + print_message(msg_connections, "%s:connection from %s to %s forwarded from %s to %s\n", cnx->proto->name, desc->peer, desc->service,