On Fri, Jan 30, 2004 at 12:27:02PM -0700, jim cromie wrote:It seems that all tracing/logging activity could be implemented by these hooks.
Tim Bunce wrote:
On Fri, Jan 30, 2004 at 03:00:37AM -0700, jim cromie wrote:speculative logging: The basic idea is to buffer up a log as a transaction proceeds,
This sounds like it could plug into the trace mechanism, either increasing its
leverage, simplifying its implementation, or both.
I've long wanted the DBI to have code hooks for method call entry & exit that could be used for building all sorts of funky tools.
And having just crept up to a line, let me cross it. Can new DBI2 have
2 logging levels under transactions ? Anything that commits (success)
logs at 1 or 2, things that rollback are logged at 5 or 6. This should
help unravel anomalous behavior by automatically putting your fovea
on it.
and decide afterwards what details of the log you want to keep - ie emit to the logging device.
Commit/rollback is the most obvious decision point, if youve got a
rollback, or an error, dump the log-trace since the start-transaction at a high level of detail, if all went smoothly, log only at a low trace-level.
Ah, okay. No, I wouldn't add that to the DBI, but if I add hooks for method call entry & exit that could be used to implement what you want - but do it for all drivers.
assuming DBI dispatch is done by AUTOLOAD, (for sake of discussion)
sub AUTOLOAD {
# call entry hooks
$_->(@_) foreach ($callbacks{"${AUTOLOAD}_entry"});
# call method itself, whether its on $dbh, $drh, etc.. @res = $AUTOLOAD->(@_);
# call post hooks
$_->([EMAIL PROTECTED], [EMAIL PROTECTED]) foreach $callbacks{"${AUTOLOAD}_exit"});
}and trace() just controls those callback lists kept for each hook.
(That reminds me, anothet component is to allow tracing to athere seems (to me anyway) some advantage to treating each
filehandle so a tied handle can be used, for example to gether trace output into a string.)
trace/set_error/info item separately. If autoflush on the handle can be turned off,
theres some possiblity of subclassing, and filtering the items when the queue is committed
to the file/socket/logging-object.
having named callbacks might be better than in an array, so that the trace-cb
is easy to replace wo disturbing info-cb, error-cb, etc..
But I confess, im not sure anymore whether were talking dbi-2 or 1 now.
Tim.
.
