On Wed, Dec 13, 2006 at 11:31:00AM -0800, Dean Arnold 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:
>
> 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.
Only for errors, not for general tracing.
> Has this been discussed before, or have I overlooked something that already
> exists ? It seems like a capability that would be useful.
It has been raised before. The only viable approach is to use a tied
filehandle - but I've never got round to doing the plumbing.
I'd imagine that some simple changes to set_trace_file() in DBI.xs would
suffice.
Patches welcome!
Tim.