debian/0000755000000000000000000000000011576472015007176 5ustar debian/control0000644000000000000000000000223611576471517010612 0ustar Source: libapache-dbilogger-perl Section: perl Priority: optional Build-Depends: debhelper (>= 8) Build-Depends-Indep: libapache-dbi-perl, libapache2-mod-perl2, libdbi-perl, libtimedate-perl, perl Maintainer: Debian Perl Group Uploaders: gregor herrmann , Fabrizio Regalli Standards-Version: 3.9.2 Homepage: http://search.cpan.org/dist/Apache-DBILogger/ Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libapache-dbilogger-perl/ Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libapache-dbilogger-perl/ Package: libapache-dbilogger-perl Architecture: all Depends: ${misc:Depends}, ${perl:Depends}, libapache-dbi-perl, libapache2-mod-perl2, libdbi-perl, libtimedate-perl Description: Perl module for tracking what's being transferred in a DBI database Apache::DBILogger tracks what's being transfered by the Apache web server in a SQL database (everything with a DBI/DBD driver). This allows one to get statistics (of almost everything) without having to parse the log files (like the Apache::Traffic module, just in a "real" database, and with a lot more logged information). debian/copyright0000644000000000000000000000233611575702460011134 0ustar Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=135 Maintainer: Ask Bjoern Hansen Source: http://search.cpan.org/dist/Apache-DBILogger/ Name: Apache-DBILogger Files: * Copyright: 1998, Ask Bjoern Hansen License: Artistic or GPL-1+ Files: debian/* Copyright: 1998, 1999, 2001, 2004, Michael Alan Dorman 2004, 2005, 2006, 2007, Gunnar Wolf 2006, 2007, 2008, gregor herrmann 2011, Fabrizio Regalli License: Artistic or GPL-1+ License: Artistic This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License, which comes with Perl. . On Debian systems, the complete text of the Artistic License can be found in `/usr/share/common-licenses/Artistic'. License: GPL-1+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. . On Debian systems, the complete text of version 1 of the GNU General Public License can be found in `/usr/share/common-licenses/GPL-1'. debian/watch0000644000000000000000000000017311212456153010220 0ustar version=3 http://search.cpan.org/dist/Apache-DBILogger/ .*/Apache-DBILogger-v?(\d[\d.]+)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip) debian/patches/0000755000000000000000000000000011576472015010625 5ustar debian/patches/apache2.patch0000644000000000000000000001420311576471744013161 0ustar Description: Ported the module to correctly work under Apache 2.x / mod_perl 2.x, as it is API-incompatible Author: Gunnar Wolf Bug-Debian: http://bugs.debian.org/397491 Last-Update: 2007-05-01 Forwarded: unknown --- a/DBILogger.pm +++ b/DBILogger.pm @@ -2,7 +2,25 @@ package Apache::DBILogger; require 5.004; use strict; -use Apache::Constants qw( :common ); +# use Apache::Constants qw( :common ); +# In order to make this module compatible with either Apache 1.3.x or 2.2.x, +# for which mod_perl has slightly different APIs, this BEGIN block serves the +# same purpose as the previous 'use Apache::Constants qw(:common)' statement. +my $modperl2; +BEGIN { + eval "use Apache::Constants qw(:common);"; + if ($@) { + eval "use Apache2::Const qw(:common); + use APR::Pool; + use APR::Table; + use Apache2::Connection; + use APR::SockAddr;"; + $modperl2 = 1; + if ($@) { + die "Not under Apache, not under Apache2?\n$@"; + } + } +} use DBI; use Date::Format; @@ -25,30 +43,12 @@ sub reconnect($$) { } sub logger { - my $r = shift->last; + my $r = _get_req(shift); my $s = $r->server; my $c = $r->connection; - my %data = ( - 'server' => $s->server_hostname, - 'bytes' => $r->bytes_sent, - 'filename' => $r->filename || '', - 'remotehost'=> $c->remote_host || '', - 'remoteip' => $c->remote_ip || '', - 'status' => $r->status || '', - 'urlpath' => $r->uri || '', - 'referer' => $r->header_in("Referer") || '', - 'useragent' => $r->header_in('User-Agent') || '', - 'timeserved'=> time2str("%Y-%m-%d %X", time), - 'contenttype' => $r->content_type || '' - ); - - if (my $user = $c->user) { - $data{user} = $user; - } - - $data{usertrack} = $r->notes('cookie') || ''; + my %data = _get_data($r); my $dbh = DBI->connect($r->dir_config("DBILogger_data_source"), $r->dir_config("DBILogger_username"), $r->dir_config("DBILogger_password")); @@ -57,16 +57,12 @@ sub logger { return DECLINED; } - my @valueslist; - - foreach (keys %data) { - $data{$_} = $dbh->quote($data{$_}); - push @valueslist, $data{$_}; - } - my $table = $r->dir_config("DBILogger_table") || 'requests'; - my $statement = "insert into $table (". join(',', keys %data) .") VALUES (". join(',', @valueslist) .")"; + my @columns = map($dbh->quote_identifier($_), keys %data); + my @values = map($dbh->quote($_), values %data); + + my $statement = "INSERT INTO $table (" . join(', ', @columns) . ") VALUES (" . join(', ', @values ) . ")"; my $tries = 0; @@ -98,10 +94,75 @@ sub logger { # #perl pun: windows is for users who can't handle the power of the mac. sub handler { - shift->post_connection(\&logger); + _register_logger(shift); +} + +############################################################ +# Multi-API compatibility functions follow +# +# _register_logger, _get_req and _get_data should take care of handling the +# incompatibility between the mod_perl 1.x and 2.x APIs. They should do exactly +# the same, although in a different way; they are based on +# http://perl.apache.org/docs/2.0/user/porting/compat.html +# +# For any bugs regarding this code, please contact Gunnar Wolf +# . +sub _register_logger { + my $r = shift; + if ($modperl2) { + $r->pool->cleanup_register(\&logger, $r); + } else { + $r->post_connection(\&logger); + } return OK; } +sub _get_req { + return $modperl2 ? shift : shift->last; +} + +sub _get_data { + my ($r, $s, $c, %data); + $r = shift; + $s = $r->server; + $c = $r->connection; + + if ($modperl2) { + %data = ( + 'server' => $s->server_hostname, + 'bytes' => $r->bytes_sent, + 'filename' => $r->filename || '', + 'remotehost' => $c->get_remote_host || '', + 'remoteip' => $c->remote_addr->ip_get || '', + 'status' => $r->status || '', + 'urlpath' => $r->uri || '', + 'referer' => $r->headers_in->{'Referer'} || '', + 'useragent' => $r->headers_in->{'User-Agent'} || '', + 'timeserved' => time2str("%Y-%m-%d %X", time), + 'contenttype' => $r->content_type || '', + 'user' => $r->user() || '', + 'usertrack' => $r->notes->get('cookie') || '' + ); + } else { + %data = ( + 'server' => $s->server_hostname, + 'bytes' => $r->bytes_sent, + 'filename' => $r->filename || '', + 'remotehost' => $c->remote_host || '', + 'remoteip' => $c->remote_ip || '', + 'status' => $r->status || '', + 'urlpath' => $r->uri || '', + 'referer' => $r->header_in("Referer") || '', + 'useragent' => $r->header_in('User-Agent') || '', + 'timeserved' => time2str("%Y-%m-%d %X", time), + 'contenttype' => $r->content_type || '', + 'user' => $c->user || '', + 'usertrack' => $r->notes('cookie') || '' + ); + } + return %data; +} + 1; __END__ @@ -139,6 +200,10 @@ CREATE TABLE requests ( KEY timeserved_idx (timeserved) ); +Please note that for some databases (notably, PostgreSQL) you will need to +double-quote the user column name (that is, to specify it as C<"user" +varchar(15)>) in order for the database not to mistake it with a keyword. + Its recommended that you include use Apache::DBI; @@ -267,6 +332,19 @@ work fine with Apache::DBI. You might get problems with Apache 1.2.x. (Not supporting post_connection?) +=head1 MOD_PERL 2 SUPPORT + +The official version of this module, as Ask Bjoern Hansen last modified +it, lacks support for the API changes introduced with Apache 2.x and +the corresponding mod_perl 2.x - Of course, this is quite understandable +as this module was last updated in 1998 ;-) But anyway, the module does its +job still quite fine, and users still require its functionality. + +For any help requests regarding this module on Apache 2 systems, contact +Gunnar Wolf directly. If your system is based on Debian +GNU/Linux, you can use the regular Debian bugtracking facilities, as the +multi-API patch was introduced specifically for Debian. + =head1 SUPPORT This module is supported via the mod_perl mailinglist debian/patches/fix_manpage0000644000000000000000000000111511576452601013023 0ustar Description: Fixing man page Author: Fabrizio Regalli Last-Update: 2010-11-10 Forwarded: no --- a/DBILogger.pm +++ b/DBILogger.pm @@ -151,7 +151,7 @@ =head1 DESCRIPTION This module tracks what's being transfered by the Apache web server in a -SQL database (everything with a DBI/DBD driver). This allows to get +SQL database (everything with a DBI/DBD driver). This allows one to get statistics (of almost everything) without having to parse the log files (like the Apache::Traffic module, just in a "real" database, and with a lot more logged information). debian/patches/series0000644000000000000000000000003211576452601012034 0ustar fix_manpage apache2.patch debian/compat0000644000000000000000000000000211575702460010373 0ustar 8 debian/changelog0000644000000000000000000001010311576452601011042 0ustar libapache-dbilogger-perl (0.93-12) unstable; urgency=low [ gregor herrmann ] * debian/control: Changed: Switched Vcs-Browser field to ViewSVN (source stanza). * debian/control: Added: ${misc:Depends} to Depends: field. [ Nathan Handler ] * debian/watch: Update to ignore development releases. [ Fabrizio Regalli ] * Bump to 3.9.2 Standard-Version. * Switch to DEP5 license format. * Add myself to Uploaders. * Switch d/compat to 8. * Build-Depends: switch to debhelper (>= 8). * Bump to 3.0 quilt format. * Email change: gregor herrmann -> gregoa@debian.org -- Fabrizio Regalli Tue, 14 Jun 2011 12:56:13 +0200 libapache-dbilogger-perl (0.93-11) unstable; urgency=low * debian/control: Added: Vcs-Svn field (source stanza); Vcs-Browser field (source stanza); Homepage field (source stanza). Removed: XS- Vcs-Svn fields. * debian/rules: - delete /usr/lib/perl5 only if it exists (closes: #468238) - update with the help of dh-make-perl's templates - don't install README anymore, it's just the text version of the POD documentation * debian/watch: use dist-based URL. * Set Standards-Version to 3.7.3 (no changes). * Set debhelper compatibility level to 6. * Split out Gunnar's fixes for Apache 2.x into apache2.patch; add quilt framework. * debian/copyright: add upstream source location, convert to new format. -- gregor herrmann Fri, 29 Feb 2008 22:26:48 +0100 libapache-dbilogger-perl (0.93-10) unstable; urgency=low * Change (build) dependency from libapache-mod-perl to libapache2-mod-perl2 (closes: #429106). -- gregor herrmann Fri, 15 Jun 2007 22:51:56 +0200 libapache-dbilogger-perl (0.93-9) unstable; urgency=low * Ported the module to correctly work under Apache 2.x / mod_perl 2.x, as it is API-incompatible (Closes: #397491) -- Gunnar Wolf Tue, 01 May 2007 21:36:09 -0500 libapache-dbilogger-perl (0.93-8) unstable; urgency=low * Removed spurious file with a temporary commit message (Closes: #397428) -- Gunnar Wolf Mon, 13 Nov 2006 21:04:08 -0600 libapache-dbilogger-perl (0.93-7) unstable; urgency=low * Moved debhelper to Build-Depends. * Set Standards-Version to 3.7.2 (no changes). * Set Debhelper Compatibility Level to 5. * Removed empty /usr/lib/perl5 from package. -- gregor herrmann Fri, 16 Jun 2006 14:34:59 +0200 libapache-dbilogger-perl (0.93-6) unstable; urgency=low * Documented how the table should be used in PostgreSQL, added a small patch (Thanks, Julian Mehnle!) preventing the problem from happening. (Closes: #41890) -- Gunnar Wolf Mon, 7 Mar 2005 17:15:31 -0600 libapache-dbilogger-perl (0.93-5) unstable; urgency=low * Fixed missing build-depends (Closes: #276292) -- Gunnar Wolf Thu, 14 Oct 2004 12:07:23 -0500 libapache-dbilogger-perl (0.93-4) unstable; urgency=low * New maintainer: Debian Perl Group (Closes: #265760) * Added a 'make test' while building the package * Moved to section: perl -- Gunnar Wolf Mon, 11 Oct 2004 13:55:38 -0500 libapache-dbilogger-perl (0.93-3) unstable; urgency=low * Fix copyright problem (closes: bug#157543) * Orphan the package, making packages@qa.debian.org the maintainer. -- Michael Alan Dorman Mon, 2 Aug 2004 15:36:25 -0400 libapache-dbilogger-perl (0.93-2) unstable; urgency=low * Updated to comply with latest perl policy. (closes: bug#91190, bug#91543) -- Michael Alan Dorman Sun, 15 Apr 2001 15:23:40 -0400 libapache-dbilogger-perl (0.93-1) unstable; urgency=low * New upstream version * Modified for new perl packages. * Updated to use debhelper. -- Michael Alan Dorman Sun, 4 Jul 1999 22:11:56 +0000 libapache-dbilogger-perl (0.92-1) unstable; urgency=low * Initial debianization -- Michael Alan Dorman Tue, 3 Nov 1998 10:20:48 -0500 debian/source/0000755000000000000000000000000011576472015010476 5ustar debian/source/format0000644000000000000000000000001411575702460011703 0ustar 3.0 (quilt) debian/rules0000755000000000000000000000003611575702460010254 0ustar #!/usr/bin/make -f %: dh $@