On Wed, 13 Dec 2006 11:31:00 -0800, Dean Arnold <[EMAIL PROTECTED]> wrote:
> (Nothing surfaced in DBI.pm or the TODO list, nor the usual > net searches, so...) > > Has there been any thought to extending the target for > trace() beyond simple filenames ? I'm looking for a means > to supply either a coderef, or maybe an object implementing > a simple print/write interface. My need is to be able to direct > the traces to a centrally managed logging facility, and be able > to turn them off/on as needed, e.g: Instead of a coderef, I would suggest accepting file handles. As the simple open my $handle, ">", \$scalar; is a way to get your trace in a string if that would work, passing that string to a sub would solve your case too. I've just done something similar in a module that ties filehandles to functions, so if trace () were to accept file handles in all allowed formats (also IO::Handle), that would be generic enough to cover all needs. Good thought though! > my $logger = MyFancyLogger->new(); > > DBI->trace(2, sub { $logger->logInfo("DBI trace: " . $_[0]); }); > > I realize the tracing is currently buried in XS code, but > it appears the HandleError invokation code could be copied > to provide the ability. > > Has this been discussed before, or have I overlooked something that already > exists ? It seems like a capability that would be useful. > > Dean Arnold > Presicient Corp. > -- H.Merijn Brand Amsterdam Perl Mongers (http://amsterdam.pm.org/) using & porting perl 5.6.2, 5.8.x, 5.9.x on HP-UX 10.20, 11.00, 11.11, & 11.23, SuSE 10.0 & 10.1, AIX 4.3 & 5.2, and Cygwin. http://qa.perl.org http://mirrors.develooper.com/hpux/ http://www.test-smoke.org http://www.goldmark.org/jeff/stupid-disclaimers/