I've searched the web and this mailing list for the answer to this
question. I've found several places that seem to hover around the
answer (including a PDF of chapter 16 of the mod_perl cookbook) but I
can't figure out how to implement it in my code. BTW, I don't own the
mod_perl cookbook and am desperately short on money right now, so
buying the book would be a difficult next step.
I'm writing a custom log which will do all sorts of fun, fancy stuff
for me. I had little difficulty getting the URI, status and other
request information and storing it into a database. Here's my log
handler so far - it just grabs some information and puts it into a
database, I haven't gotten to the fancy parts yet:
package MyProject::ModPerl::Log;
use strict;
use warnings;
use Apache2::RequestRec ();
use Apache2::Connection ();
use Apache2::Const -compile => qw(OK DECLINED);
use DBI;
# handler
sub handler {
my ($r) = @_;
my ($dbh, $sql);
# open database
$dbh = DBI->connect("dbi:SQLite:dbname=/my/log/path") or die
$DBI::errstr;
# insert record
$sql = "insert into events (uri, status, msg) values (?, ?, ?)";
$dbh->do($sql, undef, $r->uri, $r->status, 'STDERR here');
$DBI::err and die "db err: $DBI::err: $DBI::errstr";
# return OK
return Apache2::Const::OK;
}
# return true
1;
So far so good, it adds the information I've got to the database quite
nicely. But the one more thing I really need is all the STDERR that
was generated while processing the request. Recipe 6.10 provides a
method for outputting STDERR to a different file but I'd like to grab
it and put it into my database.
What would be a good way to do this? Thanks for any help!
Tom