Return-Path: Delivered-To: apmail-perl-modperl-archive@www.apache.org Received: (qmail 48130 invoked from network); 17 Mar 2009 03:20:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Mar 2009 03:20:38 -0000 Received: (qmail 77249 invoked by uid 500); 17 Mar 2009 03:20:34 -0000 Delivered-To: apmail-perl-modperl-archive@perl.apache.org Received: (qmail 77223 invoked by uid 500); 17 Mar 2009 03:20:34 -0000 Mailing-List: contact modperl-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list modperl@perl.apache.org Received: (qmail 77212 invoked by uid 99); 17 Mar 2009 03:20:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Mar 2009 20:20:34 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of tspencer9@gmail.com designates 74.125.44.154 as permitted sender) Received: from [74.125.44.154] (HELO yx-out-1718.google.com) (74.125.44.154) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Mar 2009 03:20:27 +0000 Received: by yx-out-1718.google.com with SMTP id 3so895128yxi.40 for ; Mon, 16 Mar 2009 20:20:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=di+uzmVd3xHeXPL/B0sMasW9+3U6/9wz1kazOzGuAJc=; b=M8gqqfr1Ak6ZIr2t36V5it4lAYCDc6zHS5CS+VQAZKZyQgzuqfdlUqe82tshVht6yf 4kmU4kCR7/mLWODnijgeEUfxfhCrl+Sq+mssXQVoksVe86MLHXHIjANvdZtOp7DNVveF Dq01MvHuRk2wFjV2fTWWh/jeWumR75ahM04j4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=DpS96WrvGS/0HoVEc9BxbqAKHYYjGB3tuJk00sKsUDU97QKvz+Au/+ZAo4xZB9TmjW 0Cl1DNMw55cnVzK+8ECxcdC2u4k1FxfXBEik5+ZURVSJe+/CJCdFcxhtdbm001q7dT7l 6hFsRqYTsTmmqn6dVEGf6oJRnk94QUH8w4reU= MIME-Version: 1.0 Received: by 10.231.20.2 with SMTP id d2mr1230689ibb.27.1237260006495; Mon, 16 Mar 2009 20:20:06 -0700 (PDT) Date: Mon, 16 Mar 2009 23:20:06 -0400 Message-ID: <2396d9540903162020y701acb6ewc4d4f71613a75a24@mail.gmail.com> Subject: Capturing STDERR for use in log handler From: Tom Spencer To: modperl@perl.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org 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