From 651cf26f1ceeb683e9a069017225b27c6d6360bd Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Mon, 20 Sep 2004 02:51:50 +0000 Subject: auto table names for massVirtualhosting swap - with _ added 'V' logformat to log virtualhost according to canonical setting. --- CHANGELOG | 7 +++++++ Makefile.in | 6 +++--- TODO.in | 4 +++- configure.ac | 4 +++- functions.h | 7 ++++++- mod_log_sql.c | 59 +++++++++++++++++++++++++++++++---------------------------- 6 files changed, 53 insertions(+), 34 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9bcc20a..ca767f8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,10 @@ +1.100: 2004-09-?f +* fixes for NULL fields (empty request_args) +* fixed a mysql reconnect bug +* wrong hostname was logged when using mass virtual hosting + Use, the new 'V' logformat +* formatted massvirutalhosting tables to swap - with _. + 1.99: 2004-07-28 * Added DBI support (not completed yet) * fixed segfault in the mysql driver escape_string function diff --git a/Makefile.in b/Makefile.in index a08ec1b..0a7b9be 100644 --- a/Makefile.in +++ b/Makefile.in @@ -73,13 +73,13 @@ PROVIDERS_SUBDIRS = @subdirs@ srcdir = @abs_srcdir@ builddir = @abs_builddir@ -OBJ = $(SOURCES:.c=.o) $(sslSOURCES:.c=.o) $(mysqlSOURCES:.c=.o) \ +OBJ = $(coreSOURCES:.c=.o) $(sslSOURCES:.c=.o) $(mysqlSOURCES:.c=.o) \ $(dbiSOURCES:.c=.o) $(pgsqlSOURCES:.c=.o) -LO = $(SOURCES:.c=.lo) $(sslSOURCES:.c=.lo) $(mysqlSOURCES:.c=.lo) \ +LO = $(coreSOURCES:.c=.lo) $(sslSOURCES:.c=.lo) $(mysqlSOURCES:.c=.lo) \ $(dbiSOURCES:.c=.lo) $(pgsqlSOURCES:.c=.lo) -SLO = $(SOURCES:.c=.slo) $(sslSOURCES:.c=.slo) $(mysqlSOURCES:.c=.slo) \ +SLO = $(coreSOURCES:.c=.slo) $(sslSOURCES:.c=.slo) $(mysqlSOURCES:.c=.slo) \ $(dbiSOURCES:.c=.slo) $(pgsqlSOURCES:.c=.slo) STD_DIST = install-sh \ diff --git a/TODO.in b/TODO.in index 12bb30c..2686a44 100644 --- a/TODO.in +++ b/TODO.in @@ -1,4 +1,6 @@ TODO: +* verify a db driver has been loaded. +* validate table names before trying to log them. * write alternate DB driver (PostgreSQL, libDBI, mod_*_pool) * look at forcing table name to ServerName instead of on of the names in ServerAlias? @@ -9,7 +11,7 @@ TODO: * investigate thread safety issues Use libmysqlclient_r for threaded MPM (or always?) Add thread locks if using standard mysqlclient - Check locking issues with the preserve file? + Check locking issues with the preserve file * rewrite main core logging function to optimize for speed. * Clean up table creation code. support DB independent way of defining the tables diff --git a/configure.ac b/configure.ac index 322cde2..7dd9489 100644 --- a/configure.ac +++ b/configure.ac @@ -26,6 +26,7 @@ CHECK_MYSQL( AC_MSG_WARN([*** Mysql client libraries not found!]) WANT_MYSQL_MOD=0 ) + AC_SUBST(WANT_MYSQL_MOD) CHECK_LIBDBI(WANT_DBI_MOD=1, @@ -41,9 +42,10 @@ AC_SUBST(WANT_PGSQL_MOD) CHECK_MOD_SSL( WANT_SSL_MOD=1, - AC_MSG_ERROR([** mod_ssl.h not found or missing SSL headers!]) + AC_MSG_WARN([** mod_ssl.h not found or missing SSL headers!]) WANT_SSL_MOD=0 ) + AC_SUBST(WANT_SSL_MOD) case "$target" in diff --git a/functions.h b/functions.h index dcbc939..b35634a 100644 --- a/functions.h +++ b/functions.h @@ -99,7 +99,12 @@ static const char *extract_status(request_rec *r, char *a) static const char *extract_virtual_host(request_rec *r, char *a) { - return apr_pstrdup(r->pool, r->server->server_hostname); + return r->server->server_hostname; +} + +static const char *extract_server_name(request_rec *r, char *a) +{ + return ap_get_server_name(r); } static const char *extract_machine_id(request_rec *r, char *a) diff --git a/mod_log_sql.c b/mod_log_sql.c index 7aaa595..13a7eb8 100644 --- a/mod_log_sql.c +++ b/mod_log_sql.c @@ -464,35 +464,36 @@ static int log_sql_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptem static void log_sql_module_init(server_rec *s, apr_pool_t *p) #endif { - /* TODO: Add local_address, remote_address, server_name, connection_status */ - /* Register handlers */ - log_sql_register_item(s,p,'A', extract_agent, "agent", 1, 1); - log_sql_register_item(s,p,'a', extract_request_query, "request_args", 1, 1); - log_sql_register_item(s,p,'b', extract_bytes_sent, "bytes_sent", 0, 0); + /* TODO: Add local_address, remote_address, server_name, connection_status */ + /* Register handlers */ + log_sql_register_item(s,p,'A', extract_agent, "agent", 1, 1); + log_sql_register_item(s,p,'a', extract_request_query, "request_args", 1, 1); + log_sql_register_item(s,p,'b', extract_bytes_sent, "bytes_sent", 0, 0); log_sql_register_item(s,p,'c', extract_cookie, "cookie", 0, 1); - /* TODO: Document */ + /* TODO: Document */ log_sql_register_item(s,p,'f', extract_request_file, "request_file", 0, 1); - log_sql_register_item(s,p,'H', extract_request_protocol, "request_protocol", 0, 1); - log_sql_register_item(s,p,'h', extract_remote_host, "remote_host", 0, 1); - log_sql_register_item(s,p,'I', extract_unique_id, "id", 0, 1); - log_sql_register_item(s,p,'l', extract_remote_logname, "remote_logname", 0, 1); - log_sql_register_item(s,p,'m', extract_request_method, "request_method", 0, 1); - log_sql_register_item(s,p,'M', extract_machine_id, "machine_id", 0, 1); - log_sql_register_item(s,p,'P', extract_child_pid, "child_pid", 0, 0); - log_sql_register_item(s,p,'p', extract_server_port, "server_port", 0, 0); - log_sql_register_item(s,p,'R', extract_referer, "referer", 1, 1); - log_sql_register_item(s,p,'r', extract_request_line, "request_line", 1, 1); - log_sql_register_item(s,p,'S', extract_request_timestamp, "time_stamp", 0, 0); - log_sql_register_item(s,p,'s', extract_status, "status", 1, 0); - log_sql_register_item(s,p,'T', extract_request_duration, "request_duration", 1, 0); - log_sql_register_item(s,p,'t', extract_request_time, "request_time", 0, 1); - log_sql_register_item(s,p,'u', extract_remote_user, "remote_user", 0, 1); - log_sql_register_item(s,p,'U', extract_request_uri, "request_uri", 1, 1); - log_sql_register_item(s,p,'v', extract_virtual_host, "virtual_host", 0, 1); - - if (global_config.announce) { - ap_add_version_component(p, PACKAGE_NAME"/"PACKAGE_VERSION); - } + log_sql_register_item(s,p,'H', extract_request_protocol, "request_protocol", 0, 1); + log_sql_register_item(s,p,'h', extract_remote_host, "remote_host", 0, 1); + log_sql_register_item(s,p,'I', extract_unique_id, "id", 0, 1); + log_sql_register_item(s,p,'l', extract_remote_logname, "remote_logname", 0, 1); + log_sql_register_item(s,p,'m', extract_request_method, "request_method", 0, 1); + log_sql_register_item(s,p,'M', extract_machine_id, "machine_id", 0, 1); + log_sql_register_item(s,p,'P', extract_child_pid, "child_pid", 0, 0); + log_sql_register_item(s,p,'p', extract_server_port, "server_port", 0, 0); + log_sql_register_item(s,p,'R', extract_referer, "referer", 1, 1); + log_sql_register_item(s,p,'r', extract_request_line, "request_line", 1, 1); + log_sql_register_item(s,p,'S', extract_request_timestamp, "time_stamp", 0, 0); + log_sql_register_item(s,p,'s', extract_status, "status", 1, 0); + log_sql_register_item(s,p,'T', extract_request_duration, "request_duration", 1, 0); + log_sql_register_item(s,p,'t', extract_request_time, "request_time", 0, 1); + log_sql_register_item(s,p,'u', extract_remote_user, "remote_user", 0, 1); + log_sql_register_item(s,p,'U', extract_request_uri, "request_uri", 1, 1); + log_sql_register_item(s,p,'v', extract_virtual_host, "virtual_host", 0, 1); + log_sql_register_item(s,p,'V', extract_server_name, "virtual_host", 0, 1); + + if (global_config.announce) { + ap_add_version_component(p, PACKAGE_NAME"/"PACKAGE_VERSION); + } /* ap_server_root_relative any default preserve file locations */ { server_rec *cur_s; @@ -798,12 +799,14 @@ static int log_sql_transaction(request_rec *orig) char *cookie_base = "cookies_"; - /* Determint the hostname and convert it to all lower-case; */ + /* Determine the hostname and convert it to all lower-case; */ char *servername = apr_pstrdup(orig->pool,(char *)ap_get_server_name(orig)); + char *p=servername; while (*p) { *p = apr_tolower(*p); if (*p == '.') *p = '_'; + if (*p == '-') *p = '_'; ++p; } -- cgit