]> ruderich.org/simon Gitweb - tlsproxy/tlsproxy.git/blobdiff - src/connection.c
src/: Move log related functions/defines to log.[hc].
[tlsproxy/tlsproxy.git] / src / connection.c
index 8e023fe551718c75359a5d9f70d48fa82c00e782..7ea6eb24a7573dd14d5d21facf89a06dc2546c9d 100644 (file)
 #include <poll.h>
 /* errno */
 #include <errno.h>
-/* va_*() */
-#include <stdarg.h>
-/* pthread_*() */
-#include <pthread.h>
 
 
 /* Maximum line of a HTTP request line. Longer request lines are aborted with
 #define PROXY_CA_FILE  "proxy-ca.pem"
 #define PROXY_KEY_FILE "proxy-key.pem"
 
-/* Helper macro for LOG/LOG_PERROR. Print file/line number if compiled with
- * debug output. */
-#ifdef DEBUG
-#define LOG_PRINT_LOCATION fprintf(stdout, "%s:%-3d ", __FILE__, __LINE__);
-#else
-#define LOG_PRINT_LOCATION
-#endif
-/* Call log_message() and print current file and line number. */
-#define LOG \
-    LOG_PRINT_LOCATION \
-    log_message
-/* perror() replacement with debug level support. */
-#define LOG_PERROR(level, message) \
-    LOG_PRINT_LOCATION \
-    log_message(level, "%s: %s", message, strerror(errno))
-
 
 static int initialize_tls_session_client(int peer_socket,
         const char *hostname,
@@ -86,8 +66,6 @@ static int connect_to_host(const char *hostname, const char *port);
 static int parse_request(const char *buffer, char *host, char *port,
                                              int *version_minor);
 
-static void log_message(int level, const char *format, ...);
-
 
 void handle_connection(int client_socket) {
     int server_socket;
@@ -736,26 +714,3 @@ static int parse_request(const char *request, char *host, char *port,
 
     return 0;
 }
-
-
-static void log_message(int level, const char *format, ...) {
-    va_list ap;
-    const char *level_string;
-
-    if (global_log_level < level) {
-        return;
-    }
-
-    switch (level) {
-        case LOG_ERROR:   level_string = "ERROR"; break;
-        case LOG_WARNING: level_string = "WARN "; break;
-        case LOG_DEBUG:   level_string = "DEBUG"; break;
-        default:          level_string = "UNKNOWN";
-    }
-
-    va_start(ap, format);
-    fprintf(stdout, "[%s] [%d] ", level_string, (int)pthread_self());
-    vfprintf(stdout, format, ap);
-    fprintf(stdout, "\n");
-    va_end(ap);
-}