Raymond Sundland | 10 Apr 2007 22:49

Patch to use ServerName when using LogSQLMassVirtualHosting option

Hi,

 

Since there does not seem to be much activity, I do not know how far this email will go.  I started to use mod_log_sql recently on my FreeBSD box and noticed the LogSQLMassVirtualHosting option used the hostname of the request host (equivalent to the server’s HTTP_HOST variable) to create it’s dynamic tables.  After conferring with someone on IRC who also used mod_log_sql, I wrote a small patch that will provide an option for either using the HTTP_HOST for the table name or the ServerName defined in your httpd.conf or VirtualHost configuration.

 

Basically, I created a new option called LogSQLUseServerName which can be set to either on or off.  Off is the default and replicates the current behavior.  On will make it use ServerName to create your tables.

 

Patch as follows (use patch –p0 < patch) to apply to source.  I wrote this patch from 101 so it may not work with earlier versions.  Disclaimer:  I am not a C developer, only a part time code hacker so the code may not be 100% sane (but I believe it is).  Use at your own risk.  Feel free to “fix” if necessary, just do us all a favor and give it back to us.

 

Thanks.

 

--- mod_log_sql.c.old  Mon Nov  6 18:43:23 2006+++ mod_log_sql.c      Sun Apr  8 22:24:49 2007 <at> <at> -55,6 +55,7 <at> <at>        int createtables;        int forcepreserve;        int disablepreserve;+       int use_servername;        char *machid;        int announce;        logsql_dbconnection db; <at> <at> -806,7 +807,16 <at> <at>                 /* Determine the hostname and convert it to all lower-case; */-              char *servername = apr_pstrdup(orig->pool,(char *)ap_get_server_name(orig));+              char *servername;+              if( global_config.use_servername ) {+                      servername = apr_pstrdup(orig->pool,(char *)orig->server->server_hostname);+                      // log_error(APLOG_MARK,APLOG_ERR,0,orig->server, "use_servername defined in config");+              }+              else {+                      servername = apr_pstrdup(orig->pool,(char *)ap_get_server_name(orig));+              }+              // log_error(APLOG_MARK,APLOG_ERR,0,orig->server, "using servername %s", servername);+                                             char *p=servername;               while (*p) { <at> <at> -1181,6 +1191,11 <at> <at>         (void *)APR_OFFSETOF(global_config_t, machid), RSRC_CONF,         "Machine ID that the module will log, useful in web clusters to differentiate machines")        ,+       /* Use ServerName or the Request Header Name? */+        AP_INIT_FLAG("LogSQLUseServerName", set_global_flag_slot,+         (void *)APR_OFFSETOF(global_config_t, use_servername), RSRC_CONF,+         "Determines whether we are going to use the Virtual Host ServerName to create our tables or the request header")+        ,        /* Limits on logging */        AP_INIT_ITERATE("LogSQLRequestAccept", add_server_string_slot,         (void *)APR_OFFSETOF(logsql_state, transfer_accept_list), RSRC_CONF,

 

_______________________________________________
Download the latest version at http://www.outoforder.cc/projects/apache/mod_log_sql/

To unsubscribe send an e-mail to 
mod_log_sql-unsubscribe@...
Edward Rudd | 11 Apr 2007 01:56
Favicon
Gravatar

Re: Patch to use ServerName when using LogSQLMassVirtualHosting option

Thanks for the patch, I had not had a change yet to reply to your
earlier e-mail.  But I will definitely go through this and add it to the
next release.

Thanks.

Raymond Sundland wrote:
> Hi,
> 
>  
> 
> Since there does not seem to be much activity, I do not know how far
> this email will go.  I started to use mod_log_sql recently on my FreeBSD
> box and noticed the LogSQLMassVirtualHosting option used the hostname of
> the request host (equivalent to the server’s HTTP_HOST variable) to
> create it’s dynamic tables.  After conferring with someone on IRC who
> also used mod_log_sql, I wrote a small patch that will provide an option
> for either using the HTTP_HOST for the table name or the ServerName
> defined in your httpd.conf or VirtualHost configuration.
> 
>  
> 
> Basically, I created a new option called LogSQLUseServerName which can
> be set to either on or off.  Off is the default and replicates the
> current behavior.  On will make it use ServerName to create your tables.
> 
>  
> 
> Patch as follows (use patch –p0 < patch) to apply to source.  I wrote
> this patch from 101 so it may not work with earlier versions. 
> Disclaimer:  I am not a C developer, only a part time code hacker so the
> code may not be 100% sane (but I believe it is).  Use at your own risk. 
> Feel free to “fix” if necessary, just do us all a favor and give it back
> to us.

_______________________________________________
Download the latest version at http://www.outoforder.cc/projects/apache/mod_log_sql/

To unsubscribe send an e-mail to 
mod_log_sql-unsubscribe@...
James Cloos | 23 Apr 2007 21:02
Face
Favicon

configuration using libdbi

When using mod_log_sql with dbi and pgsql, what is the proper syntax for
LogSQLLoginInfo to have it use the unix socket?

Everything else is well documented, but I cannot find any docs on that,
and a perusal of the src didn't enlighten.

Thanks,

-JimC
--

-- 
James Cloos <cloos@...>         OpenPGP: 1024D/ED7DAEA6
_______________________________________________
Download the latest version at http://www.outoforder.cc/projects/apache/mod_log_sql/

To unsubscribe send an e-mail to 
mod_log_sql-unsubscribe@...

Edward Rudd | 24 Apr 2007 03:32
Favicon
Gravatar

Re: configuration using libdbi

According to the libdbi documentation
http://libdbi-drivers.sourceforge.net/docs/dbd_pgsql/options.html

You specify the path to the unix socket as the host.

so

pgsql://user:pass <at> %2fvar%2flib%2fpgsql%2fpgsql.sock/database

Should work and specify a socket of
 /var/lib/pgsql/pgsql.sock

IF that doesn't work you can manually specify the settings using
LogSQLDBParam .. ie.

LogSQLDBParam hostname /var/lib/pgsql/pgsql.sock

James Cloos wrote:
> When using mod_log_sql with dbi and pgsql, what is the proper syntax for
> LogSQLLoginInfo to have it use the unix socket?
> 
> Everything else is well documented, but I cannot find any docs on that,
> and a perusal of the src didn't enlighten.
> 
> Thanks,
> 
> -JimC

_______________________________________________
Download the latest version at http://www.outoforder.cc/projects/apache/mod_log_sql/

To unsubscribe send an e-mail to 
mod_log_sql-unsubscribe@...

Gmane