Robert Spier wrote:
+sub register_standard_hooks {
+ my ($plugin, $qp) = @_;
+
+ for my $hook (keys %hooks) {
+ my $hooksub = "hook_$hook";
+ $hooksub =~ s/\W/_/g;
+ $plugin->register_hook( $hook, $hooksub )
+ if ($plugin->can($hooksub));
+ }
+}
Looks good, except it might be useful to log that at the debug level, e.g.
if ($plugin->can($hooksub)) {
# can't call ->log() directly because it assumes it's inside a hook
$plugin->varlog(LOGDEBUG, $self->plugin_name, " hooking ", $hook);
$plugin->register_hook( $hook, $hooksub );
}
since it is a useful bit of information to grep for all plugins hooking a
particular hook, and with the current plugin loading scheme, it only happens
once (as long as you are not running under tcpserver).
sub hook_rcpt {
my ($self, $transaction, $recipient) = @_;
- warn "uh.. don't really care, just calling child\n";
+ $self->log(LOGDEBUG, "uh.. don't really care, just calling child");
$self->SUPER::hook_rcpt( $transaction, $recipient );
}
I'd prefer, if you are actually adding the sample plugin, that it be "good" code
that someone can use to write a new plugin. I've tried to eliminate all
instances of warn() from the core (I see there are a couple more I need to get)
except from within a logging plugin, so that all output from the code is controlled.
Otherwise, "You may fire when ready, Gridley!" [1]
John
1) <http://www.americaslibrary.gov/cgi-bin/page.cgi/jb/reform/dewey_1>